babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670
  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. private _tempMatrix2;
  7514. protected _isWorldMatrixFrozen: boolean;
  7515. /** @hidden */
  7516. _indexInSceneTransformNodesArray: number;
  7517. /**
  7518. * An event triggered after the world matrix is updated
  7519. */
  7520. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7521. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7522. /**
  7523. * Gets a string identifying the name of the class
  7524. * @returns "TransformNode" string
  7525. */
  7526. getClassName(): string;
  7527. /**
  7528. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7529. */
  7530. position: Vector3;
  7531. /**
  7532. * 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)).
  7533. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7534. */
  7535. rotation: Vector3;
  7536. /**
  7537. * 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)).
  7538. */
  7539. scaling: Vector3;
  7540. /**
  7541. * 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).
  7542. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7543. */
  7544. rotationQuaternion: Nullable<Quaternion>;
  7545. /**
  7546. * The forward direction of that transform in world space.
  7547. */
  7548. readonly forward: Vector3;
  7549. /**
  7550. * The up direction of that transform in world space.
  7551. */
  7552. readonly up: Vector3;
  7553. /**
  7554. * The right direction of that transform in world space.
  7555. */
  7556. readonly right: Vector3;
  7557. /**
  7558. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7559. * @param matrix the matrix to copy the pose from
  7560. * @returns this TransformNode.
  7561. */
  7562. updatePoseMatrix(matrix: Matrix): TransformNode;
  7563. /**
  7564. * Returns the mesh Pose matrix.
  7565. * @returns the pose matrix
  7566. */
  7567. getPoseMatrix(): Matrix;
  7568. /** @hidden */
  7569. _isSynchronized(): boolean;
  7570. /** @hidden */
  7571. _initCache(): void;
  7572. /**
  7573. * Flag the transform node as dirty (Forcing it to update everything)
  7574. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7575. * @returns this transform node
  7576. */
  7577. markAsDirty(property: string): TransformNode;
  7578. /**
  7579. * Returns the current mesh absolute position.
  7580. * Returns a Vector3.
  7581. */
  7582. readonly absolutePosition: Vector3;
  7583. /**
  7584. * Sets a new matrix to apply before all other transformation
  7585. * @param matrix defines the transform matrix
  7586. * @returns the current TransformNode
  7587. */
  7588. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7589. /**
  7590. * Sets a new pivot matrix to the current node
  7591. * @param matrix defines the new pivot matrix to use
  7592. * @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
  7593. * @returns the current TransformNode
  7594. */
  7595. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7596. /**
  7597. * Returns the mesh pivot matrix.
  7598. * Default : Identity.
  7599. * @returns the matrix
  7600. */
  7601. getPivotMatrix(): Matrix;
  7602. /**
  7603. * Prevents the World matrix to be computed any longer.
  7604. * @returns the TransformNode.
  7605. */
  7606. freezeWorldMatrix(): TransformNode;
  7607. /**
  7608. * Allows back the World matrix computation.
  7609. * @returns the TransformNode.
  7610. */
  7611. unfreezeWorldMatrix(): this;
  7612. /**
  7613. * True if the World matrix has been frozen.
  7614. */
  7615. readonly isWorldMatrixFrozen: boolean;
  7616. /**
  7617. * Retuns the mesh absolute position in the World.
  7618. * @returns a Vector3.
  7619. */
  7620. getAbsolutePosition(): Vector3;
  7621. /**
  7622. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7623. * @param absolutePosition the absolute position to set
  7624. * @returns the TransformNode.
  7625. */
  7626. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7627. /**
  7628. * Sets the mesh position in its local space.
  7629. * @param vector3 the position to set in localspace
  7630. * @returns the TransformNode.
  7631. */
  7632. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7633. /**
  7634. * Returns the mesh position in the local space from the current World matrix values.
  7635. * @returns a new Vector3.
  7636. */
  7637. getPositionExpressedInLocalSpace(): Vector3;
  7638. /**
  7639. * Translates the mesh along the passed Vector3 in its local space.
  7640. * @param vector3 the distance to translate in localspace
  7641. * @returns the TransformNode.
  7642. */
  7643. locallyTranslate(vector3: Vector3): TransformNode;
  7644. private static _lookAtVectorCache;
  7645. /**
  7646. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7647. * @param targetPoint the position (must be in same space as current mesh) to look at
  7648. * @param yawCor optional yaw (y-axis) correction in radians
  7649. * @param pitchCor optional pitch (x-axis) correction in radians
  7650. * @param rollCor optional roll (z-axis) correction in radians
  7651. * @param space the choosen space of the target
  7652. * @returns the TransformNode.
  7653. */
  7654. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7655. /**
  7656. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7657. * This Vector3 is expressed in the World space.
  7658. * @param localAxis axis to rotate
  7659. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7660. */
  7661. getDirection(localAxis: Vector3): Vector3;
  7662. /**
  7663. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7664. * localAxis is expressed in the mesh local space.
  7665. * result is computed in the Wordl space from the mesh World matrix.
  7666. * @param localAxis axis to rotate
  7667. * @param result the resulting transformnode
  7668. * @returns this TransformNode.
  7669. */
  7670. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7671. /**
  7672. * Sets this transform node rotation to the given local axis.
  7673. * @param localAxis the axis in local space
  7674. * @param yawCor optional yaw (y-axis) correction in radians
  7675. * @param pitchCor optional pitch (x-axis) correction in radians
  7676. * @param rollCor optional roll (z-axis) correction in radians
  7677. * @returns this TransformNode
  7678. */
  7679. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7680. /**
  7681. * Sets a new pivot point to the current node
  7682. * @param point defines the new pivot point to use
  7683. * @param space defines if the point is in world or local space (local by default)
  7684. * @returns the current TransformNode
  7685. */
  7686. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7687. /**
  7688. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7689. * @returns the pivot point
  7690. */
  7691. getPivotPoint(): Vector3;
  7692. /**
  7693. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7694. * @param result the vector3 to store the result
  7695. * @returns this TransformNode.
  7696. */
  7697. getPivotPointToRef(result: Vector3): TransformNode;
  7698. /**
  7699. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7700. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7701. */
  7702. getAbsolutePivotPoint(): Vector3;
  7703. /**
  7704. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7705. * @param result vector3 to store the result
  7706. * @returns this TransformNode.
  7707. */
  7708. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7709. /**
  7710. * Defines the passed node as the parent of the current node.
  7711. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7712. * @param node the node ot set as the parent
  7713. * @returns this TransformNode.
  7714. */
  7715. setParent(node: Nullable<Node>): TransformNode;
  7716. private _nonUniformScaling;
  7717. /**
  7718. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7719. */
  7720. readonly nonUniformScaling: boolean;
  7721. /** @hidden */
  7722. _updateNonUniformScalingState(value: boolean): boolean;
  7723. /**
  7724. * Attach the current TransformNode to another TransformNode associated with a bone
  7725. * @param bone Bone affecting the TransformNode
  7726. * @param affectedTransformNode TransformNode associated with the bone
  7727. * @returns this object
  7728. */
  7729. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7730. /**
  7731. * Detach the transform node if its associated with a bone
  7732. * @returns this object
  7733. */
  7734. detachFromBone(): TransformNode;
  7735. private static _rotationAxisCache;
  7736. /**
  7737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7738. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7739. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7740. * The passed axis is also normalized.
  7741. * @param axis the axis to rotate around
  7742. * @param amount the amount to rotate in radians
  7743. * @param space Space to rotate in (Default: local)
  7744. * @returns the TransformNode.
  7745. */
  7746. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7747. /**
  7748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7749. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7750. * The passed axis is also normalized. .
  7751. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7752. * @param point the point to rotate around
  7753. * @param axis the axis to rotate around
  7754. * @param amount the amount to rotate in radians
  7755. * @returns the TransformNode
  7756. */
  7757. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7758. /**
  7759. * Translates the mesh along the axis vector for the passed distance in the given space.
  7760. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7761. * @param axis the axis to translate in
  7762. * @param distance the distance to translate
  7763. * @param space Space to rotate in (Default: local)
  7764. * @returns the TransformNode.
  7765. */
  7766. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7767. /**
  7768. * Adds a rotation step to the mesh current rotation.
  7769. * x, y, z are Euler angles expressed in radians.
  7770. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7771. * This means this rotation is made in the mesh local space only.
  7772. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7773. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7774. * ```javascript
  7775. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7776. * ```
  7777. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7778. * 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.
  7779. * @param x Rotation to add
  7780. * @param y Rotation to add
  7781. * @param z Rotation to add
  7782. * @returns the TransformNode.
  7783. */
  7784. addRotation(x: number, y: number, z: number): TransformNode;
  7785. /**
  7786. * Computes the world matrix of the node
  7787. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7788. * @returns the world matrix
  7789. */
  7790. computeWorldMatrix(force?: boolean): Matrix;
  7791. protected _afterComputeWorldMatrix(): void;
  7792. /**
  7793. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7794. * @param func callback function to add
  7795. *
  7796. * @returns the TransformNode.
  7797. */
  7798. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7799. /**
  7800. * Removes a registered callback function.
  7801. * @param func callback function to remove
  7802. * @returns the TransformNode.
  7803. */
  7804. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7805. /**
  7806. * Gets the position of the current mesh in camera space
  7807. * @param camera defines the camera to use
  7808. * @returns a position
  7809. */
  7810. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7811. /**
  7812. * Returns the distance from the mesh to the active camera
  7813. * @param camera defines the camera to use
  7814. * @returns the distance
  7815. */
  7816. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7817. /**
  7818. * Clone the current transform node
  7819. * @param name Name of the new clone
  7820. * @param newParent New parent for the clone
  7821. * @param doNotCloneChildren Do not clone children hierarchy
  7822. * @returns the new transform node
  7823. */
  7824. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7825. /**
  7826. * Serializes the objects information.
  7827. * @param currentSerializationObject defines the object to serialize in
  7828. * @returns the serialized object
  7829. */
  7830. serialize(currentSerializationObject?: any): any;
  7831. /**
  7832. * Returns a new TransformNode object parsed from the source provided.
  7833. * @param parsedTransformNode is the source.
  7834. * @param scene the scne the object belongs to
  7835. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7836. * @returns a new TransformNode object parsed from the source provided.
  7837. */
  7838. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7839. /**
  7840. * Get all child-transformNodes of this node
  7841. * @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
  7842. * @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
  7843. * @returns an array of TransformNode
  7844. */
  7845. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7846. /**
  7847. * Releases resources associated with this transform node.
  7848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7850. */
  7851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7852. }
  7853. }
  7854. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7855. /**
  7856. * Class used to override all child animations of a given target
  7857. */
  7858. export class AnimationPropertiesOverride {
  7859. /**
  7860. * Gets or sets a value indicating if animation blending must be used
  7861. */
  7862. enableBlending: boolean;
  7863. /**
  7864. * Gets or sets the blending speed to use when enableBlending is true
  7865. */
  7866. blendingSpeed: number;
  7867. /**
  7868. * Gets or sets the default loop mode to use
  7869. */
  7870. loopMode: number;
  7871. }
  7872. }
  7873. declare module "babylonjs/Bones/bone" {
  7874. import { Skeleton } from "babylonjs/Bones/skeleton";
  7875. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7876. import { Nullable } from "babylonjs/types";
  7877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7879. import { Node } from "babylonjs/node";
  7880. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7881. /**
  7882. * Class used to store bone information
  7883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7884. */
  7885. export class Bone extends Node {
  7886. /**
  7887. * defines the bone name
  7888. */
  7889. name: string;
  7890. private static _tmpVecs;
  7891. private static _tmpQuat;
  7892. private static _tmpMats;
  7893. /**
  7894. * Gets the list of child bones
  7895. */
  7896. children: Bone[];
  7897. /** Gets the animations associated with this bone */
  7898. animations: import("babylonjs/Animations/animation").Animation[];
  7899. /**
  7900. * Gets or sets bone length
  7901. */
  7902. length: number;
  7903. /**
  7904. * @hidden Internal only
  7905. * Set this value to map this bone to a different index in the transform matrices
  7906. * Set this value to -1 to exclude the bone from the transform matrices
  7907. */
  7908. _index: Nullable<number>;
  7909. private _skeleton;
  7910. private _localMatrix;
  7911. private _restPose;
  7912. private _baseMatrix;
  7913. private _absoluteTransform;
  7914. private _invertedAbsoluteTransform;
  7915. private _parent;
  7916. private _scalingDeterminant;
  7917. private _worldTransform;
  7918. private _localScaling;
  7919. private _localRotation;
  7920. private _localPosition;
  7921. private _needToDecompose;
  7922. private _needToCompose;
  7923. /** @hidden */
  7924. _linkedTransformNode: Nullable<TransformNode>;
  7925. /** @hidden */
  7926. /** @hidden */
  7927. _matrix: Matrix;
  7928. /**
  7929. * Create a new bone
  7930. * @param name defines the bone name
  7931. * @param skeleton defines the parent skeleton
  7932. * @param parentBone defines the parent (can be null if the bone is the root)
  7933. * @param localMatrix defines the local matrix
  7934. * @param restPose defines the rest pose matrix
  7935. * @param baseMatrix defines the base matrix
  7936. * @param index defines index of the bone in the hiearchy
  7937. */
  7938. constructor(
  7939. /**
  7940. * defines the bone name
  7941. */
  7942. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7943. /**
  7944. * Gets the current object class name.
  7945. * @return the class name
  7946. */
  7947. getClassName(): string;
  7948. /**
  7949. * Gets the parent skeleton
  7950. * @returns a skeleton
  7951. */
  7952. getSkeleton(): Skeleton;
  7953. /**
  7954. * Gets parent bone
  7955. * @returns a bone or null if the bone is the root of the bone hierarchy
  7956. */
  7957. getParent(): Nullable<Bone>;
  7958. /**
  7959. * Returns an array containing the root bones
  7960. * @returns an array containing the root bones
  7961. */
  7962. getChildren(): Array<Bone>;
  7963. /**
  7964. * Sets the parent bone
  7965. * @param parent defines the parent (can be null if the bone is the root)
  7966. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7967. */
  7968. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7969. /**
  7970. * Gets the local matrix
  7971. * @returns a matrix
  7972. */
  7973. getLocalMatrix(): Matrix;
  7974. /**
  7975. * Gets the base matrix (initial matrix which remains unchanged)
  7976. * @returns a matrix
  7977. */
  7978. getBaseMatrix(): Matrix;
  7979. /**
  7980. * Gets the rest pose matrix
  7981. * @returns a matrix
  7982. */
  7983. getRestPose(): Matrix;
  7984. /**
  7985. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7986. */
  7987. getWorldMatrix(): Matrix;
  7988. /**
  7989. * Sets the local matrix to rest pose matrix
  7990. */
  7991. returnToRest(): void;
  7992. /**
  7993. * Gets the inverse of the absolute transform matrix.
  7994. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7995. * @returns a matrix
  7996. */
  7997. getInvertedAbsoluteTransform(): Matrix;
  7998. /**
  7999. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8000. * @returns a matrix
  8001. */
  8002. getAbsoluteTransform(): Matrix;
  8003. /**
  8004. * Links with the given transform node.
  8005. * The local matrix of this bone is copied from the transform node every frame.
  8006. * @param transformNode defines the transform node to link to
  8007. */
  8008. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8009. /** Gets or sets current position (in local space) */
  8010. position: Vector3;
  8011. /** Gets or sets current rotation (in local space) */
  8012. rotation: Vector3;
  8013. /** Gets or sets current rotation quaternion (in local space) */
  8014. rotationQuaternion: Quaternion;
  8015. /** Gets or sets current scaling (in local space) */
  8016. scaling: Vector3;
  8017. /**
  8018. * Gets the animation properties override
  8019. */
  8020. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8021. private _decompose;
  8022. private _compose;
  8023. /**
  8024. * Update the base and local matrices
  8025. * @param matrix defines the new base or local matrix
  8026. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8027. * @param updateLocalMatrix defines if the local matrix should be updated
  8028. */
  8029. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8030. /** @hidden */
  8031. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8032. /**
  8033. * Flag the bone as dirty (Forcing it to update everything)
  8034. */
  8035. markAsDirty(): void;
  8036. private _markAsDirtyAndCompose;
  8037. private _markAsDirtyAndDecompose;
  8038. /**
  8039. * Translate the bone in local or world space
  8040. * @param vec The amount to translate the bone
  8041. * @param space The space that the translation is in
  8042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8043. */
  8044. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8045. /**
  8046. * Set the postion of the bone in local or world space
  8047. * @param position The position to set the bone
  8048. * @param space The space that the position is in
  8049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8050. */
  8051. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8052. /**
  8053. * Set the absolute position of the bone (world space)
  8054. * @param position The position to set the bone
  8055. * @param mesh The mesh that this bone is attached to
  8056. */
  8057. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8058. /**
  8059. * Scale the bone on the x, y and z axes (in local space)
  8060. * @param x The amount to scale the bone on the x axis
  8061. * @param y The amount to scale the bone on the y axis
  8062. * @param z The amount to scale the bone on the z axis
  8063. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8064. */
  8065. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8066. /**
  8067. * Set the bone scaling in local space
  8068. * @param scale defines the scaling vector
  8069. */
  8070. setScale(scale: Vector3): void;
  8071. /**
  8072. * Gets the current scaling in local space
  8073. * @returns the current scaling vector
  8074. */
  8075. getScale(): Vector3;
  8076. /**
  8077. * Gets the current scaling in local space and stores it in a target vector
  8078. * @param result defines the target vector
  8079. */
  8080. getScaleToRef(result: Vector3): void;
  8081. /**
  8082. * Set the yaw, pitch, and roll of the bone in local or world space
  8083. * @param yaw The rotation of the bone on the y axis
  8084. * @param pitch The rotation of the bone on the x axis
  8085. * @param roll The rotation of the bone on the z axis
  8086. * @param space The space that the axes of rotation are in
  8087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8088. */
  8089. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8090. /**
  8091. * Add a rotation to the bone on an axis in local or world space
  8092. * @param axis The axis to rotate the bone on
  8093. * @param amount The amount to rotate the bone
  8094. * @param space The space that the axis is in
  8095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8096. */
  8097. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8098. /**
  8099. * Set the rotation of the bone to a particular axis angle in local or world space
  8100. * @param axis The axis to rotate the bone on
  8101. * @param angle The angle that the bone should be rotated to
  8102. * @param space The space that the axis is in
  8103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8104. */
  8105. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8106. /**
  8107. * Set the euler rotation of the bone in local of world space
  8108. * @param rotation The euler rotation that the bone should be set to
  8109. * @param space The space that the rotation is in
  8110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8111. */
  8112. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8113. /**
  8114. * Set the quaternion rotation of the bone in local of world space
  8115. * @param quat The quaternion rotation that the bone should be set to
  8116. * @param space The space that the rotation is in
  8117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8118. */
  8119. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8120. /**
  8121. * Set the rotation matrix of the bone in local of world space
  8122. * @param rotMat The rotation matrix that the bone should be set to
  8123. * @param space The space that the rotation is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8127. private _rotateWithMatrix;
  8128. private _getNegativeRotationToRef;
  8129. /**
  8130. * Get the position of the bone in local or world space
  8131. * @param space The space that the returned position is in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. * @returns The position of the bone
  8134. */
  8135. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8136. /**
  8137. * Copy the position of the bone to a vector3 in local or world space
  8138. * @param space The space that the returned position is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. * @param result The vector3 to copy the position to
  8141. */
  8142. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8143. /**
  8144. * Get the absolute position of the bone (world space)
  8145. * @param mesh The mesh that this bone is attached to
  8146. * @returns The absolute position of the bone
  8147. */
  8148. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8149. /**
  8150. * Copy the absolute position of the bone (world space) to the result param
  8151. * @param mesh The mesh that this bone is attached to
  8152. * @param result The vector3 to copy the absolute position to
  8153. */
  8154. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8155. /**
  8156. * Compute the absolute transforms of this bone and its children
  8157. */
  8158. computeAbsoluteTransforms(): void;
  8159. /**
  8160. * Get the world direction from an axis that is in the local space of the bone
  8161. * @param localAxis The local direction that is used to compute the world direction
  8162. * @param mesh The mesh that this bone is attached to
  8163. * @returns The world direction
  8164. */
  8165. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8166. /**
  8167. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8168. * @param localAxis The local direction that is used to compute the world direction
  8169. * @param mesh The mesh that this bone is attached to
  8170. * @param result The vector3 that the world direction will be copied to
  8171. */
  8172. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8173. /**
  8174. * Get the euler rotation of the bone in local or world space
  8175. * @param space The space that the rotation should be in
  8176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8177. * @returns The euler rotation
  8178. */
  8179. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8180. /**
  8181. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8182. * @param space The space that the rotation should be in
  8183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8184. * @param result The vector3 that the rotation should be copied to
  8185. */
  8186. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8187. /**
  8188. * Get the quaternion rotation of the bone in either local or world space
  8189. * @param space The space that the rotation should be in
  8190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8191. * @returns The quaternion rotation
  8192. */
  8193. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8194. /**
  8195. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8196. * @param space The space that the rotation should be in
  8197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8198. * @param result The quaternion that the rotation should be copied to
  8199. */
  8200. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8201. /**
  8202. * Get the rotation matrix of the bone in local or world space
  8203. * @param space The space that the rotation should be in
  8204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8205. * @returns The rotation matrix
  8206. */
  8207. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8208. /**
  8209. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8210. * @param space The space that the rotation should be in
  8211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8212. * @param result The quaternion that the rotation should be copied to
  8213. */
  8214. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8215. /**
  8216. * Get the world position of a point that is in the local space of the bone
  8217. * @param position The local position
  8218. * @param mesh The mesh that this bone is attached to
  8219. * @returns The world position
  8220. */
  8221. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8222. /**
  8223. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8224. * @param position The local position
  8225. * @param mesh The mesh that this bone is attached to
  8226. * @param result The vector3 that the world position should be copied to
  8227. */
  8228. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8229. /**
  8230. * Get the local position of a point that is in world space
  8231. * @param position The world position
  8232. * @param mesh The mesh that this bone is attached to
  8233. * @returns The local position
  8234. */
  8235. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8236. /**
  8237. * Get the local position of a point that is in world space and copy it to the result param
  8238. * @param position The world position
  8239. * @param mesh The mesh that this bone is attached to
  8240. * @param result The vector3 that the local position should be copied to
  8241. */
  8242. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8243. }
  8244. }
  8245. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8246. import { Nullable } from "babylonjs/types";
  8247. import { Scene } from "babylonjs/scene";
  8248. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8250. /**
  8251. * Class for creating a cube texture
  8252. */
  8253. export class CubeTexture extends BaseTexture {
  8254. private _delayedOnLoad;
  8255. /**
  8256. * The url of the texture
  8257. */
  8258. url: string;
  8259. /**
  8260. * Gets or sets the center of the bounding box associated with the cube texture.
  8261. * It must define where the camera used to render the texture was set
  8262. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8263. */
  8264. boundingBoxPosition: Vector3;
  8265. private _boundingBoxSize;
  8266. /**
  8267. * Gets or sets the size of the bounding box associated with the cube texture
  8268. * When defined, the cubemap will switch to local mode
  8269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8270. * @example https://www.babylonjs-playground.com/#RNASML
  8271. */
  8272. /**
  8273. * Returns the bounding box size
  8274. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8275. */
  8276. boundingBoxSize: Vector3;
  8277. protected _rotationY: number;
  8278. /**
  8279. * Sets texture matrix rotation angle around Y axis in radians.
  8280. */
  8281. /**
  8282. * Gets texture matrix rotation angle around Y axis radians.
  8283. */
  8284. rotationY: number;
  8285. /**
  8286. * Are mip maps generated for this texture or not.
  8287. */
  8288. readonly noMipmap: boolean;
  8289. private _noMipmap;
  8290. private _files;
  8291. private _extensions;
  8292. private _textureMatrix;
  8293. private _format;
  8294. private _createPolynomials;
  8295. /** @hidden */
  8296. _prefiltered: boolean;
  8297. /**
  8298. * Creates a cube texture from an array of image urls
  8299. * @param files defines an array of image urls
  8300. * @param scene defines the hosting scene
  8301. * @param noMipmap specifies if mip maps are not used
  8302. * @returns a cube texture
  8303. */
  8304. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8305. /**
  8306. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8307. * @param url defines the url of the prefiltered texture
  8308. * @param scene defines the scene the texture is attached to
  8309. * @param forcedExtension defines the extension of the file if different from the url
  8310. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8311. * @return the prefiltered texture
  8312. */
  8313. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8314. /**
  8315. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8316. * as prefiltered data.
  8317. * @param rootUrl defines the url of the texture or the root name of the six images
  8318. * @param scene defines the scene the texture is attached to
  8319. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8320. * @param noMipmap defines if mipmaps should be created or not
  8321. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8322. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8323. * @param onError defines a callback triggered in case of error during load
  8324. * @param format defines the internal format to use for the texture once loaded
  8325. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8326. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8327. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8328. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8329. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8330. * @return the cube texture
  8331. */
  8332. 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);
  8333. /**
  8334. * Get the current class name of the texture useful for serialization or dynamic coding.
  8335. * @returns "CubeTexture"
  8336. */
  8337. getClassName(): string;
  8338. /**
  8339. * Update the url (and optional buffer) of this texture if url was null during construction.
  8340. * @param url the url of the texture
  8341. * @param forcedExtension defines the extension to use
  8342. * @param onLoad callback called when the texture is loaded (defaults to null)
  8343. */
  8344. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8345. /**
  8346. * Delays loading of the cube texture
  8347. * @param forcedExtension defines the extension to use
  8348. */
  8349. delayLoad(forcedExtension?: string): void;
  8350. /**
  8351. * Returns the reflection texture matrix
  8352. * @returns the reflection texture matrix
  8353. */
  8354. getReflectionTextureMatrix(): Matrix;
  8355. /**
  8356. * Sets the reflection texture matrix
  8357. * @param value Reflection texture matrix
  8358. */
  8359. setReflectionTextureMatrix(value: Matrix): void;
  8360. /**
  8361. * Parses text to create a cube texture
  8362. * @param parsedTexture define the serialized text to read from
  8363. * @param scene defines the hosting scene
  8364. * @param rootUrl defines the root url of the cube texture
  8365. * @returns a cube texture
  8366. */
  8367. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8368. /**
  8369. * Makes a clone, or deep copy, of the cube texture
  8370. * @returns a new cube texture
  8371. */
  8372. clone(): CubeTexture;
  8373. }
  8374. }
  8375. declare module "babylonjs/Shaders/postprocess.vertex" {
  8376. /** @hidden */
  8377. export var postprocessVertexShader: {
  8378. name: string;
  8379. shader: string;
  8380. };
  8381. }
  8382. declare module "babylonjs/Cameras/targetCamera" {
  8383. import { Nullable } from "babylonjs/types";
  8384. import { Camera } from "babylonjs/Cameras/camera";
  8385. import { Scene } from "babylonjs/scene";
  8386. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8387. /**
  8388. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8389. * This is the base of the follow, arc rotate cameras and Free camera
  8390. * @see http://doc.babylonjs.com/features/cameras
  8391. */
  8392. export class TargetCamera extends Camera {
  8393. private static _RigCamTransformMatrix;
  8394. private static _TargetTransformMatrix;
  8395. private static _TargetFocalPoint;
  8396. /**
  8397. * Define the current direction the camera is moving to
  8398. */
  8399. cameraDirection: Vector3;
  8400. /**
  8401. * Define the current rotation the camera is rotating to
  8402. */
  8403. cameraRotation: Vector2;
  8404. /**
  8405. * When set, the up vector of the camera will be updated by the rotation of the camera
  8406. */
  8407. updateUpVectorFromRotation: boolean;
  8408. private _tmpQuaternion;
  8409. /**
  8410. * Define the current rotation of the camera
  8411. */
  8412. rotation: Vector3;
  8413. /**
  8414. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8415. */
  8416. rotationQuaternion: Quaternion;
  8417. /**
  8418. * Define the current speed of the camera
  8419. */
  8420. speed: number;
  8421. /**
  8422. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8423. * around all axis.
  8424. */
  8425. noRotationConstraint: boolean;
  8426. /**
  8427. * Define the current target of the camera as an object or a position.
  8428. */
  8429. lockedTarget: any;
  8430. /** @hidden */
  8431. _currentTarget: Vector3;
  8432. /** @hidden */
  8433. _initialFocalDistance: number;
  8434. /** @hidden */
  8435. _viewMatrix: Matrix;
  8436. /** @hidden */
  8437. _camMatrix: Matrix;
  8438. /** @hidden */
  8439. _cameraTransformMatrix: Matrix;
  8440. /** @hidden */
  8441. _cameraRotationMatrix: Matrix;
  8442. /** @hidden */
  8443. _referencePoint: Vector3;
  8444. /** @hidden */
  8445. _transformedReferencePoint: Vector3;
  8446. protected _globalCurrentTarget: Vector3;
  8447. protected _globalCurrentUpVector: Vector3;
  8448. /** @hidden */
  8449. _reset: () => void;
  8450. private _defaultUp;
  8451. /**
  8452. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8453. * This is the base of the follow, arc rotate cameras and Free camera
  8454. * @see http://doc.babylonjs.com/features/cameras
  8455. * @param name Defines the name of the camera in the scene
  8456. * @param position Defines the start position of the camera in the scene
  8457. * @param scene Defines the scene the camera belongs to
  8458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8459. */
  8460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8461. /**
  8462. * Gets the position in front of the camera at a given distance.
  8463. * @param distance The distance from the camera we want the position to be
  8464. * @returns the position
  8465. */
  8466. getFrontPosition(distance: number): Vector3;
  8467. /** @hidden */
  8468. _getLockedTargetPosition(): Nullable<Vector3>;
  8469. private _storedPosition;
  8470. private _storedRotation;
  8471. private _storedRotationQuaternion;
  8472. /**
  8473. * Store current camera state of the camera (fov, position, rotation, etc..)
  8474. * @returns the camera
  8475. */
  8476. storeState(): Camera;
  8477. /**
  8478. * Restored camera state. You must call storeState() first
  8479. * @returns whether it was successful or not
  8480. * @hidden
  8481. */
  8482. _restoreStateValues(): boolean;
  8483. /** @hidden */
  8484. _initCache(): void;
  8485. /** @hidden */
  8486. _updateCache(ignoreParentClass?: boolean): void;
  8487. /** @hidden */
  8488. _isSynchronizedViewMatrix(): boolean;
  8489. /** @hidden */
  8490. _computeLocalCameraSpeed(): number;
  8491. /**
  8492. * Defines the target the camera should look at.
  8493. * This will automatically adapt alpha beta and radius to fit within the new target.
  8494. * @param target Defines the new target as a Vector or a mesh
  8495. */
  8496. setTarget(target: Vector3): void;
  8497. /**
  8498. * Return the current target position of the camera. This value is expressed in local space.
  8499. * @returns the target position
  8500. */
  8501. getTarget(): Vector3;
  8502. /** @hidden */
  8503. _decideIfNeedsToMove(): boolean;
  8504. /** @hidden */
  8505. _updatePosition(): void;
  8506. /** @hidden */
  8507. _checkInputs(): void;
  8508. protected _updateCameraRotationMatrix(): void;
  8509. /**
  8510. * 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)
  8511. * @returns the current camera
  8512. */
  8513. private _rotateUpVectorWithCameraRotationMatrix;
  8514. private _cachedRotationZ;
  8515. private _cachedQuaternionRotationZ;
  8516. /** @hidden */
  8517. _getViewMatrix(): Matrix;
  8518. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8519. /**
  8520. * @hidden
  8521. */
  8522. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8523. /**
  8524. * @hidden
  8525. */
  8526. _updateRigCameras(): void;
  8527. private _getRigCamPositionAndTarget;
  8528. /**
  8529. * Gets the current object class name.
  8530. * @return the class name
  8531. */
  8532. getClassName(): string;
  8533. }
  8534. }
  8535. declare module "babylonjs/Cameras/cameraInputsManager" {
  8536. import { Nullable } from "babylonjs/types";
  8537. import { Camera } from "babylonjs/Cameras/camera";
  8538. /**
  8539. * @ignore
  8540. * This is a list of all the different input types that are available in the application.
  8541. * Fo instance: ArcRotateCameraGamepadInput...
  8542. */
  8543. export var CameraInputTypes: {};
  8544. /**
  8545. * This is the contract to implement in order to create a new input class.
  8546. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8547. */
  8548. export interface ICameraInput<TCamera extends Camera> {
  8549. /**
  8550. * Defines the camera the input is attached to.
  8551. */
  8552. camera: Nullable<TCamera>;
  8553. /**
  8554. * Gets the class name of the current intput.
  8555. * @returns the class name
  8556. */
  8557. getClassName(): string;
  8558. /**
  8559. * Get the friendly name associated with the input class.
  8560. * @returns the input friendly name
  8561. */
  8562. getSimpleName(): string;
  8563. /**
  8564. * Attach the input controls to a specific dom element to get the input from.
  8565. * @param element Defines the element the controls should be listened from
  8566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8567. */
  8568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8569. /**
  8570. * Detach the current controls from the specified dom element.
  8571. * @param element Defines the element to stop listening the inputs from
  8572. */
  8573. detachControl(element: Nullable<HTMLElement>): void;
  8574. /**
  8575. * Update the current camera state depending on the inputs that have been used this frame.
  8576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8577. */
  8578. checkInputs?: () => void;
  8579. }
  8580. /**
  8581. * Represents a map of input types to input instance or input index to input instance.
  8582. */
  8583. export interface CameraInputsMap<TCamera extends Camera> {
  8584. /**
  8585. * Accessor to the input by input type.
  8586. */
  8587. [name: string]: ICameraInput<TCamera>;
  8588. /**
  8589. * Accessor to the input by input index.
  8590. */
  8591. [idx: number]: ICameraInput<TCamera>;
  8592. }
  8593. /**
  8594. * This represents the input manager used within a camera.
  8595. * It helps dealing with all the different kind of input attached to a camera.
  8596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8597. */
  8598. export class CameraInputsManager<TCamera extends Camera> {
  8599. /**
  8600. * Defines the list of inputs attahed to the camera.
  8601. */
  8602. attached: CameraInputsMap<TCamera>;
  8603. /**
  8604. * Defines the dom element the camera is collecting inputs from.
  8605. * This is null if the controls have not been attached.
  8606. */
  8607. attachedElement: Nullable<HTMLElement>;
  8608. /**
  8609. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8610. */
  8611. noPreventDefault: boolean;
  8612. /**
  8613. * Defined the camera the input manager belongs to.
  8614. */
  8615. camera: TCamera;
  8616. /**
  8617. * Update the current camera state depending on the inputs that have been used this frame.
  8618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8619. */
  8620. checkInputs: () => void;
  8621. /**
  8622. * Instantiate a new Camera Input Manager.
  8623. * @param camera Defines the camera the input manager blongs to
  8624. */
  8625. constructor(camera: TCamera);
  8626. /**
  8627. * Add an input method to a camera
  8628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8629. * @param input camera input method
  8630. */
  8631. add(input: ICameraInput<TCamera>): void;
  8632. /**
  8633. * Remove a specific input method from a camera
  8634. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8635. * @param inputToRemove camera input method
  8636. */
  8637. remove(inputToRemove: ICameraInput<TCamera>): void;
  8638. /**
  8639. * Remove a specific input type from a camera
  8640. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8641. * @param inputType the type of the input to remove
  8642. */
  8643. removeByType(inputType: string): void;
  8644. private _addCheckInputs;
  8645. /**
  8646. * Attach the input controls to the currently attached dom element to listen the events from.
  8647. * @param input Defines the input to attach
  8648. */
  8649. attachInput(input: ICameraInput<TCamera>): void;
  8650. /**
  8651. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8652. * @param element Defines the dom element to collect the events from
  8653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8654. */
  8655. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8656. /**
  8657. * Detach the current manager inputs controls from a specific dom element.
  8658. * @param element Defines the dom element to collect the events from
  8659. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8660. */
  8661. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8662. /**
  8663. * Rebuild the dynamic inputCheck function from the current list of
  8664. * defined inputs in the manager.
  8665. */
  8666. rebuildInputCheck(): void;
  8667. /**
  8668. * Remove all attached input methods from a camera
  8669. */
  8670. clear(): void;
  8671. /**
  8672. * Serialize the current input manager attached to a camera.
  8673. * This ensures than once parsed,
  8674. * the input associated to the camera will be identical to the current ones
  8675. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8676. */
  8677. serialize(serializedCamera: any): void;
  8678. /**
  8679. * Parses an input manager serialized JSON to restore the previous list of inputs
  8680. * and states associated to a camera.
  8681. * @param parsedCamera Defines the JSON to parse
  8682. */
  8683. parse(parsedCamera: any): void;
  8684. }
  8685. }
  8686. declare module "babylonjs/Events/keyboardEvents" {
  8687. /**
  8688. * Gather the list of keyboard event types as constants.
  8689. */
  8690. export class KeyboardEventTypes {
  8691. /**
  8692. * The keydown event is fired when a key becomes active (pressed).
  8693. */
  8694. static readonly KEYDOWN: number;
  8695. /**
  8696. * The keyup event is fired when a key has been released.
  8697. */
  8698. static readonly KEYUP: number;
  8699. }
  8700. /**
  8701. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8702. */
  8703. export class KeyboardInfo {
  8704. /**
  8705. * Defines the type of event (KeyboardEventTypes)
  8706. */
  8707. type: number;
  8708. /**
  8709. * Defines the related dom event
  8710. */
  8711. event: KeyboardEvent;
  8712. /**
  8713. * Instantiates a new keyboard info.
  8714. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8715. * @param type Defines the type of event (KeyboardEventTypes)
  8716. * @param event Defines the related dom event
  8717. */
  8718. constructor(
  8719. /**
  8720. * Defines the type of event (KeyboardEventTypes)
  8721. */
  8722. type: number,
  8723. /**
  8724. * Defines the related dom event
  8725. */
  8726. event: KeyboardEvent);
  8727. }
  8728. /**
  8729. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8730. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8731. */
  8732. export class KeyboardInfoPre extends KeyboardInfo {
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number;
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent;
  8741. /**
  8742. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8743. */
  8744. skipOnPointerObservable: boolean;
  8745. /**
  8746. * Instantiates a new keyboard pre info.
  8747. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8748. * @param type Defines the type of event (KeyboardEventTypes)
  8749. * @param event Defines the related dom event
  8750. */
  8751. constructor(
  8752. /**
  8753. * Defines the type of event (KeyboardEventTypes)
  8754. */
  8755. type: number,
  8756. /**
  8757. * Defines the related dom event
  8758. */
  8759. event: KeyboardEvent);
  8760. }
  8761. }
  8762. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8763. import { Nullable } from "babylonjs/types";
  8764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8765. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8766. /**
  8767. * Manage the keyboard inputs to control the movement of a free camera.
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. */
  8770. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8771. /**
  8772. * Defines the camera the input is attached to.
  8773. */
  8774. camera: FreeCamera;
  8775. /**
  8776. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8777. */
  8778. keysUp: number[];
  8779. /**
  8780. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8781. */
  8782. keysDown: number[];
  8783. /**
  8784. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8785. */
  8786. keysLeft: number[];
  8787. /**
  8788. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8789. */
  8790. keysRight: number[];
  8791. private _keys;
  8792. private _onCanvasBlurObserver;
  8793. private _onKeyboardObserver;
  8794. private _engine;
  8795. private _scene;
  8796. /**
  8797. * Attach the input controls to a specific dom element to get the input from.
  8798. * @param element Defines the element the controls should be listened from
  8799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8800. */
  8801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8802. /**
  8803. * Detach the current controls from the specified dom element.
  8804. * @param element Defines the element to stop listening the inputs from
  8805. */
  8806. detachControl(element: Nullable<HTMLElement>): void;
  8807. /**
  8808. * Update the current camera state depending on the inputs that have been used this frame.
  8809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8810. */
  8811. checkInputs(): void;
  8812. /**
  8813. * Gets the class name of the current intput.
  8814. * @returns the class name
  8815. */
  8816. getClassName(): string;
  8817. /** @hidden */
  8818. _onLostFocus(): void;
  8819. /**
  8820. * Get the friendly name associated with the input class.
  8821. * @returns the input friendly name
  8822. */
  8823. getSimpleName(): string;
  8824. }
  8825. }
  8826. declare module "babylonjs/Lights/shadowLight" {
  8827. import { Camera } from "babylonjs/Cameras/camera";
  8828. import { Scene } from "babylonjs/scene";
  8829. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8831. import { Light } from "babylonjs/Lights/light";
  8832. /**
  8833. * Interface describing all the common properties and methods a shadow light needs to implement.
  8834. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8835. * as well as binding the different shadow properties to the effects.
  8836. */
  8837. export interface IShadowLight extends Light {
  8838. /**
  8839. * The light id in the scene (used in scene.findLighById for instance)
  8840. */
  8841. id: string;
  8842. /**
  8843. * The position the shdow will be casted from.
  8844. */
  8845. position: Vector3;
  8846. /**
  8847. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8848. */
  8849. direction: Vector3;
  8850. /**
  8851. * The transformed position. Position of the light in world space taking parenting in account.
  8852. */
  8853. transformedPosition: Vector3;
  8854. /**
  8855. * The transformed direction. Direction of the light in world space taking parenting in account.
  8856. */
  8857. transformedDirection: Vector3;
  8858. /**
  8859. * The friendly name of the light in the scene.
  8860. */
  8861. name: string;
  8862. /**
  8863. * Defines the shadow projection clipping minimum z value.
  8864. */
  8865. shadowMinZ: number;
  8866. /**
  8867. * Defines the shadow projection clipping maximum z value.
  8868. */
  8869. shadowMaxZ: number;
  8870. /**
  8871. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8872. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8873. */
  8874. computeTransformedInformation(): boolean;
  8875. /**
  8876. * Gets the scene the light belongs to.
  8877. * @returns The scene
  8878. */
  8879. getScene(): Scene;
  8880. /**
  8881. * Callback defining a custom Projection Matrix Builder.
  8882. * This can be used to override the default projection matrix computation.
  8883. */
  8884. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8885. /**
  8886. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8887. * @param matrix The materix to updated with the projection information
  8888. * @param viewMatrix The transform matrix of the light
  8889. * @param renderList The list of mesh to render in the map
  8890. * @returns The current light
  8891. */
  8892. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8893. /**
  8894. * Gets the current depth scale used in ESM.
  8895. * @returns The scale
  8896. */
  8897. getDepthScale(): number;
  8898. /**
  8899. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8900. * @returns true if a cube texture needs to be use
  8901. */
  8902. needCube(): boolean;
  8903. /**
  8904. * Detects if the projection matrix requires to be recomputed this frame.
  8905. * @returns true if it requires to be recomputed otherwise, false.
  8906. */
  8907. needProjectionMatrixCompute(): boolean;
  8908. /**
  8909. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8910. */
  8911. forceProjectionMatrixCompute(): void;
  8912. /**
  8913. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8914. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8915. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8916. */
  8917. getShadowDirection(faceIndex?: number): Vector3;
  8918. /**
  8919. * Gets the minZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the min for
  8921. * @returns the depth min z
  8922. */
  8923. getDepthMinZ(activeCamera: Camera): number;
  8924. /**
  8925. * Gets the maxZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the max for
  8927. * @returns the depth max z
  8928. */
  8929. getDepthMaxZ(activeCamera: Camera): number;
  8930. }
  8931. /**
  8932. * Base implementation IShadowLight
  8933. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8934. */
  8935. export abstract class ShadowLight extends Light implements IShadowLight {
  8936. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8937. protected _position: Vector3;
  8938. protected _setPosition(value: Vector3): void;
  8939. /**
  8940. * Sets the position the shadow will be casted from. Also use as the light position for both
  8941. * point and spot lights.
  8942. */
  8943. /**
  8944. * Sets the position the shadow will be casted from. Also use as the light position for both
  8945. * point and spot lights.
  8946. */
  8947. position: Vector3;
  8948. protected _direction: Vector3;
  8949. protected _setDirection(value: Vector3): void;
  8950. /**
  8951. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8952. * Also use as the light direction on spot and directional lights.
  8953. */
  8954. /**
  8955. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8956. * Also use as the light direction on spot and directional lights.
  8957. */
  8958. direction: Vector3;
  8959. private _shadowMinZ;
  8960. /**
  8961. * Gets the shadow projection clipping minimum z value.
  8962. */
  8963. /**
  8964. * Sets the shadow projection clipping minimum z value.
  8965. */
  8966. shadowMinZ: number;
  8967. private _shadowMaxZ;
  8968. /**
  8969. * Sets the shadow projection clipping maximum z value.
  8970. */
  8971. /**
  8972. * Gets the shadow projection clipping maximum z value.
  8973. */
  8974. shadowMaxZ: number;
  8975. /**
  8976. * Callback defining a custom Projection Matrix Builder.
  8977. * This can be used to override the default projection matrix computation.
  8978. */
  8979. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8980. /**
  8981. * The transformed position. Position of the light in world space taking parenting in account.
  8982. */
  8983. transformedPosition: Vector3;
  8984. /**
  8985. * The transformed direction. Direction of the light in world space taking parenting in account.
  8986. */
  8987. transformedDirection: Vector3;
  8988. private _needProjectionMatrixCompute;
  8989. /**
  8990. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8991. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8992. */
  8993. computeTransformedInformation(): boolean;
  8994. /**
  8995. * Return the depth scale used for the shadow map.
  8996. * @returns the depth scale.
  8997. */
  8998. getDepthScale(): number;
  8999. /**
  9000. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9001. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9002. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9003. */
  9004. getShadowDirection(faceIndex?: number): Vector3;
  9005. /**
  9006. * Returns the ShadowLight absolute position in the World.
  9007. * @returns the position vector in world space
  9008. */
  9009. getAbsolutePosition(): Vector3;
  9010. /**
  9011. * Sets the ShadowLight direction toward the passed target.
  9012. * @param target The point to target in local space
  9013. * @returns the updated ShadowLight direction
  9014. */
  9015. setDirectionToTarget(target: Vector3): Vector3;
  9016. /**
  9017. * Returns the light rotation in euler definition.
  9018. * @returns the x y z rotation in local space.
  9019. */
  9020. getRotation(): Vector3;
  9021. /**
  9022. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9023. * @returns true if a cube texture needs to be use
  9024. */
  9025. needCube(): boolean;
  9026. /**
  9027. * Detects if the projection matrix requires to be recomputed this frame.
  9028. * @returns true if it requires to be recomputed otherwise, false.
  9029. */
  9030. needProjectionMatrixCompute(): boolean;
  9031. /**
  9032. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9033. */
  9034. forceProjectionMatrixCompute(): void;
  9035. /** @hidden */
  9036. _initCache(): void;
  9037. /** @hidden */
  9038. _isSynchronized(): boolean;
  9039. /**
  9040. * Computes the world matrix of the node
  9041. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9042. * @returns the world matrix
  9043. */
  9044. computeWorldMatrix(force?: boolean): Matrix;
  9045. /**
  9046. * Gets the minZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the min for
  9048. * @returns the depth min z
  9049. */
  9050. getDepthMinZ(activeCamera: Camera): number;
  9051. /**
  9052. * Gets the maxZ used for shadow according to both the scene and the light.
  9053. * @param activeCamera The camera we are returning the max for
  9054. * @returns the depth max z
  9055. */
  9056. getDepthMaxZ(activeCamera: Camera): number;
  9057. /**
  9058. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9059. * @param matrix The materix to updated with the projection information
  9060. * @param viewMatrix The transform matrix of the light
  9061. * @param renderList The list of mesh to render in the map
  9062. * @returns The current light
  9063. */
  9064. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9065. }
  9066. }
  9067. declare module "babylonjs/Materials/materialHelper" {
  9068. import { Nullable } from "babylonjs/types";
  9069. import { Scene } from "babylonjs/scene";
  9070. import { Engine } from "babylonjs/Engines/engine";
  9071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9072. import { Light } from "babylonjs/Lights/light";
  9073. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9074. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9076. /**
  9077. * "Static Class" containing the most commonly used helper while dealing with material for
  9078. * rendering purpose.
  9079. *
  9080. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9081. *
  9082. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9083. */
  9084. export class MaterialHelper {
  9085. /**
  9086. * Bind the current view position to an effect.
  9087. * @param effect The effect to be bound
  9088. * @param scene The scene the eyes position is used from
  9089. */
  9090. static BindEyePosition(effect: Effect, scene: Scene): void;
  9091. /**
  9092. * Helps preparing the defines values about the UVs in used in the effect.
  9093. * UVs are shared as much as we can accross channels in the shaders.
  9094. * @param texture The texture we are preparing the UVs for
  9095. * @param defines The defines to update
  9096. * @param key The channel key "diffuse", "specular"... used in the shader
  9097. */
  9098. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9099. /**
  9100. * Binds a texture matrix value to its corrsponding uniform
  9101. * @param texture The texture to bind the matrix for
  9102. * @param uniformBuffer The uniform buffer receivin the data
  9103. * @param key The channel key "diffuse", "specular"... used in the shader
  9104. */
  9105. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9106. /**
  9107. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9108. * @param mesh defines the current mesh
  9109. * @param scene defines the current scene
  9110. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9111. * @param pointsCloud defines if point cloud rendering has to be turned on
  9112. * @param fogEnabled defines if fog has to be turned on
  9113. * @param alphaTest defines if alpha testing has to be turned on
  9114. * @param defines defines the current list of defines
  9115. */
  9116. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9117. /**
  9118. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9119. * @param scene defines the current scene
  9120. * @param engine defines the current engine
  9121. * @param defines specifies the list of active defines
  9122. * @param useInstances defines if instances have to be turned on
  9123. * @param useClipPlane defines if clip plane have to be turned on
  9124. */
  9125. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9126. /**
  9127. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9128. * @param mesh The mesh containing the geometry data we will draw
  9129. * @param defines The defines to update
  9130. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9131. * @param useBones Precise whether bones should be used or not (override mesh info)
  9132. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9133. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9134. * @returns false if defines are considered not dirty and have not been checked
  9135. */
  9136. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9137. /**
  9138. * Prepares the defines related to the light information passed in parameter
  9139. * @param scene The scene we are intending to draw
  9140. * @param mesh The mesh the effect is compiling for
  9141. * @param defines The defines to update
  9142. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9143. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9144. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9145. * @returns true if normals will be required for the rest of the effect
  9146. */
  9147. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9148. /**
  9149. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9150. * that won t be acctive due to defines being turned off.
  9151. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9152. * @param samplersList The samplers list
  9153. * @param defines The defines helping in the list generation
  9154. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9155. */
  9156. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9157. /**
  9158. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9159. * @param defines The defines to update while falling back
  9160. * @param fallbacks The authorized effect fallbacks
  9161. * @param maxSimultaneousLights The maximum number of lights allowed
  9162. * @param rank the current rank of the Effect
  9163. * @returns The newly affected rank
  9164. */
  9165. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9166. /**
  9167. * Prepares the list of attributes required for morph targets according to the effect defines.
  9168. * @param attribs The current list of supported attribs
  9169. * @param mesh The mesh to prepare the morph targets attributes for
  9170. * @param defines The current Defines of the effect
  9171. */
  9172. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the list of attributes required for bones according to the effect defines.
  9175. * @param attribs The current list of supported attribs
  9176. * @param mesh The mesh to prepare the bones attributes for
  9177. * @param defines The current Defines of the effect
  9178. * @param fallbacks The current efffect fallback strategy
  9179. */
  9180. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9181. /**
  9182. * Prepares the list of attributes required for instances according to the effect defines.
  9183. * @param attribs The current list of supported attribs
  9184. * @param defines The current Defines of the effect
  9185. */
  9186. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9187. /**
  9188. * Binds the light shadow information to the effect for the given mesh.
  9189. * @param light The light containing the generator
  9190. * @param scene The scene the lights belongs to
  9191. * @param mesh The mesh we are binding the information to render
  9192. * @param lightIndex The light index in the effect used to render the mesh
  9193. * @param effect The effect we are binding the data to
  9194. */
  9195. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9196. /**
  9197. * Binds the light information to the effect.
  9198. * @param light The light containing the generator
  9199. * @param effect The effect we are binding the data to
  9200. * @param lightIndex The light index in the effect used to render
  9201. */
  9202. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9203. /**
  9204. * Binds the lights information from the scene to the effect for the given mesh.
  9205. * @param scene The scene the lights belongs to
  9206. * @param mesh The mesh we are binding the information to render
  9207. * @param effect The effect we are binding the data to
  9208. * @param defines The generated defines for the effect
  9209. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9210. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9211. */
  9212. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9213. private static _tempFogColor;
  9214. /**
  9215. * Binds the fog information from the scene to the effect for the given mesh.
  9216. * @param scene The scene the lights belongs to
  9217. * @param mesh The mesh we are binding the information to render
  9218. * @param effect The effect we are binding the data to
  9219. * @param linearSpace Defines if the fog effect is applied in linear space
  9220. */
  9221. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9222. /**
  9223. * Binds the bones information from the mesh to the effect.
  9224. * @param mesh The mesh we are binding the information to render
  9225. * @param effect The effect we are binding the data to
  9226. */
  9227. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9228. /**
  9229. * Binds the morph targets information from the mesh to the effect.
  9230. * @param abstractMesh The mesh we are binding the information to render
  9231. * @param effect The effect we are binding the data to
  9232. */
  9233. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9234. /**
  9235. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9236. * @param defines The generated defines used in the effect
  9237. * @param effect The effect we are binding the data to
  9238. * @param scene The scene we are willing to render with logarithmic scale for
  9239. */
  9240. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9241. /**
  9242. * Binds the clip plane information from the scene to the effect.
  9243. * @param scene The scene the clip plane information are extracted from
  9244. * @param effect The effect we are binding the data to
  9245. */
  9246. static BindClipPlane(effect: Effect, scene: Scene): void;
  9247. }
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9250. /** @hidden */
  9251. export var kernelBlurVaryingDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9257. /** @hidden */
  9258. export var kernelBlurFragment: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9264. /** @hidden */
  9265. export var kernelBlurFragment2: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9273. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9274. /** @hidden */
  9275. export var kernelBlurPixelShader: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9281. /** @hidden */
  9282. export var kernelBlurVertex: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9288. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9289. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9290. /** @hidden */
  9291. export var kernelBlurVertexShader: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9297. import { Vector2 } from "babylonjs/Maths/math";
  9298. import { Nullable } from "babylonjs/types";
  9299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9300. import { Camera } from "babylonjs/Cameras/camera";
  9301. import { Effect } from "babylonjs/Materials/effect";
  9302. import { Engine } from "babylonjs/Engines/engine";
  9303. import "babylonjs/Shaders/kernelBlur.fragment";
  9304. import "babylonjs/Shaders/kernelBlur.vertex";
  9305. /**
  9306. * The Blur Post Process which blurs an image based on a kernel and direction.
  9307. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9308. */
  9309. export class BlurPostProcess extends PostProcess {
  9310. /** The direction in which to blur the image. */
  9311. direction: Vector2;
  9312. private blockCompilation;
  9313. protected _kernel: number;
  9314. protected _idealKernel: number;
  9315. protected _packedFloat: boolean;
  9316. private _staticDefines;
  9317. /**
  9318. * Sets the length in pixels of the blur sample region
  9319. */
  9320. /**
  9321. * Gets the length in pixels of the blur sample region
  9322. */
  9323. kernel: number;
  9324. /**
  9325. * Sets wether or not the blur needs to unpack/repack floats
  9326. */
  9327. /**
  9328. * Gets wether or not the blur is unpacking/repacking floats
  9329. */
  9330. packedFloat: boolean;
  9331. /**
  9332. * Creates a new instance BlurPostProcess
  9333. * @param name The name of the effect.
  9334. * @param direction The direction in which to blur the image.
  9335. * @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.
  9336. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9337. * @param camera The camera to apply the render pass to.
  9338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9339. * @param engine The engine which the post process will be applied. (default: current engine)
  9340. * @param reusable If the post process can be reused on the same frame. (default: false)
  9341. * @param textureType Type of textures used when performing the post process. (default: 0)
  9342. * @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)
  9343. */
  9344. constructor(name: string,
  9345. /** The direction in which to blur the image. */
  9346. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9347. /**
  9348. * Updates the effect with the current post process compile time values and recompiles the shader.
  9349. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9350. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9351. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9352. * @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
  9353. * @param onCompiled Called when the shader has been compiled.
  9354. * @param onError Called if there is an error when compiling a shader.
  9355. */
  9356. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9357. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9358. /**
  9359. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9360. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9361. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9362. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9363. * The gaps between physical kernels are compensated for in the weighting of the samples
  9364. * @param idealKernel Ideal blur kernel.
  9365. * @return Nearest best kernel.
  9366. */
  9367. protected _nearestBestKernel(idealKernel: number): number;
  9368. /**
  9369. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9370. * @param x The point on the Gaussian distribution to sample.
  9371. * @return the value of the Gaussian function at x.
  9372. */
  9373. protected _gaussianWeight(x: number): number;
  9374. /**
  9375. * Generates a string that can be used as a floating point number in GLSL.
  9376. * @param x Value to print.
  9377. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9378. * @return GLSL float string.
  9379. */
  9380. protected _glslFloat(x: number, decimalFigures?: number): string;
  9381. }
  9382. }
  9383. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9384. /** @hidden */
  9385. export var shadowMapPixelShader: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9391. /** @hidden */
  9392. export var bonesDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9398. /** @hidden */
  9399. export var morphTargetsVertexGlobalDeclaration: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9405. /** @hidden */
  9406. export var morphTargetsVertexDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9412. /** @hidden */
  9413. export var instancesDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9419. /** @hidden */
  9420. export var helperFunctions: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9426. /** @hidden */
  9427. export var morphTargetsVertex: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9433. /** @hidden */
  9434. export var instancesVertex: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9440. /** @hidden */
  9441. export var bonesVertex: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9447. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9450. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9451. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9452. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9453. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9454. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9455. /** @hidden */
  9456. export var shadowMapVertexShader: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9462. /** @hidden */
  9463. export var depthBoxBlurPixelShader: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9469. import { Nullable } from "babylonjs/types";
  9470. import { Scene } from "babylonjs/scene";
  9471. import { Matrix } from "babylonjs/Maths/math";
  9472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9474. import { Mesh } from "babylonjs/Meshes/mesh";
  9475. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9476. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9477. import { Effect } from "babylonjs/Materials/effect";
  9478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9479. import "babylonjs/Shaders/shadowMap.fragment";
  9480. import "babylonjs/Shaders/shadowMap.vertex";
  9481. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9482. import { Observable } from "babylonjs/Misc/observable";
  9483. /**
  9484. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9485. */
  9486. export interface ICustomShaderOptions {
  9487. /**
  9488. * Gets or sets the custom shader name to use
  9489. */
  9490. shaderName: string;
  9491. /**
  9492. * The list of attribute names used in the shader
  9493. */
  9494. attributes?: string[];
  9495. /**
  9496. * The list of unifrom names used in the shader
  9497. */
  9498. uniforms?: string[];
  9499. /**
  9500. * The list of sampler names used in the shader
  9501. */
  9502. samplers?: string[];
  9503. /**
  9504. * The list of defines used in the shader
  9505. */
  9506. defines?: string[];
  9507. }
  9508. /**
  9509. * Interface to implement to create a shadow generator compatible with BJS.
  9510. */
  9511. export interface IShadowGenerator {
  9512. /**
  9513. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9514. * @returns The render target texture if present otherwise, null
  9515. */
  9516. getShadowMap(): Nullable<RenderTargetTexture>;
  9517. /**
  9518. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9519. * @returns The render target texture if the shadow map is present otherwise, null
  9520. */
  9521. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9522. /**
  9523. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9524. * @param subMesh The submesh we want to render in the shadow map
  9525. * @param useInstances Defines wether will draw in the map using instances
  9526. * @returns true if ready otherwise, false
  9527. */
  9528. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9529. /**
  9530. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9531. * @param defines Defines of the material we want to update
  9532. * @param lightIndex Index of the light in the enabled light list of the material
  9533. */
  9534. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9535. /**
  9536. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9537. * defined in the generator but impacting the effect).
  9538. * It implies the unifroms available on the materials are the standard BJS ones.
  9539. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9540. * @param effect The effect we are binfing the information for
  9541. */
  9542. bindShadowLight(lightIndex: string, effect: Effect): void;
  9543. /**
  9544. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9545. * (eq to shadow prjection matrix * light transform matrix)
  9546. * @returns The transform matrix used to create the shadow map
  9547. */
  9548. getTransformMatrix(): Matrix;
  9549. /**
  9550. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9551. * Cube and 2D textures for instance.
  9552. */
  9553. recreateShadowMap(): void;
  9554. /**
  9555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9556. * @param onCompiled Callback triggered at the and of the effects compilation
  9557. * @param options Sets of optional options forcing the compilation with different modes
  9558. */
  9559. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9560. useInstances: boolean;
  9561. }>): void;
  9562. /**
  9563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. * @returns A promise that resolves when the compilation completes
  9566. */
  9567. forceCompilationAsync(options?: Partial<{
  9568. useInstances: boolean;
  9569. }>): Promise<void>;
  9570. /**
  9571. * Serializes the shadow generator setup to a json object.
  9572. * @returns The serialized JSON object
  9573. */
  9574. serialize(): any;
  9575. /**
  9576. * Disposes the Shadow map and related Textures and effects.
  9577. */
  9578. dispose(): void;
  9579. }
  9580. /**
  9581. * Default implementation IShadowGenerator.
  9582. * This is the main object responsible of generating shadows in the framework.
  9583. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9584. */
  9585. export class ShadowGenerator implements IShadowGenerator {
  9586. /**
  9587. * Shadow generator mode None: no filtering applied.
  9588. */
  9589. static readonly FILTER_NONE: number;
  9590. /**
  9591. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9592. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9593. */
  9594. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9595. /**
  9596. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9597. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9598. */
  9599. static readonly FILTER_POISSONSAMPLING: number;
  9600. /**
  9601. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9602. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9603. */
  9604. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9605. /**
  9606. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9607. * edge artifacts on steep falloff.
  9608. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9609. */
  9610. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9611. /**
  9612. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9613. * edge artifacts on steep falloff.
  9614. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9615. */
  9616. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9617. /**
  9618. * Shadow generator mode PCF: Percentage Closer Filtering
  9619. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9620. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9621. */
  9622. static readonly FILTER_PCF: number;
  9623. /**
  9624. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9625. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9626. * Contact Hardening
  9627. */
  9628. static readonly FILTER_PCSS: number;
  9629. /**
  9630. * Reserved for PCF and PCSS
  9631. * Highest Quality.
  9632. *
  9633. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9634. *
  9635. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9636. */
  9637. static readonly QUALITY_HIGH: number;
  9638. /**
  9639. * Reserved for PCF and PCSS
  9640. * Good tradeoff for quality/perf cross devices
  9641. *
  9642. * Execute PCF on a 3*3 kernel.
  9643. *
  9644. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9645. */
  9646. static readonly QUALITY_MEDIUM: number;
  9647. /**
  9648. * Reserved for PCF and PCSS
  9649. * The lowest quality but the fastest.
  9650. *
  9651. * Execute PCF on a 1*1 kernel.
  9652. *
  9653. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9654. */
  9655. static readonly QUALITY_LOW: number;
  9656. /** Gets or sets the custom shader name to use */
  9657. customShaderOptions: ICustomShaderOptions;
  9658. /**
  9659. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9660. */
  9661. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9662. /**
  9663. * Observable triggered before a mesh is rendered in the shadow map.
  9664. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9665. */
  9666. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9667. private _bias;
  9668. /**
  9669. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9670. */
  9671. /**
  9672. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9673. */
  9674. bias: number;
  9675. private _normalBias;
  9676. /**
  9677. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9678. */
  9679. /**
  9680. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9681. */
  9682. normalBias: number;
  9683. private _blurBoxOffset;
  9684. /**
  9685. * Gets the blur box offset: offset applied during the blur pass.
  9686. * Only useful if useKernelBlur = false
  9687. */
  9688. /**
  9689. * Sets the blur box offset: offset applied during the blur pass.
  9690. * Only useful if useKernelBlur = false
  9691. */
  9692. blurBoxOffset: number;
  9693. private _blurScale;
  9694. /**
  9695. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9696. * 2 means half of the size.
  9697. */
  9698. /**
  9699. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9700. * 2 means half of the size.
  9701. */
  9702. blurScale: number;
  9703. private _blurKernel;
  9704. /**
  9705. * Gets the blur kernel: kernel size of the blur pass.
  9706. * Only useful if useKernelBlur = true
  9707. */
  9708. /**
  9709. * Sets the blur kernel: kernel size of the blur pass.
  9710. * Only useful if useKernelBlur = true
  9711. */
  9712. blurKernel: number;
  9713. private _useKernelBlur;
  9714. /**
  9715. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9716. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9717. */
  9718. /**
  9719. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9720. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9721. */
  9722. useKernelBlur: boolean;
  9723. private _depthScale;
  9724. /**
  9725. * Gets the depth scale used in ESM mode.
  9726. */
  9727. /**
  9728. * Sets the depth scale used in ESM mode.
  9729. * This can override the scale stored on the light.
  9730. */
  9731. depthScale: number;
  9732. private _filter;
  9733. /**
  9734. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9735. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9736. */
  9737. /**
  9738. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9739. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9740. */
  9741. filter: number;
  9742. /**
  9743. * Gets if the current filter is set to Poisson Sampling.
  9744. */
  9745. /**
  9746. * Sets the current filter to Poisson Sampling.
  9747. */
  9748. usePoissonSampling: boolean;
  9749. /**
  9750. * Gets if the current filter is set to ESM.
  9751. */
  9752. /**
  9753. * Sets the current filter is to ESM.
  9754. */
  9755. useExponentialShadowMap: boolean;
  9756. /**
  9757. * Gets if the current filter is set to filtered ESM.
  9758. */
  9759. /**
  9760. * Gets if the current filter is set to filtered ESM.
  9761. */
  9762. useBlurExponentialShadowMap: boolean;
  9763. /**
  9764. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9765. * exponential to prevent steep falloff artifacts).
  9766. */
  9767. /**
  9768. * Sets the current filter to "close ESM" (using the inverse of the
  9769. * exponential to prevent steep falloff artifacts).
  9770. */
  9771. useCloseExponentialShadowMap: boolean;
  9772. /**
  9773. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9774. * exponential to prevent steep falloff artifacts).
  9775. */
  9776. /**
  9777. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9778. * exponential to prevent steep falloff artifacts).
  9779. */
  9780. useBlurCloseExponentialShadowMap: boolean;
  9781. /**
  9782. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9783. */
  9784. /**
  9785. * Sets the current filter to "PCF" (percentage closer filtering).
  9786. */
  9787. usePercentageCloserFiltering: boolean;
  9788. private _filteringQuality;
  9789. /**
  9790. * Gets the PCF or PCSS Quality.
  9791. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9792. */
  9793. /**
  9794. * Sets the PCF or PCSS Quality.
  9795. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9796. */
  9797. filteringQuality: number;
  9798. /**
  9799. * Gets if the current filter is set to "PCSS" (contact hardening).
  9800. */
  9801. /**
  9802. * Sets the current filter to "PCSS" (contact hardening).
  9803. */
  9804. useContactHardeningShadow: boolean;
  9805. private _contactHardeningLightSizeUVRatio;
  9806. /**
  9807. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9808. * Using a ratio helps keeping shape stability independently of the map size.
  9809. *
  9810. * It does not account for the light projection as it was having too much
  9811. * instability during the light setup or during light position changes.
  9812. *
  9813. * Only valid if useContactHardeningShadow is true.
  9814. */
  9815. /**
  9816. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9817. * Using a ratio helps keeping shape stability independently of the map size.
  9818. *
  9819. * It does not account for the light projection as it was having too much
  9820. * instability during the light setup or during light position changes.
  9821. *
  9822. * Only valid if useContactHardeningShadow is true.
  9823. */
  9824. contactHardeningLightSizeUVRatio: number;
  9825. private _darkness;
  9826. /**
  9827. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9828. * 0 means strongest and 1 would means no shadow.
  9829. * @returns the darkness.
  9830. */
  9831. getDarkness(): number;
  9832. /**
  9833. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9834. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9835. * @returns the shadow generator allowing fluent coding.
  9836. */
  9837. setDarkness(darkness: number): ShadowGenerator;
  9838. private _transparencyShadow;
  9839. /**
  9840. * Sets the ability to have transparent shadow (boolean).
  9841. * @param transparent True if transparent else False
  9842. * @returns the shadow generator allowing fluent coding
  9843. */
  9844. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9845. private _shadowMap;
  9846. private _shadowMap2;
  9847. /**
  9848. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9849. * @returns The render target texture if present otherwise, null
  9850. */
  9851. getShadowMap(): Nullable<RenderTargetTexture>;
  9852. /**
  9853. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9854. * @returns The render target texture if the shadow map is present otherwise, null
  9855. */
  9856. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9857. /**
  9858. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9859. * @param mesh Mesh to add
  9860. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9861. * @returns the Shadow Generator itself
  9862. */
  9863. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9864. /**
  9865. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9866. * @param mesh Mesh to remove
  9867. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9868. * @returns the Shadow Generator itself
  9869. */
  9870. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9871. /**
  9872. * Controls the extent to which the shadows fade out at the edge of the frustum
  9873. * Used only by directionals and spots
  9874. */
  9875. frustumEdgeFalloff: number;
  9876. private _light;
  9877. /**
  9878. * Returns the associated light object.
  9879. * @returns the light generating the shadow
  9880. */
  9881. getLight(): IShadowLight;
  9882. /**
  9883. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9884. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9885. * It might on the other hand introduce peter panning.
  9886. */
  9887. forceBackFacesOnly: boolean;
  9888. private _scene;
  9889. private _lightDirection;
  9890. private _effect;
  9891. private _viewMatrix;
  9892. private _projectionMatrix;
  9893. private _transformMatrix;
  9894. private _cachedPosition;
  9895. private _cachedDirection;
  9896. private _cachedDefines;
  9897. private _currentRenderID;
  9898. private _boxBlurPostprocess;
  9899. private _kernelBlurXPostprocess;
  9900. private _kernelBlurYPostprocess;
  9901. private _blurPostProcesses;
  9902. private _mapSize;
  9903. private _currentFaceIndex;
  9904. private _currentFaceIndexCache;
  9905. private _textureType;
  9906. private _defaultTextureMatrix;
  9907. /** @hidden */
  9908. static _SceneComponentInitialization: (scene: Scene) => void;
  9909. /**
  9910. * Creates a ShadowGenerator object.
  9911. * A ShadowGenerator is the required tool to use the shadows.
  9912. * Each light casting shadows needs to use its own ShadowGenerator.
  9913. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9914. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9915. * @param light The light object generating the shadows.
  9916. * @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.
  9917. */
  9918. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9919. private _initializeGenerator;
  9920. private _initializeShadowMap;
  9921. private _initializeBlurRTTAndPostProcesses;
  9922. private _renderForShadowMap;
  9923. private _renderSubMeshForShadowMap;
  9924. private _applyFilterValues;
  9925. /**
  9926. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9927. * @param onCompiled Callback triggered at the and of the effects compilation
  9928. * @param options Sets of optional options forcing the compilation with different modes
  9929. */
  9930. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9931. useInstances: boolean;
  9932. }>): void;
  9933. /**
  9934. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9935. * @param options Sets of optional options forcing the compilation with different modes
  9936. * @returns A promise that resolves when the compilation completes
  9937. */
  9938. forceCompilationAsync(options?: Partial<{
  9939. useInstances: boolean;
  9940. }>): Promise<void>;
  9941. /**
  9942. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9943. * @param subMesh The submesh we want to render in the shadow map
  9944. * @param useInstances Defines wether will draw in the map using instances
  9945. * @returns true if ready otherwise, false
  9946. */
  9947. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9948. /**
  9949. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9950. * @param defines Defines of the material we want to update
  9951. * @param lightIndex Index of the light in the enabled light list of the material
  9952. */
  9953. prepareDefines(defines: any, lightIndex: number): void;
  9954. /**
  9955. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9956. * defined in the generator but impacting the effect).
  9957. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9958. * @param effect The effect we are binfing the information for
  9959. */
  9960. bindShadowLight(lightIndex: string, effect: Effect): void;
  9961. /**
  9962. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9963. * (eq to shadow prjection matrix * light transform matrix)
  9964. * @returns The transform matrix used to create the shadow map
  9965. */
  9966. getTransformMatrix(): Matrix;
  9967. /**
  9968. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9969. * Cube and 2D textures for instance.
  9970. */
  9971. recreateShadowMap(): void;
  9972. private _disposeBlurPostProcesses;
  9973. private _disposeRTTandPostProcesses;
  9974. /**
  9975. * Disposes the ShadowGenerator.
  9976. * Returns nothing.
  9977. */
  9978. dispose(): void;
  9979. /**
  9980. * Serializes the shadow generator setup to a json object.
  9981. * @returns The serialized JSON object
  9982. */
  9983. serialize(): any;
  9984. /**
  9985. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9986. * @param parsedShadowGenerator The JSON object to parse
  9987. * @param scene The scene to create the shadow map for
  9988. * @returns The parsed shadow generator
  9989. */
  9990. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9991. }
  9992. }
  9993. declare module "babylonjs/Lights/light" {
  9994. import { Nullable } from "babylonjs/types";
  9995. import { Scene } from "babylonjs/scene";
  9996. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9997. import { Node } from "babylonjs/node";
  9998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9999. import { Effect } from "babylonjs/Materials/effect";
  10000. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10001. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10002. /**
  10003. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10004. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10005. * 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.
  10006. */
  10007. export abstract class Light extends Node {
  10008. /**
  10009. * Falloff Default: light is falling off following the material specification:
  10010. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10011. */
  10012. static readonly FALLOFF_DEFAULT: number;
  10013. /**
  10014. * Falloff Physical: light is falling off following the inverse squared distance law.
  10015. */
  10016. static readonly FALLOFF_PHYSICAL: number;
  10017. /**
  10018. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10019. * to enhance interoperability with other engines.
  10020. */
  10021. static readonly FALLOFF_GLTF: number;
  10022. /**
  10023. * Falloff Standard: light is falling off like in the standard material
  10024. * to enhance interoperability with other materials.
  10025. */
  10026. static readonly FALLOFF_STANDARD: number;
  10027. /**
  10028. * If every light affecting the material is in this lightmapMode,
  10029. * material.lightmapTexture adds or multiplies
  10030. * (depends on material.useLightmapAsShadowmap)
  10031. * after every other light calculations.
  10032. */
  10033. static readonly LIGHTMAP_DEFAULT: number;
  10034. /**
  10035. * material.lightmapTexture as only diffuse lighting from this light
  10036. * adds only specular lighting from this light
  10037. * adds dynamic shadows
  10038. */
  10039. static readonly LIGHTMAP_SPECULAR: number;
  10040. /**
  10041. * material.lightmapTexture as only lighting
  10042. * no light calculation from this light
  10043. * only adds dynamic shadows from this light
  10044. */
  10045. static readonly LIGHTMAP_SHADOWSONLY: number;
  10046. /**
  10047. * Each light type uses the default quantity according to its type:
  10048. * point/spot lights use luminous intensity
  10049. * directional lights use illuminance
  10050. */
  10051. static readonly INTENSITYMODE_AUTOMATIC: number;
  10052. /**
  10053. * lumen (lm)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10056. /**
  10057. * candela (lm/sr)
  10058. */
  10059. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10060. /**
  10061. * lux (lm/m^2)
  10062. */
  10063. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10064. /**
  10065. * nit (cd/m^2)
  10066. */
  10067. static readonly INTENSITYMODE_LUMINANCE: number;
  10068. /**
  10069. * Light type const id of the point light.
  10070. */
  10071. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10072. /**
  10073. * Light type const id of the directional light.
  10074. */
  10075. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10076. /**
  10077. * Light type const id of the spot light.
  10078. */
  10079. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10080. /**
  10081. * Light type const id of the hemispheric light.
  10082. */
  10083. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10084. /**
  10085. * Diffuse gives the basic color to an object.
  10086. */
  10087. diffuse: Color3;
  10088. /**
  10089. * Specular produces a highlight color on an object.
  10090. * Note: This is note affecting PBR materials.
  10091. */
  10092. specular: Color3;
  10093. /**
  10094. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10095. * falling off base on range or angle.
  10096. * This can be set to any values in Light.FALLOFF_x.
  10097. *
  10098. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10099. * other types of materials.
  10100. */
  10101. falloffType: number;
  10102. /**
  10103. * Strength of the light.
  10104. * Note: By default it is define in the framework own unit.
  10105. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10106. */
  10107. intensity: number;
  10108. private _range;
  10109. protected _inverseSquaredRange: number;
  10110. /**
  10111. * Defines how far from the source the light is impacting in scene units.
  10112. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10113. */
  10114. /**
  10115. * Defines how far from the source the light is impacting in scene units.
  10116. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10117. */
  10118. range: number;
  10119. /**
  10120. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10121. * of light.
  10122. */
  10123. private _photometricScale;
  10124. private _intensityMode;
  10125. /**
  10126. * Gets the photometric scale used to interpret the intensity.
  10127. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10128. */
  10129. /**
  10130. * Sets the photometric scale used to interpret the intensity.
  10131. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10132. */
  10133. intensityMode: number;
  10134. private _radius;
  10135. /**
  10136. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10137. */
  10138. /**
  10139. * sets the light radius used by PBR Materials to simulate soft area lights.
  10140. */
  10141. radius: number;
  10142. private _renderPriority;
  10143. /**
  10144. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10145. * exceeding the number allowed of the materials.
  10146. */
  10147. renderPriority: number;
  10148. private _shadowEnabled;
  10149. /**
  10150. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10151. * the current shadow generator.
  10152. */
  10153. /**
  10154. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10155. * the current shadow generator.
  10156. */
  10157. shadowEnabled: boolean;
  10158. private _includedOnlyMeshes;
  10159. /**
  10160. * Gets the only meshes impacted by this light.
  10161. */
  10162. /**
  10163. * Sets the only meshes impacted by this light.
  10164. */
  10165. includedOnlyMeshes: AbstractMesh[];
  10166. private _excludedMeshes;
  10167. /**
  10168. * Gets the meshes not impacted by this light.
  10169. */
  10170. /**
  10171. * Sets the meshes not impacted by this light.
  10172. */
  10173. excludedMeshes: AbstractMesh[];
  10174. private _excludeWithLayerMask;
  10175. /**
  10176. * Gets the layer id use to find what meshes are not impacted by the light.
  10177. * Inactive if 0
  10178. */
  10179. /**
  10180. * Sets the layer id use to find what meshes are not impacted by the light.
  10181. * Inactive if 0
  10182. */
  10183. excludeWithLayerMask: number;
  10184. private _includeOnlyWithLayerMask;
  10185. /**
  10186. * Gets the layer id use to find what meshes are impacted by the light.
  10187. * Inactive if 0
  10188. */
  10189. /**
  10190. * Sets the layer id use to find what meshes are impacted by the light.
  10191. * Inactive if 0
  10192. */
  10193. includeOnlyWithLayerMask: number;
  10194. private _lightmapMode;
  10195. /**
  10196. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10197. */
  10198. /**
  10199. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10200. */
  10201. lightmapMode: number;
  10202. /**
  10203. * Shadow generator associted to the light.
  10204. * @hidden Internal use only.
  10205. */
  10206. _shadowGenerator: Nullable<IShadowGenerator>;
  10207. /**
  10208. * @hidden Internal use only.
  10209. */
  10210. _excludedMeshesIds: string[];
  10211. /**
  10212. * @hidden Internal use only.
  10213. */
  10214. _includedOnlyMeshesIds: string[];
  10215. /**
  10216. * The current light unifom buffer.
  10217. * @hidden Internal use only.
  10218. */
  10219. _uniformBuffer: UniformBuffer;
  10220. /**
  10221. * Creates a Light object in the scene.
  10222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10223. * @param name The firendly name of the light
  10224. * @param scene The scene the light belongs too
  10225. */
  10226. constructor(name: string, scene: Scene);
  10227. protected abstract _buildUniformLayout(): void;
  10228. /**
  10229. * Sets the passed Effect "effect" with the Light information.
  10230. * @param effect The effect to update
  10231. * @param lightIndex The index of the light in the effect to update
  10232. * @returns The light
  10233. */
  10234. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10235. /**
  10236. * Returns the string "Light".
  10237. * @returns the class name
  10238. */
  10239. getClassName(): string;
  10240. /** @hidden */
  10241. readonly _isLight: boolean;
  10242. /**
  10243. * Converts the light information to a readable string for debug purpose.
  10244. * @param fullDetails Supports for multiple levels of logging within scene loading
  10245. * @returns the human readable light info
  10246. */
  10247. toString(fullDetails?: boolean): string;
  10248. /** @hidden */
  10249. protected _syncParentEnabledState(): void;
  10250. /**
  10251. * Set the enabled state of this node.
  10252. * @param value - the new enabled state
  10253. */
  10254. setEnabled(value: boolean): void;
  10255. /**
  10256. * Returns the Light associated shadow generator if any.
  10257. * @return the associated shadow generator.
  10258. */
  10259. getShadowGenerator(): Nullable<IShadowGenerator>;
  10260. /**
  10261. * Returns a Vector3, the absolute light position in the World.
  10262. * @returns the world space position of the light
  10263. */
  10264. getAbsolutePosition(): Vector3;
  10265. /**
  10266. * Specifies if the light will affect the passed mesh.
  10267. * @param mesh The mesh to test against the light
  10268. * @return true the mesh is affected otherwise, false.
  10269. */
  10270. canAffectMesh(mesh: AbstractMesh): boolean;
  10271. /**
  10272. * Sort function to order lights for rendering.
  10273. * @param a First Light object to compare to second.
  10274. * @param b Second Light object to compare first.
  10275. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10276. */
  10277. static CompareLightsPriority(a: Light, b: Light): number;
  10278. /**
  10279. * Releases resources associated with this node.
  10280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10282. */
  10283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10284. /**
  10285. * Returns the light type ID (integer).
  10286. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10287. */
  10288. getTypeID(): number;
  10289. /**
  10290. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10291. * @returns the scaled intensity in intensity mode unit
  10292. */
  10293. getScaledIntensity(): number;
  10294. /**
  10295. * Returns a new Light object, named "name", from the current one.
  10296. * @param name The name of the cloned light
  10297. * @returns the new created light
  10298. */
  10299. clone(name: string): Nullable<Light>;
  10300. /**
  10301. * Serializes the current light into a Serialization object.
  10302. * @returns the serialized object.
  10303. */
  10304. serialize(): any;
  10305. /**
  10306. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10307. * This new light is named "name" and added to the passed scene.
  10308. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10309. * @param name The friendly name of the light
  10310. * @param scene The scene the new light will belong to
  10311. * @returns the constructor function
  10312. */
  10313. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10314. /**
  10315. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10316. * @param parsedLight The JSON representation of the light
  10317. * @param scene The scene to create the parsed light in
  10318. * @returns the created light after parsing
  10319. */
  10320. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10321. private _hookArrayForExcluded;
  10322. private _hookArrayForIncludedOnly;
  10323. private _resyncMeshes;
  10324. /**
  10325. * Forces the meshes to update their light related information in their rendering used effects
  10326. * @hidden Internal Use Only
  10327. */
  10328. _markMeshesAsLightDirty(): void;
  10329. /**
  10330. * Recomputes the cached photometric scale if needed.
  10331. */
  10332. private _computePhotometricScale;
  10333. /**
  10334. * Returns the Photometric Scale according to the light type and intensity mode.
  10335. */
  10336. private _getPhotometricScale;
  10337. /**
  10338. * Reorder the light in the scene according to their defined priority.
  10339. * @hidden Internal Use Only
  10340. */
  10341. _reorderLightsInScene(): void;
  10342. /**
  10343. * Prepares the list of defines specific to the light type.
  10344. * @param defines the list of defines
  10345. * @param lightIndex defines the index of the light for the effect
  10346. */
  10347. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10348. }
  10349. }
  10350. declare module "babylonjs/Actions/action" {
  10351. import { Observable } from "babylonjs/Misc/observable";
  10352. import { Condition } from "babylonjs/Actions/condition";
  10353. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10354. import { ActionManager } from "babylonjs/Actions/actionManager";
  10355. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10356. /**
  10357. * Interface used to define Action
  10358. */
  10359. export interface IAction {
  10360. /**
  10361. * Trigger for the action
  10362. */
  10363. trigger: number;
  10364. /** Options of the trigger */
  10365. triggerOptions: any;
  10366. /**
  10367. * Gets the trigger parameters
  10368. * @returns the trigger parameters
  10369. */
  10370. getTriggerParameter(): any;
  10371. /**
  10372. * Internal only - executes current action event
  10373. * @hidden
  10374. */
  10375. _executeCurrent(evt?: ActionEvent): void;
  10376. /**
  10377. * Serialize placeholder for child classes
  10378. * @param parent of child
  10379. * @returns the serialized object
  10380. */
  10381. serialize(parent: any): any;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. _prepare(): void;
  10387. /**
  10388. * Internal only - manager for action
  10389. * @hidden
  10390. */
  10391. _actionManager: AbstractActionManager;
  10392. }
  10393. /**
  10394. * The action to be carried out following a trigger
  10395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10396. */
  10397. export class Action implements IAction {
  10398. /** the trigger, with or without parameters, for the action */
  10399. triggerOptions: any;
  10400. /**
  10401. * Trigger for the action
  10402. */
  10403. trigger: number;
  10404. /**
  10405. * Internal only - manager for action
  10406. * @hidden
  10407. */
  10408. _actionManager: ActionManager;
  10409. private _nextActiveAction;
  10410. private _child;
  10411. private _condition?;
  10412. private _triggerParameter;
  10413. /**
  10414. * An event triggered prior to action being executed.
  10415. */
  10416. onBeforeExecuteObservable: Observable<Action>;
  10417. /**
  10418. * Creates a new Action
  10419. * @param triggerOptions the trigger, with or without parameters, for the action
  10420. * @param condition an optional determinant of action
  10421. */
  10422. constructor(
  10423. /** the trigger, with or without parameters, for the action */
  10424. triggerOptions: any, condition?: Condition);
  10425. /**
  10426. * Internal only
  10427. * @hidden
  10428. */
  10429. _prepare(): void;
  10430. /**
  10431. * Gets the trigger parameters
  10432. * @returns the trigger parameters
  10433. */
  10434. getTriggerParameter(): any;
  10435. /**
  10436. * Internal only - executes current action event
  10437. * @hidden
  10438. */
  10439. _executeCurrent(evt?: ActionEvent): void;
  10440. /**
  10441. * Execute placeholder for child classes
  10442. * @param evt optional action event
  10443. */
  10444. execute(evt?: ActionEvent): void;
  10445. /**
  10446. * Skips to next active action
  10447. */
  10448. skipToNextActiveAction(): void;
  10449. /**
  10450. * Adds action to chain of actions, may be a DoNothingAction
  10451. * @param action defines the next action to execute
  10452. * @returns The action passed in
  10453. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10454. */
  10455. then(action: Action): Action;
  10456. /**
  10457. * Internal only
  10458. * @hidden
  10459. */
  10460. _getProperty(propertyPath: string): string;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. _getEffectiveTarget(target: any, propertyPath: string): any;
  10466. /**
  10467. * Serialize placeholder for child classes
  10468. * @param parent of child
  10469. * @returns the serialized object
  10470. */
  10471. serialize(parent: any): any;
  10472. /**
  10473. * Internal only called by serialize
  10474. * @hidden
  10475. */
  10476. protected _serialize(serializedAction: any, parent?: any): any;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. static _SerializeValueAsString: (value: any) => string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10487. name: string;
  10488. targetType: string;
  10489. value: string;
  10490. };
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/condition" {
  10494. import { ActionManager } from "babylonjs/Actions/actionManager";
  10495. /**
  10496. * A Condition applied to an Action
  10497. */
  10498. export class Condition {
  10499. /**
  10500. * Internal only - manager for action
  10501. * @hidden
  10502. */
  10503. _actionManager: ActionManager;
  10504. /**
  10505. * Internal only
  10506. * @hidden
  10507. */
  10508. _evaluationId: number;
  10509. /**
  10510. * Internal only
  10511. * @hidden
  10512. */
  10513. _currentResult: boolean;
  10514. /**
  10515. * Creates a new Condition
  10516. * @param actionManager the manager of the action the condition is applied to
  10517. */
  10518. constructor(actionManager: ActionManager);
  10519. /**
  10520. * Check if the current condition is valid
  10521. * @returns a boolean
  10522. */
  10523. isValid(): boolean;
  10524. /**
  10525. * Internal only
  10526. * @hidden
  10527. */
  10528. _getProperty(propertyPath: string): string;
  10529. /**
  10530. * Internal only
  10531. * @hidden
  10532. */
  10533. _getEffectiveTarget(target: any, propertyPath: string): any;
  10534. /**
  10535. * Serialize placeholder for child classes
  10536. * @returns the serialized object
  10537. */
  10538. serialize(): any;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. protected _serialize(serializedCondition: any): any;
  10544. }
  10545. /**
  10546. * Defines specific conditional operators as extensions of Condition
  10547. */
  10548. export class ValueCondition extends Condition {
  10549. /** path to specify the property of the target the conditional operator uses */
  10550. propertyPath: string;
  10551. /** the value compared by the conditional operator against the current value of the property */
  10552. value: any;
  10553. /** the conditional operator, default ValueCondition.IsEqual */
  10554. operator: number;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. private static _IsEqual;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. private static _IsDifferent;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. private static _IsGreater;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. private static _IsLesser;
  10575. /**
  10576. * returns the number for IsEqual
  10577. */
  10578. static readonly IsEqual: number;
  10579. /**
  10580. * Returns the number for IsDifferent
  10581. */
  10582. static readonly IsDifferent: number;
  10583. /**
  10584. * Returns the number for IsGreater
  10585. */
  10586. static readonly IsGreater: number;
  10587. /**
  10588. * Returns the number for IsLesser
  10589. */
  10590. static readonly IsLesser: number;
  10591. /**
  10592. * Internal only The action manager for the condition
  10593. * @hidden
  10594. */
  10595. _actionManager: ActionManager;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. private _target;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. private _effectiveTarget;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. private _property;
  10611. /**
  10612. * Creates a new ValueCondition
  10613. * @param actionManager manager for the action the condition applies to
  10614. * @param target for the action
  10615. * @param propertyPath path to specify the property of the target the conditional operator uses
  10616. * @param value the value compared by the conditional operator against the current value of the property
  10617. * @param operator the conditional operator, default ValueCondition.IsEqual
  10618. */
  10619. constructor(actionManager: ActionManager, target: any,
  10620. /** path to specify the property of the target the conditional operator uses */
  10621. propertyPath: string,
  10622. /** the value compared by the conditional operator against the current value of the property */
  10623. value: any,
  10624. /** the conditional operator, default ValueCondition.IsEqual */
  10625. operator?: number);
  10626. /**
  10627. * Compares the given value with the property value for the specified conditional operator
  10628. * @returns the result of the comparison
  10629. */
  10630. isValid(): boolean;
  10631. /**
  10632. * Serialize the ValueCondition into a JSON compatible object
  10633. * @returns serialization object
  10634. */
  10635. serialize(): any;
  10636. /**
  10637. * Gets the name of the conditional operator for the ValueCondition
  10638. * @param operator the conditional operator
  10639. * @returns the name
  10640. */
  10641. static GetOperatorName(operator: number): string;
  10642. }
  10643. /**
  10644. * Defines a predicate condition as an extension of Condition
  10645. */
  10646. export class PredicateCondition extends Condition {
  10647. /** defines the predicate function used to validate the condition */
  10648. predicate: () => boolean;
  10649. /**
  10650. * Internal only - manager for action
  10651. * @hidden
  10652. */
  10653. _actionManager: ActionManager;
  10654. /**
  10655. * Creates a new PredicateCondition
  10656. * @param actionManager manager for the action the condition applies to
  10657. * @param predicate defines the predicate function used to validate the condition
  10658. */
  10659. constructor(actionManager: ActionManager,
  10660. /** defines the predicate function used to validate the condition */
  10661. predicate: () => boolean);
  10662. /**
  10663. * @returns the validity of the predicate condition
  10664. */
  10665. isValid(): boolean;
  10666. }
  10667. /**
  10668. * Defines a state condition as an extension of Condition
  10669. */
  10670. export class StateCondition extends Condition {
  10671. /** Value to compare with target state */
  10672. value: string;
  10673. /**
  10674. * Internal only - manager for action
  10675. * @hidden
  10676. */
  10677. _actionManager: ActionManager;
  10678. /**
  10679. * Internal only
  10680. * @hidden
  10681. */
  10682. private _target;
  10683. /**
  10684. * Creates a new StateCondition
  10685. * @param actionManager manager for the action the condition applies to
  10686. * @param target of the condition
  10687. * @param value to compare with target state
  10688. */
  10689. constructor(actionManager: ActionManager, target: any,
  10690. /** Value to compare with target state */
  10691. value: string);
  10692. /**
  10693. * Gets a boolean indicating if the current condition is met
  10694. * @returns the validity of the state
  10695. */
  10696. isValid(): boolean;
  10697. /**
  10698. * Serialize the StateCondition into a JSON compatible object
  10699. * @returns serialization object
  10700. */
  10701. serialize(): any;
  10702. }
  10703. }
  10704. declare module "babylonjs/Actions/directActions" {
  10705. import { Action } from "babylonjs/Actions/action";
  10706. import { Condition } from "babylonjs/Actions/condition";
  10707. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10708. /**
  10709. * This defines an action responsible to toggle a boolean once triggered.
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10711. */
  10712. export class SwitchBooleanAction extends Action {
  10713. /**
  10714. * The path to the boolean property in the target object
  10715. */
  10716. propertyPath: string;
  10717. private _target;
  10718. private _effectiveTarget;
  10719. private _property;
  10720. /**
  10721. * Instantiate the action
  10722. * @param triggerOptions defines the trigger options
  10723. * @param target defines the object containing the boolean
  10724. * @param propertyPath defines the path to the boolean property in the target object
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action toggle the boolean value.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. /**
  10742. * This defines an action responsible to set a the state field of the target
  10743. * to a desired value once triggered.
  10744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10745. */
  10746. export class SetStateAction extends Action {
  10747. /**
  10748. * The value to store in the state field.
  10749. */
  10750. value: string;
  10751. private _target;
  10752. /**
  10753. * Instantiate the action
  10754. * @param triggerOptions defines the trigger options
  10755. * @param target defines the object containing the state property
  10756. * @param value defines the value to store in the state field
  10757. * @param condition defines the trigger related conditions
  10758. */
  10759. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10760. /**
  10761. * Execute the action and store the value on the target state property.
  10762. */
  10763. execute(): void;
  10764. /**
  10765. * Serializes the actions and its related information.
  10766. * @param parent defines the object to serialize in
  10767. * @returns the serialized object
  10768. */
  10769. serialize(parent: any): any;
  10770. }
  10771. /**
  10772. * This defines an action responsible to set a property of the target
  10773. * to a desired value once triggered.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class SetValueAction extends Action {
  10777. /**
  10778. * The path of the property to set in the target.
  10779. */
  10780. propertyPath: string;
  10781. /**
  10782. * The value to set in the property
  10783. */
  10784. value: any;
  10785. private _target;
  10786. private _effectiveTarget;
  10787. private _property;
  10788. /**
  10789. * Instantiate the action
  10790. * @param triggerOptions defines the trigger options
  10791. * @param target defines the object containing the property
  10792. * @param propertyPath defines the path of the property to set in the target
  10793. * @param value defines the value to set in the property
  10794. * @param condition defines the trigger related conditions
  10795. */
  10796. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10797. /** @hidden */
  10798. _prepare(): void;
  10799. /**
  10800. * Execute the action and set the targetted property to the desired value.
  10801. */
  10802. execute(): void;
  10803. /**
  10804. * Serializes the actions and its related information.
  10805. * @param parent defines the object to serialize in
  10806. * @returns the serialized object
  10807. */
  10808. serialize(parent: any): any;
  10809. }
  10810. /**
  10811. * This defines an action responsible to increment the target value
  10812. * to a desired value once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class IncrementValueAction extends Action {
  10816. /**
  10817. * The path of the property to increment in the target.
  10818. */
  10819. propertyPath: string;
  10820. /**
  10821. * The value we should increment the property by.
  10822. */
  10823. value: any;
  10824. private _target;
  10825. private _effectiveTarget;
  10826. private _property;
  10827. /**
  10828. * Instantiate the action
  10829. * @param triggerOptions defines the trigger options
  10830. * @param target defines the object containing the property
  10831. * @param propertyPath defines the path of the property to increment in the target
  10832. * @param value defines the value value we should increment the property by
  10833. * @param condition defines the trigger related conditions
  10834. */
  10835. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10836. /** @hidden */
  10837. _prepare(): void;
  10838. /**
  10839. * Execute the action and increment the target of the value amount.
  10840. */
  10841. execute(): void;
  10842. /**
  10843. * Serializes the actions and its related information.
  10844. * @param parent defines the object to serialize in
  10845. * @returns the serialized object
  10846. */
  10847. serialize(parent: any): any;
  10848. }
  10849. /**
  10850. * This defines an action responsible to start an animation once triggered.
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10852. */
  10853. export class PlayAnimationAction extends Action {
  10854. /**
  10855. * Where the animation should start (animation frame)
  10856. */
  10857. from: number;
  10858. /**
  10859. * Where the animation should stop (animation frame)
  10860. */
  10861. to: number;
  10862. /**
  10863. * Define if the animation should loop or stop after the first play.
  10864. */
  10865. loop?: boolean;
  10866. private _target;
  10867. /**
  10868. * Instantiate the action
  10869. * @param triggerOptions defines the trigger options
  10870. * @param target defines the target animation or animation name
  10871. * @param from defines from where the animation should start (animation frame)
  10872. * @param end defines where the animation should stop (animation frame)
  10873. * @param loop defines if the animation should loop or stop after the first play
  10874. * @param condition defines the trigger related conditions
  10875. */
  10876. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10877. /** @hidden */
  10878. _prepare(): void;
  10879. /**
  10880. * Execute the action and play the animation.
  10881. */
  10882. execute(): void;
  10883. /**
  10884. * Serializes the actions and its related information.
  10885. * @param parent defines the object to serialize in
  10886. * @returns the serialized object
  10887. */
  10888. serialize(parent: any): any;
  10889. }
  10890. /**
  10891. * This defines an action responsible to stop an animation once triggered.
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10893. */
  10894. export class StopAnimationAction extends Action {
  10895. private _target;
  10896. /**
  10897. * Instantiate the action
  10898. * @param triggerOptions defines the trigger options
  10899. * @param target defines the target animation or animation name
  10900. * @param condition defines the trigger related conditions
  10901. */
  10902. constructor(triggerOptions: any, target: any, condition?: Condition);
  10903. /** @hidden */
  10904. _prepare(): void;
  10905. /**
  10906. * Execute the action and stop the animation.
  10907. */
  10908. execute(): void;
  10909. /**
  10910. * Serializes the actions and its related information.
  10911. * @param parent defines the object to serialize in
  10912. * @returns the serialized object
  10913. */
  10914. serialize(parent: any): any;
  10915. }
  10916. /**
  10917. * This defines an action responsible that does nothing once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class DoNothingAction extends Action {
  10921. /**
  10922. * Instantiate the action
  10923. * @param triggerOptions defines the trigger options
  10924. * @param condition defines the trigger related conditions
  10925. */
  10926. constructor(triggerOptions?: any, condition?: Condition);
  10927. /**
  10928. * Execute the action and do nothing.
  10929. */
  10930. execute(): void;
  10931. /**
  10932. * Serializes the actions and its related information.
  10933. * @param parent defines the object to serialize in
  10934. * @returns the serialized object
  10935. */
  10936. serialize(parent: any): any;
  10937. }
  10938. /**
  10939. * This defines an action responsible to trigger several actions once triggered.
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10941. */
  10942. export class CombineAction extends Action {
  10943. /**
  10944. * The list of aggregated animations to run.
  10945. */
  10946. children: Action[];
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param children defines the list of aggregated animations to run
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and executes all the aggregated actions.
  10958. */
  10959. execute(evt: ActionEvent): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. /**
  10968. * This defines an action responsible to run code (external event) once triggered.
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10970. */
  10971. export class ExecuteCodeAction extends Action {
  10972. /**
  10973. * The callback function to run.
  10974. */
  10975. func: (evt: ActionEvent) => void;
  10976. /**
  10977. * Instantiate the action
  10978. * @param triggerOptions defines the trigger options
  10979. * @param func defines the callback function to run
  10980. * @param condition defines the trigger related conditions
  10981. */
  10982. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10983. /**
  10984. * Execute the action and run the attached code.
  10985. */
  10986. execute(evt: ActionEvent): void;
  10987. }
  10988. /**
  10989. * This defines an action responsible to set the parent property of the target once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class SetParentAction extends Action {
  10993. private _parent;
  10994. private _target;
  10995. /**
  10996. * Instantiate the action
  10997. * @param triggerOptions defines the trigger options
  10998. * @param target defines the target containing the parent property
  10999. * @param parent defines from where the animation should start (animation frame)
  11000. * @param condition defines the trigger related conditions
  11001. */
  11002. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11003. /** @hidden */
  11004. _prepare(): void;
  11005. /**
  11006. * Execute the action and set the parent property.
  11007. */
  11008. execute(): void;
  11009. /**
  11010. * Serializes the actions and its related information.
  11011. * @param parent defines the object to serialize in
  11012. * @returns the serialized object
  11013. */
  11014. serialize(parent: any): any;
  11015. }
  11016. }
  11017. declare module "babylonjs/Actions/actionManager" {
  11018. import { Nullable } from "babylonjs/types";
  11019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11020. import { Scene } from "babylonjs/scene";
  11021. import { IAction } from "babylonjs/Actions/action";
  11022. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11023. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11024. /**
  11025. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11026. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11028. */
  11029. export class ActionManager extends AbstractActionManager {
  11030. /**
  11031. * Nothing
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly NothingTrigger: number;
  11035. /**
  11036. * On pick
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnPickTrigger: number;
  11040. /**
  11041. * On left pick
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnLeftPickTrigger: number;
  11045. /**
  11046. * On right pick
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnRightPickTrigger: number;
  11050. /**
  11051. * On center pick
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnCenterPickTrigger: number;
  11055. /**
  11056. * On pick down
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickDownTrigger: number;
  11060. /**
  11061. * On double pick
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnDoublePickTrigger: number;
  11065. /**
  11066. * On pick up
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPickUpTrigger: number;
  11070. /**
  11071. * On pick out.
  11072. * This trigger will only be raised if you also declared a OnPickDown
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickOutTrigger: number;
  11076. /**
  11077. * On long press
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnLongPressTrigger: number;
  11081. /**
  11082. * On pointer over
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPointerOverTrigger: number;
  11086. /**
  11087. * On pointer out
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPointerOutTrigger: number;
  11091. /**
  11092. * On every frame
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnEveryFrameTrigger: number;
  11096. /**
  11097. * On intersection enter
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnIntersectionEnterTrigger: number;
  11101. /**
  11102. * On intersection exit
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnIntersectionExitTrigger: number;
  11106. /**
  11107. * On key down
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnKeyDownTrigger: number;
  11111. /**
  11112. * On key up
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnKeyUpTrigger: number;
  11116. private _scene;
  11117. /**
  11118. * Creates a new action manager
  11119. * @param scene defines the hosting scene
  11120. */
  11121. constructor(scene: Scene);
  11122. /**
  11123. * Releases all associated resources
  11124. */
  11125. dispose(): void;
  11126. /**
  11127. * Gets hosting scene
  11128. * @returns the hosting scene
  11129. */
  11130. getScene(): Scene;
  11131. /**
  11132. * Does this action manager handles actions of any of the given triggers
  11133. * @param triggers defines the triggers to be tested
  11134. * @return a boolean indicating whether one (or more) of the triggers is handled
  11135. */
  11136. hasSpecificTriggers(triggers: number[]): boolean;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11139. * speed.
  11140. * @param triggerA defines the trigger to be tested
  11141. * @param triggerB defines the trigger to be tested
  11142. * @return a boolean indicating whether one (or more) of the triggers is handled
  11143. */
  11144. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11145. /**
  11146. * Does this action manager handles actions of a given trigger
  11147. * @param trigger defines the trigger to be tested
  11148. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11149. * @return whether the trigger is handled
  11150. */
  11151. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11152. /**
  11153. * Does this action manager has pointer triggers
  11154. */
  11155. readonly hasPointerTriggers: boolean;
  11156. /**
  11157. * Does this action manager has pick triggers
  11158. */
  11159. readonly hasPickTriggers: boolean;
  11160. /**
  11161. * Registers an action to this action manager
  11162. * @param action defines the action to be registered
  11163. * @return the action amended (prepared) after registration
  11164. */
  11165. registerAction(action: IAction): Nullable<IAction>;
  11166. /**
  11167. * Unregisters an action to this action manager
  11168. * @param action defines the action to be unregistered
  11169. * @return a boolean indicating whether the action has been unregistered
  11170. */
  11171. unregisterAction(action: IAction): Boolean;
  11172. /**
  11173. * Process a specific trigger
  11174. * @param trigger defines the trigger to process
  11175. * @param evt defines the event details to be processed
  11176. */
  11177. processTrigger(trigger: number, evt?: IActionEvent): void;
  11178. /** @hidden */
  11179. _getEffectiveTarget(target: any, propertyPath: string): any;
  11180. /** @hidden */
  11181. _getProperty(propertyPath: string): string;
  11182. /**
  11183. * Serialize this manager to a JSON object
  11184. * @param name defines the property name to store this manager
  11185. * @returns a JSON representation of this manager
  11186. */
  11187. serialize(name: string): any;
  11188. /**
  11189. * Creates a new ActionManager from a JSON data
  11190. * @param parsedActions defines the JSON data to read from
  11191. * @param object defines the hosting mesh
  11192. * @param scene defines the hosting scene
  11193. */
  11194. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11195. /**
  11196. * Get a trigger name by index
  11197. * @param trigger defines the trigger index
  11198. * @returns a trigger name
  11199. */
  11200. static GetTriggerName(trigger: number): string;
  11201. }
  11202. }
  11203. declare module "babylonjs/Culling/ray" {
  11204. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11205. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11207. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11208. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11209. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11210. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11211. /**
  11212. * Class representing a ray with position and direction
  11213. */
  11214. export class Ray {
  11215. /** origin point */
  11216. origin: Vector3;
  11217. /** direction */
  11218. direction: Vector3;
  11219. /** length of the ray */
  11220. length: number;
  11221. private static readonly TmpVector3;
  11222. private _tmpRay;
  11223. /**
  11224. * Creates a new ray
  11225. * @param origin origin point
  11226. * @param direction direction
  11227. * @param length length of the ray
  11228. */
  11229. constructor(
  11230. /** origin point */
  11231. origin: Vector3,
  11232. /** direction */
  11233. direction: Vector3,
  11234. /** length of the ray */
  11235. length?: number);
  11236. /**
  11237. * Checks if the ray intersects a box
  11238. * @param minimum bound of the box
  11239. * @param maximum bound of the box
  11240. * @param intersectionTreshold extra extend to be added to the box in all direction
  11241. * @returns if the box was hit
  11242. */
  11243. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11244. /**
  11245. * Checks if the ray intersects a box
  11246. * @param box the bounding box to check
  11247. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11248. * @returns if the box was hit
  11249. */
  11250. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11251. /**
  11252. * If the ray hits a sphere
  11253. * @param sphere the bounding sphere to check
  11254. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11255. * @returns true if it hits the sphere
  11256. */
  11257. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11258. /**
  11259. * If the ray hits a triange
  11260. * @param vertex0 triangle vertex
  11261. * @param vertex1 triangle vertex
  11262. * @param vertex2 triangle vertex
  11263. * @returns intersection information if hit
  11264. */
  11265. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11266. /**
  11267. * Checks if ray intersects a plane
  11268. * @param plane the plane to check
  11269. * @returns the distance away it was hit
  11270. */
  11271. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11272. /**
  11273. * Checks if ray intersects a mesh
  11274. * @param mesh the mesh to check
  11275. * @param fastCheck if only the bounding box should checked
  11276. * @returns picking info of the intersecton
  11277. */
  11278. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11279. /**
  11280. * Checks if ray intersects a mesh
  11281. * @param meshes the meshes to check
  11282. * @param fastCheck if only the bounding box should checked
  11283. * @param results array to store result in
  11284. * @returns Array of picking infos
  11285. */
  11286. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11287. private _comparePickingInfo;
  11288. private static smallnum;
  11289. private static rayl;
  11290. /**
  11291. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11292. * @param sega the first point of the segment to test the intersection against
  11293. * @param segb the second point of the segment to test the intersection against
  11294. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11295. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11296. */
  11297. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11298. /**
  11299. * Update the ray from viewport position
  11300. * @param x position
  11301. * @param y y position
  11302. * @param viewportWidth viewport width
  11303. * @param viewportHeight viewport height
  11304. * @param world world matrix
  11305. * @param view view matrix
  11306. * @param projection projection matrix
  11307. * @returns this ray updated
  11308. */
  11309. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11310. /**
  11311. * Creates a ray with origin and direction of 0,0,0
  11312. * @returns the new ray
  11313. */
  11314. static Zero(): Ray;
  11315. /**
  11316. * Creates a new ray from screen space and viewport
  11317. * @param x position
  11318. * @param y y position
  11319. * @param viewportWidth viewport width
  11320. * @param viewportHeight viewport height
  11321. * @param world world matrix
  11322. * @param view view matrix
  11323. * @param projection projection matrix
  11324. * @returns new ray
  11325. */
  11326. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11327. /**
  11328. * 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
  11329. * transformed to the given world matrix.
  11330. * @param origin The origin point
  11331. * @param end The end point
  11332. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11333. * @returns the new ray
  11334. */
  11335. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11336. /**
  11337. * Transforms a ray by a matrix
  11338. * @param ray ray to transform
  11339. * @param matrix matrix to apply
  11340. * @returns the resulting new ray
  11341. */
  11342. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11343. /**
  11344. * Transforms a ray by a matrix
  11345. * @param ray ray to transform
  11346. * @param matrix matrix to apply
  11347. * @param result ray to store result in
  11348. */
  11349. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11350. /**
  11351. * Unproject a ray from screen space to object space
  11352. * @param sourceX defines the screen space x coordinate to use
  11353. * @param sourceY defines the screen space y coordinate to use
  11354. * @param viewportWidth defines the current width of the viewport
  11355. * @param viewportHeight defines the current height of the viewport
  11356. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11357. * @param view defines the view matrix to use
  11358. * @param projection defines the projection matrix to use
  11359. */
  11360. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11361. }
  11362. /**
  11363. * Type used to define predicate used to select faces when a mesh intersection is detected
  11364. */
  11365. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11366. module "babylonjs/scene" {
  11367. interface Scene {
  11368. /** @hidden */
  11369. _tempPickingRay: Nullable<Ray>;
  11370. /** @hidden */
  11371. _cachedRayForTransform: Ray;
  11372. /** @hidden */
  11373. _pickWithRayInverseMatrix: Matrix;
  11374. /** @hidden */
  11375. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11376. /** @hidden */
  11377. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11378. }
  11379. }
  11380. }
  11381. declare module "babylonjs/sceneComponent" {
  11382. import { Scene } from "babylonjs/scene";
  11383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11385. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11386. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11387. import { Nullable } from "babylonjs/types";
  11388. import { Camera } from "babylonjs/Cameras/camera";
  11389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11390. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11391. import { AbstractScene } from "babylonjs/abstractScene";
  11392. /**
  11393. * Groups all the scene component constants in one place to ease maintenance.
  11394. * @hidden
  11395. */
  11396. export class SceneComponentConstants {
  11397. static readonly NAME_EFFECTLAYER: string;
  11398. static readonly NAME_LAYER: string;
  11399. static readonly NAME_LENSFLARESYSTEM: string;
  11400. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11401. static readonly NAME_PARTICLESYSTEM: string;
  11402. static readonly NAME_GAMEPAD: string;
  11403. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11404. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11405. static readonly NAME_DEPTHRENDERER: string;
  11406. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11407. static readonly NAME_SPRITE: string;
  11408. static readonly NAME_OUTLINERENDERER: string;
  11409. static readonly NAME_PROCEDURALTEXTURE: string;
  11410. static readonly NAME_SHADOWGENERATOR: string;
  11411. static readonly NAME_OCTREE: string;
  11412. static readonly NAME_PHYSICSENGINE: string;
  11413. static readonly NAME_AUDIO: string;
  11414. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11415. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11417. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11418. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11419. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11420. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11421. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11422. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11423. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11424. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11425. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11426. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11427. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11428. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11429. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11430. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11431. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11432. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11433. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11434. static readonly STEP_AFTERRENDER_AUDIO: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11437. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11438. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11439. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11440. static readonly STEP_POINTERMOVE_SPRITE: number;
  11441. static readonly STEP_POINTERDOWN_SPRITE: number;
  11442. static readonly STEP_POINTERUP_SPRITE: number;
  11443. }
  11444. /**
  11445. * This represents a scene component.
  11446. *
  11447. * This is used to decouple the dependency the scene is having on the different workloads like
  11448. * layers, post processes...
  11449. */
  11450. export interface ISceneComponent {
  11451. /**
  11452. * The name of the component. Each component must have a unique name.
  11453. */
  11454. name: string;
  11455. /**
  11456. * The scene the component belongs to.
  11457. */
  11458. scene: Scene;
  11459. /**
  11460. * Register the component to one instance of a scene.
  11461. */
  11462. register(): void;
  11463. /**
  11464. * Rebuilds the elements related to this component in case of
  11465. * context lost for instance.
  11466. */
  11467. rebuild(): void;
  11468. /**
  11469. * Disposes the component and the associated ressources.
  11470. */
  11471. dispose(): void;
  11472. }
  11473. /**
  11474. * This represents a SERIALIZABLE scene component.
  11475. *
  11476. * This extends Scene Component to add Serialization methods on top.
  11477. */
  11478. export interface ISceneSerializableComponent extends ISceneComponent {
  11479. /**
  11480. * Adds all the element from the container to the scene
  11481. * @param container the container holding the elements
  11482. */
  11483. addFromContainer(container: AbstractScene): void;
  11484. /**
  11485. * Removes all the elements in the container from the scene
  11486. * @param container contains the elements to remove
  11487. */
  11488. removeFromContainer(container: AbstractScene): void;
  11489. /**
  11490. * Serializes the component data to the specified json object
  11491. * @param serializationObject The object to serialize to
  11492. */
  11493. serialize(serializationObject: any): void;
  11494. }
  11495. /**
  11496. * Strong typing of a Mesh related stage step action
  11497. */
  11498. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11499. /**
  11500. * Strong typing of a Evaluate Sub Mesh related stage step action
  11501. */
  11502. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11503. /**
  11504. * Strong typing of a Active Mesh related stage step action
  11505. */
  11506. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11507. /**
  11508. * Strong typing of a Camera related stage step action
  11509. */
  11510. export type CameraStageAction = (camera: Camera) => void;
  11511. /**
  11512. * Strong typing of a Render Target related stage step action
  11513. */
  11514. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11515. /**
  11516. * Strong typing of a RenderingGroup related stage step action
  11517. */
  11518. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11519. /**
  11520. * Strong typing of a Mesh Render related stage step action
  11521. */
  11522. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11523. /**
  11524. * Strong typing of a simple stage step action
  11525. */
  11526. export type SimpleStageAction = () => void;
  11527. /**
  11528. * Strong typing of a render target action.
  11529. */
  11530. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11531. /**
  11532. * Strong typing of a pointer move action.
  11533. */
  11534. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11535. /**
  11536. * Strong typing of a pointer up/down action.
  11537. */
  11538. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11539. /**
  11540. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11541. * @hidden
  11542. */
  11543. export class Stage<T extends Function> extends Array<{
  11544. index: number;
  11545. component: ISceneComponent;
  11546. action: T;
  11547. }> {
  11548. /**
  11549. * Hide ctor from the rest of the world.
  11550. * @param items The items to add.
  11551. */
  11552. private constructor();
  11553. /**
  11554. * Creates a new Stage.
  11555. * @returns A new instance of a Stage
  11556. */
  11557. static Create<T extends Function>(): Stage<T>;
  11558. /**
  11559. * Registers a step in an ordered way in the targeted stage.
  11560. * @param index Defines the position to register the step in
  11561. * @param component Defines the component attached to the step
  11562. * @param action Defines the action to launch during the step
  11563. */
  11564. registerStep(index: number, component: ISceneComponent, action: T): void;
  11565. /**
  11566. * Clears all the steps from the stage.
  11567. */
  11568. clear(): void;
  11569. }
  11570. }
  11571. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11572. import { Nullable } from "babylonjs/types";
  11573. import { Observable } from "babylonjs/Misc/observable";
  11574. import { Scene } from "babylonjs/scene";
  11575. import { Sprite } from "babylonjs/Sprites/sprite";
  11576. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11577. import { Ray } from "babylonjs/Culling/ray";
  11578. import { Camera } from "babylonjs/Cameras/camera";
  11579. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11580. import { ISceneComponent } from "babylonjs/sceneComponent";
  11581. module "babylonjs/scene" {
  11582. interface Scene {
  11583. /** @hidden */
  11584. _pointerOverSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _pickedDownSprite: Nullable<Sprite>;
  11587. /** @hidden */
  11588. _tempSpritePickingRay: Nullable<Ray>;
  11589. /**
  11590. * All of the sprite managers added to this scene
  11591. * @see http://doc.babylonjs.com/babylon101/sprites
  11592. */
  11593. spriteManagers: Array<ISpriteManager>;
  11594. /**
  11595. * An event triggered when sprites rendering is about to start
  11596. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11597. */
  11598. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11599. /**
  11600. * An event triggered when sprites rendering is done
  11601. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11602. */
  11603. onAfterSpritesRenderingObservable: Observable<Scene>;
  11604. /** @hidden */
  11605. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11606. /** Launch a ray to try to pick a sprite in the scene
  11607. * @param x position on screen
  11608. * @param y position on screen
  11609. * @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
  11610. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11611. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11612. * @returns a PickingInfo
  11613. */
  11614. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11615. /** Use the given ray to pick a sprite in the scene
  11616. * @param ray The ray (in world space) to use to pick meshes
  11617. * @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
  11618. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11619. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11620. * @returns a PickingInfo
  11621. */
  11622. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11623. /**
  11624. * Force the sprite under the pointer
  11625. * @param sprite defines the sprite to use
  11626. */
  11627. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11628. /**
  11629. * Gets the sprite under the pointer
  11630. * @returns a Sprite or null if no sprite is under the pointer
  11631. */
  11632. getPointerOverSprite(): Nullable<Sprite>;
  11633. }
  11634. }
  11635. /**
  11636. * Defines the sprite scene component responsible to manage sprites
  11637. * in a given scene.
  11638. */
  11639. export class SpriteSceneComponent implements ISceneComponent {
  11640. /**
  11641. * The component name helpfull to identify the component in the list of scene components.
  11642. */
  11643. readonly name: string;
  11644. /**
  11645. * The scene the component belongs to.
  11646. */
  11647. scene: Scene;
  11648. /** @hidden */
  11649. private _spritePredicate;
  11650. /**
  11651. * Creates a new instance of the component for the given scene
  11652. * @param scene Defines the scene to register the component in
  11653. */
  11654. constructor(scene: Scene);
  11655. /**
  11656. * Registers the component in a given scene
  11657. */
  11658. register(): void;
  11659. /**
  11660. * Rebuilds the elements related to this component in case of
  11661. * context lost for instance.
  11662. */
  11663. rebuild(): void;
  11664. /**
  11665. * Disposes the component and the associated ressources.
  11666. */
  11667. dispose(): void;
  11668. private _pickSpriteButKeepRay;
  11669. private _pointerMove;
  11670. private _pointerDown;
  11671. private _pointerUp;
  11672. }
  11673. }
  11674. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11675. /** @hidden */
  11676. export var fogFragmentDeclaration: {
  11677. name: string;
  11678. shader: string;
  11679. };
  11680. }
  11681. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11682. /** @hidden */
  11683. export var fogFragment: {
  11684. name: string;
  11685. shader: string;
  11686. };
  11687. }
  11688. declare module "babylonjs/Shaders/sprites.fragment" {
  11689. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11690. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11691. /** @hidden */
  11692. export var spritesPixelShader: {
  11693. name: string;
  11694. shader: string;
  11695. };
  11696. }
  11697. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11698. /** @hidden */
  11699. export var fogVertexDeclaration: {
  11700. name: string;
  11701. shader: string;
  11702. };
  11703. }
  11704. declare module "babylonjs/Shaders/sprites.vertex" {
  11705. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11706. /** @hidden */
  11707. export var spritesVertexShader: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Sprites/spriteManager" {
  11713. import { IDisposable, Scene } from "babylonjs/scene";
  11714. import { Nullable } from "babylonjs/types";
  11715. import { Observable } from "babylonjs/Misc/observable";
  11716. import { Sprite } from "babylonjs/Sprites/sprite";
  11717. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11718. import { Camera } from "babylonjs/Cameras/camera";
  11719. import { Texture } from "babylonjs/Materials/Textures/texture";
  11720. import "babylonjs/Shaders/sprites.fragment";
  11721. import "babylonjs/Shaders/sprites.vertex";
  11722. import { Ray } from "babylonjs/Culling/ray";
  11723. /**
  11724. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11725. */
  11726. export interface ISpriteManager extends IDisposable {
  11727. /**
  11728. * Restricts the camera to viewing objects with the same layerMask.
  11729. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11730. */
  11731. layerMask: number;
  11732. /**
  11733. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11734. */
  11735. isPickable: boolean;
  11736. /**
  11737. * Specifies the rendering group id for this mesh (0 by default)
  11738. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11739. */
  11740. renderingGroupId: number;
  11741. /**
  11742. * Defines the list of sprites managed by the manager.
  11743. */
  11744. sprites: Array<Sprite>;
  11745. /**
  11746. * Tests the intersection of a sprite with a specific ray.
  11747. * @param ray The ray we are sending to test the collision
  11748. * @param camera The camera space we are sending rays in
  11749. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11750. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11751. * @returns picking info or null.
  11752. */
  11753. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11754. /**
  11755. * Renders the list of sprites on screen.
  11756. */
  11757. render(): void;
  11758. }
  11759. /**
  11760. * Class used to manage multiple sprites on the same spritesheet
  11761. * @see http://doc.babylonjs.com/babylon101/sprites
  11762. */
  11763. export class SpriteManager implements ISpriteManager {
  11764. /** defines the manager's name */
  11765. name: string;
  11766. /** Gets the list of sprites */
  11767. sprites: Sprite[];
  11768. /** Gets or sets the rendering group id (0 by default) */
  11769. renderingGroupId: number;
  11770. /** Gets or sets camera layer mask */
  11771. layerMask: number;
  11772. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11773. fogEnabled: boolean;
  11774. /** Gets or sets a boolean indicating if the sprites are pickable */
  11775. isPickable: boolean;
  11776. /** Defines the default width of a cell in the spritesheet */
  11777. cellWidth: number;
  11778. /** Defines the default height of a cell in the spritesheet */
  11779. cellHeight: number;
  11780. /**
  11781. * An event triggered when the manager is disposed.
  11782. */
  11783. onDisposeObservable: Observable<SpriteManager>;
  11784. private _onDisposeObserver;
  11785. /**
  11786. * Callback called when the manager is disposed
  11787. */
  11788. onDispose: () => void;
  11789. private _capacity;
  11790. private _spriteTexture;
  11791. private _epsilon;
  11792. private _scene;
  11793. private _vertexData;
  11794. private _buffer;
  11795. private _vertexBuffers;
  11796. private _indexBuffer;
  11797. private _effectBase;
  11798. private _effectFog;
  11799. /**
  11800. * Gets or sets the spritesheet texture
  11801. */
  11802. texture: Texture;
  11803. /**
  11804. * Creates a new sprite manager
  11805. * @param name defines the manager's name
  11806. * @param imgUrl defines the sprite sheet url
  11807. * @param capacity defines the maximum allowed number of sprites
  11808. * @param cellSize defines the size of a sprite cell
  11809. * @param scene defines the hosting scene
  11810. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11811. * @param samplingMode defines the smapling mode to use with spritesheet
  11812. */
  11813. constructor(
  11814. /** defines the manager's name */
  11815. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11816. private _appendSpriteVertex;
  11817. /**
  11818. * Intersects the sprites with a ray
  11819. * @param ray defines the ray to intersect with
  11820. * @param camera defines the current active camera
  11821. * @param predicate defines a predicate used to select candidate sprites
  11822. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11823. * @returns null if no hit or a PickingInfo
  11824. */
  11825. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11826. /**
  11827. * Render all child sprites
  11828. */
  11829. render(): void;
  11830. /**
  11831. * Release associated resources
  11832. */
  11833. dispose(): void;
  11834. }
  11835. }
  11836. declare module "babylonjs/Sprites/sprite" {
  11837. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11838. import { Nullable } from "babylonjs/types";
  11839. import { ActionManager } from "babylonjs/Actions/actionManager";
  11840. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11841. /**
  11842. * Class used to represent a sprite
  11843. * @see http://doc.babylonjs.com/babylon101/sprites
  11844. */
  11845. export class Sprite {
  11846. /** defines the name */
  11847. name: string;
  11848. /** Gets or sets the current world position */
  11849. position: Vector3;
  11850. /** Gets or sets the main color */
  11851. color: Color4;
  11852. /** Gets or sets the width */
  11853. width: number;
  11854. /** Gets or sets the height */
  11855. height: number;
  11856. /** Gets or sets rotation angle */
  11857. angle: number;
  11858. /** Gets or sets the cell index in the sprite sheet */
  11859. cellIndex: number;
  11860. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11861. invertU: number;
  11862. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11863. invertV: number;
  11864. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11865. disposeWhenFinishedAnimating: boolean;
  11866. /** Gets the list of attached animations */
  11867. animations: Animation[];
  11868. /** Gets or sets a boolean indicating if the sprite can be picked */
  11869. isPickable: boolean;
  11870. /**
  11871. * Gets or sets the associated action manager
  11872. */
  11873. actionManager: Nullable<ActionManager>;
  11874. private _animationStarted;
  11875. private _loopAnimation;
  11876. private _fromIndex;
  11877. private _toIndex;
  11878. private _delay;
  11879. private _direction;
  11880. private _manager;
  11881. private _time;
  11882. private _onAnimationEnd;
  11883. /**
  11884. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11885. */
  11886. isVisible: boolean;
  11887. /**
  11888. * Gets or sets the sprite size
  11889. */
  11890. size: number;
  11891. /**
  11892. * Creates a new Sprite
  11893. * @param name defines the name
  11894. * @param manager defines the manager
  11895. */
  11896. constructor(
  11897. /** defines the name */
  11898. name: string, manager: ISpriteManager);
  11899. /**
  11900. * Starts an animation
  11901. * @param from defines the initial key
  11902. * @param to defines the end key
  11903. * @param loop defines if the animation must loop
  11904. * @param delay defines the start delay (in ms)
  11905. * @param onAnimationEnd defines a callback to call when animation ends
  11906. */
  11907. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11908. /** Stops current animation (if any) */
  11909. stopAnimation(): void;
  11910. /** @hidden */
  11911. _animate(deltaTime: number): void;
  11912. /** Release associated resources */
  11913. dispose(): void;
  11914. }
  11915. }
  11916. declare module "babylonjs/Collisions/pickingInfo" {
  11917. import { Nullable } from "babylonjs/types";
  11918. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11920. import { Sprite } from "babylonjs/Sprites/sprite";
  11921. import { Ray } from "babylonjs/Culling/ray";
  11922. /**
  11923. * Information about the result of picking within a scene
  11924. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11925. */
  11926. export class PickingInfo {
  11927. /** @hidden */
  11928. _pickingUnavailable: boolean;
  11929. /**
  11930. * If the pick collided with an object
  11931. */
  11932. hit: boolean;
  11933. /**
  11934. * Distance away where the pick collided
  11935. */
  11936. distance: number;
  11937. /**
  11938. * The location of pick collision
  11939. */
  11940. pickedPoint: Nullable<Vector3>;
  11941. /**
  11942. * The mesh corresponding the the pick collision
  11943. */
  11944. pickedMesh: Nullable<AbstractMesh>;
  11945. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11946. bu: number;
  11947. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11948. bv: number;
  11949. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11950. faceId: number;
  11951. /** Id of the the submesh that was picked */
  11952. subMeshId: number;
  11953. /** If a sprite was picked, this will be the sprite the pick collided with */
  11954. pickedSprite: Nullable<Sprite>;
  11955. /**
  11956. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11957. */
  11958. originMesh: Nullable<AbstractMesh>;
  11959. /**
  11960. * The ray that was used to perform the picking.
  11961. */
  11962. ray: Nullable<Ray>;
  11963. /**
  11964. * Gets the normal correspodning to the face the pick collided with
  11965. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11966. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11967. * @returns The normal correspodning to the face the pick collided with
  11968. */
  11969. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11970. /**
  11971. * Gets the texture coordinates of where the pick occured
  11972. * @returns the vector containing the coordnates of the texture
  11973. */
  11974. getTextureCoordinates(): Nullable<Vector2>;
  11975. }
  11976. }
  11977. declare module "babylonjs/Events/pointerEvents" {
  11978. import { Nullable } from "babylonjs/types";
  11979. import { Vector2 } from "babylonjs/Maths/math";
  11980. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11981. import { Ray } from "babylonjs/Culling/ray";
  11982. /**
  11983. * Gather the list of pointer event types as constants.
  11984. */
  11985. export class PointerEventTypes {
  11986. /**
  11987. * 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.
  11988. */
  11989. static readonly POINTERDOWN: number;
  11990. /**
  11991. * The pointerup event is fired when a pointer is no longer active.
  11992. */
  11993. static readonly POINTERUP: number;
  11994. /**
  11995. * The pointermove event is fired when a pointer changes coordinates.
  11996. */
  11997. static readonly POINTERMOVE: number;
  11998. /**
  11999. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12000. */
  12001. static readonly POINTERWHEEL: number;
  12002. /**
  12003. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12004. */
  12005. static readonly POINTERPICK: number;
  12006. /**
  12007. * The pointertap event is fired when a the object has been touched and released without drag.
  12008. */
  12009. static readonly POINTERTAP: number;
  12010. /**
  12011. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12012. */
  12013. static readonly POINTERDOUBLETAP: number;
  12014. }
  12015. /**
  12016. * Base class of pointer info types.
  12017. */
  12018. export class PointerInfoBase {
  12019. /**
  12020. * Defines the type of event (PointerEventTypes)
  12021. */
  12022. type: number;
  12023. /**
  12024. * Defines the related dom event
  12025. */
  12026. event: PointerEvent | MouseWheelEvent;
  12027. /**
  12028. * Instantiates the base class of pointers info.
  12029. * @param type Defines the type of event (PointerEventTypes)
  12030. * @param event Defines the related dom event
  12031. */
  12032. constructor(
  12033. /**
  12034. * Defines the type of event (PointerEventTypes)
  12035. */
  12036. type: number,
  12037. /**
  12038. * Defines the related dom event
  12039. */
  12040. event: PointerEvent | MouseWheelEvent);
  12041. }
  12042. /**
  12043. * This class is used to store pointer related info for the onPrePointerObservable event.
  12044. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12045. */
  12046. export class PointerInfoPre extends PointerInfoBase {
  12047. /**
  12048. * Ray from a pointer if availible (eg. 6dof controller)
  12049. */
  12050. ray: Nullable<Ray>;
  12051. /**
  12052. * Defines the local position of the pointer on the canvas.
  12053. */
  12054. localPosition: Vector2;
  12055. /**
  12056. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12057. */
  12058. skipOnPointerObservable: boolean;
  12059. /**
  12060. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12061. * @param type Defines the type of event (PointerEventTypes)
  12062. * @param event Defines the related dom event
  12063. * @param localX Defines the local x coordinates of the pointer when the event occured
  12064. * @param localY Defines the local y coordinates of the pointer when the event occured
  12065. */
  12066. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12067. }
  12068. /**
  12069. * This type contains all the data related to a pointer event in Babylon.js.
  12070. * 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.
  12071. */
  12072. export class PointerInfo extends PointerInfoBase {
  12073. /**
  12074. * Defines the picking info associated to the info (if any)\
  12075. */
  12076. pickInfo: Nullable<PickingInfo>;
  12077. /**
  12078. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12079. * @param type Defines the type of event (PointerEventTypes)
  12080. * @param event Defines the related dom event
  12081. * @param pickInfo Defines the picking info associated to the info (if any)\
  12082. */
  12083. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12084. /**
  12085. * Defines the picking info associated to the info (if any)\
  12086. */
  12087. pickInfo: Nullable<PickingInfo>);
  12088. }
  12089. /**
  12090. * Data relating to a touch event on the screen.
  12091. */
  12092. export interface PointerTouch {
  12093. /**
  12094. * X coordinate of touch.
  12095. */
  12096. x: number;
  12097. /**
  12098. * Y coordinate of touch.
  12099. */
  12100. y: number;
  12101. /**
  12102. * Id of touch. Unique for each finger.
  12103. */
  12104. pointerId: number;
  12105. /**
  12106. * Event type passed from DOM.
  12107. */
  12108. type: any;
  12109. }
  12110. }
  12111. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12112. import { Nullable } from "babylonjs/types";
  12113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12114. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12115. /**
  12116. * Manage the mouse inputs to control the movement of a free camera.
  12117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12118. */
  12119. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12120. /**
  12121. * Define if touch is enabled in the mouse input
  12122. */
  12123. touchEnabled: boolean;
  12124. /**
  12125. * Defines the camera the input is attached to.
  12126. */
  12127. camera: FreeCamera;
  12128. /**
  12129. * Defines the buttons associated with the input to handle camera move.
  12130. */
  12131. buttons: number[];
  12132. /**
  12133. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12134. */
  12135. angularSensibility: number;
  12136. private _pointerInput;
  12137. private _onMouseMove;
  12138. private _observer;
  12139. private previousPosition;
  12140. /**
  12141. * Manage the mouse inputs to control the movement of a free camera.
  12142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12143. * @param touchEnabled Defines if touch is enabled or not
  12144. */
  12145. constructor(
  12146. /**
  12147. * Define if touch is enabled in the mouse input
  12148. */
  12149. touchEnabled?: boolean);
  12150. /**
  12151. * Attach the input controls to a specific dom element to get the input from.
  12152. * @param element Defines the element the controls should be listened from
  12153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12154. */
  12155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12156. /**
  12157. * Called on JS contextmenu event.
  12158. * Override this method to provide functionality.
  12159. */
  12160. protected onContextMenu(evt: PointerEvent): void;
  12161. /**
  12162. * Detach the current controls from the specified dom element.
  12163. * @param element Defines the element to stop listening the inputs from
  12164. */
  12165. detachControl(element: Nullable<HTMLElement>): void;
  12166. /**
  12167. * Gets the class name of the current intput.
  12168. * @returns the class name
  12169. */
  12170. getClassName(): string;
  12171. /**
  12172. * Get the friendly name associated with the input class.
  12173. * @returns the input friendly name
  12174. */
  12175. getSimpleName(): string;
  12176. }
  12177. }
  12178. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12179. import { Nullable } from "babylonjs/types";
  12180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12181. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12182. /**
  12183. * Manage the touch inputs to control the movement of a free camera.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12187. /**
  12188. * Defines the camera the input is attached to.
  12189. */
  12190. camera: FreeCamera;
  12191. /**
  12192. * Defines the touch sensibility for rotation.
  12193. * The higher the faster.
  12194. */
  12195. touchAngularSensibility: number;
  12196. /**
  12197. * Defines the touch sensibility for move.
  12198. * The higher the faster.
  12199. */
  12200. touchMoveSensibility: number;
  12201. private _offsetX;
  12202. private _offsetY;
  12203. private _pointerPressed;
  12204. private _pointerInput;
  12205. private _observer;
  12206. private _onLostFocus;
  12207. /**
  12208. * Attach the input controls to a specific dom element to get the input from.
  12209. * @param element Defines the element the controls should be listened from
  12210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12211. */
  12212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12213. /**
  12214. * Detach the current controls from the specified dom element.
  12215. * @param element Defines the element to stop listening the inputs from
  12216. */
  12217. detachControl(element: Nullable<HTMLElement>): void;
  12218. /**
  12219. * Update the current camera state depending on the inputs that have been used this frame.
  12220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12221. */
  12222. checkInputs(): void;
  12223. /**
  12224. * Gets the class name of the current intput.
  12225. * @returns the class name
  12226. */
  12227. getClassName(): string;
  12228. /**
  12229. * Get the friendly name associated with the input class.
  12230. * @returns the input friendly name
  12231. */
  12232. getSimpleName(): string;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12236. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12237. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12238. /**
  12239. * Default Inputs manager for the FreeCamera.
  12240. * It groups all the default supported inputs for ease of use.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. */
  12243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12244. /**
  12245. * Instantiates a new FreeCameraInputsManager.
  12246. * @param camera Defines the camera the inputs belong to
  12247. */
  12248. constructor(camera: FreeCamera);
  12249. /**
  12250. * Add keyboard input support to the input manager.
  12251. * @returns the current input manager
  12252. */
  12253. addKeyboard(): FreeCameraInputsManager;
  12254. /**
  12255. * Add mouse input support to the input manager.
  12256. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12257. * @returns the current input manager
  12258. */
  12259. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12260. /**
  12261. * Add touch input support to the input manager.
  12262. * @returns the current input manager
  12263. */
  12264. addTouch(): FreeCameraInputsManager;
  12265. }
  12266. }
  12267. declare module "babylonjs/Cameras/freeCamera" {
  12268. import { Vector3 } from "babylonjs/Maths/math";
  12269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12270. import { Scene } from "babylonjs/scene";
  12271. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12272. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12273. /**
  12274. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12275. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12277. */
  12278. export class FreeCamera extends TargetCamera {
  12279. /**
  12280. * Define the collision ellipsoid of the camera.
  12281. * This is helpful to simulate a camera body like the player body around the camera
  12282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12283. */
  12284. ellipsoid: Vector3;
  12285. /**
  12286. * Define an offset for the position of the ellipsoid around the camera.
  12287. * This can be helpful to determine the center of the body near the gravity center of the body
  12288. * instead of its head.
  12289. */
  12290. ellipsoidOffset: Vector3;
  12291. /**
  12292. * Enable or disable collisions of the camera with the rest of the scene objects.
  12293. */
  12294. checkCollisions: boolean;
  12295. /**
  12296. * Enable or disable gravity on the camera.
  12297. */
  12298. applyGravity: boolean;
  12299. /**
  12300. * Define the input manager associated to the camera.
  12301. */
  12302. inputs: FreeCameraInputsManager;
  12303. /**
  12304. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12305. * Higher values reduce sensitivity.
  12306. */
  12307. /**
  12308. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12309. * Higher values reduce sensitivity.
  12310. */
  12311. angularSensibility: number;
  12312. /**
  12313. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12314. */
  12315. keysUp: number[];
  12316. /**
  12317. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12318. */
  12319. keysDown: number[];
  12320. /**
  12321. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12322. */
  12323. keysLeft: number[];
  12324. /**
  12325. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12326. */
  12327. keysRight: number[];
  12328. /**
  12329. * Event raised when the camera collide with a mesh in the scene.
  12330. */
  12331. onCollide: (collidedMesh: AbstractMesh) => void;
  12332. private _collider;
  12333. private _needMoveForGravity;
  12334. private _oldPosition;
  12335. private _diffPosition;
  12336. private _newPosition;
  12337. /** @hidden */
  12338. _localDirection: Vector3;
  12339. /** @hidden */
  12340. _transformedDirection: Vector3;
  12341. /**
  12342. * Instantiates a Free Camera.
  12343. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12344. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12346. * @param name Define the name of the camera in the scene
  12347. * @param position Define the start position of the camera in the scene
  12348. * @param scene Define the scene the camera belongs to
  12349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12350. */
  12351. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12352. /**
  12353. * Attached controls to the current camera.
  12354. * @param element Defines the element the controls should be listened from
  12355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12356. */
  12357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12358. /**
  12359. * Detach the current controls from the camera.
  12360. * The camera will stop reacting to inputs.
  12361. * @param element Defines the element to stop listening the inputs from
  12362. */
  12363. detachControl(element: HTMLElement): void;
  12364. private _collisionMask;
  12365. /**
  12366. * Define a collision mask to limit the list of object the camera can collide with
  12367. */
  12368. collisionMask: number;
  12369. /** @hidden */
  12370. _collideWithWorld(displacement: Vector3): void;
  12371. private _onCollisionPositionChange;
  12372. /** @hidden */
  12373. _checkInputs(): void;
  12374. /** @hidden */
  12375. _decideIfNeedsToMove(): boolean;
  12376. /** @hidden */
  12377. _updatePosition(): void;
  12378. /**
  12379. * Destroy the camera and release the current resources hold by it.
  12380. */
  12381. dispose(): void;
  12382. /**
  12383. * Gets the current object class name.
  12384. * @return the class name
  12385. */
  12386. getClassName(): string;
  12387. }
  12388. }
  12389. declare module "babylonjs/Gamepads/gamepad" {
  12390. import { Observable } from "babylonjs/Misc/observable";
  12391. /**
  12392. * Represents a gamepad control stick position
  12393. */
  12394. export class StickValues {
  12395. /**
  12396. * The x component of the control stick
  12397. */
  12398. x: number;
  12399. /**
  12400. * The y component of the control stick
  12401. */
  12402. y: number;
  12403. /**
  12404. * Initializes the gamepad x and y control stick values
  12405. * @param x The x component of the gamepad control stick value
  12406. * @param y The y component of the gamepad control stick value
  12407. */
  12408. constructor(
  12409. /**
  12410. * The x component of the control stick
  12411. */
  12412. x: number,
  12413. /**
  12414. * The y component of the control stick
  12415. */
  12416. y: number);
  12417. }
  12418. /**
  12419. * An interface which manages callbacks for gamepad button changes
  12420. */
  12421. export interface GamepadButtonChanges {
  12422. /**
  12423. * Called when a gamepad has been changed
  12424. */
  12425. changed: boolean;
  12426. /**
  12427. * Called when a gamepad press event has been triggered
  12428. */
  12429. pressChanged: boolean;
  12430. /**
  12431. * Called when a touch event has been triggered
  12432. */
  12433. touchChanged: boolean;
  12434. /**
  12435. * Called when a value has changed
  12436. */
  12437. valueChanged: boolean;
  12438. }
  12439. /**
  12440. * Represents a gamepad
  12441. */
  12442. export class Gamepad {
  12443. /**
  12444. * The id of the gamepad
  12445. */
  12446. id: string;
  12447. /**
  12448. * The index of the gamepad
  12449. */
  12450. index: number;
  12451. /**
  12452. * The browser gamepad
  12453. */
  12454. browserGamepad: any;
  12455. /**
  12456. * Specifies what type of gamepad this represents
  12457. */
  12458. type: number;
  12459. private _leftStick;
  12460. private _rightStick;
  12461. /** @hidden */
  12462. _isConnected: boolean;
  12463. private _leftStickAxisX;
  12464. private _leftStickAxisY;
  12465. private _rightStickAxisX;
  12466. private _rightStickAxisY;
  12467. /**
  12468. * Triggered when the left control stick has been changed
  12469. */
  12470. private _onleftstickchanged;
  12471. /**
  12472. * Triggered when the right control stick has been changed
  12473. */
  12474. private _onrightstickchanged;
  12475. /**
  12476. * Represents a gamepad controller
  12477. */
  12478. static GAMEPAD: number;
  12479. /**
  12480. * Represents a generic controller
  12481. */
  12482. static GENERIC: number;
  12483. /**
  12484. * Represents an XBox controller
  12485. */
  12486. static XBOX: number;
  12487. /**
  12488. * Represents a pose-enabled controller
  12489. */
  12490. static POSE_ENABLED: number;
  12491. /**
  12492. * Specifies whether the left control stick should be Y-inverted
  12493. */
  12494. protected _invertLeftStickY: boolean;
  12495. /**
  12496. * Specifies if the gamepad has been connected
  12497. */
  12498. readonly isConnected: boolean;
  12499. /**
  12500. * Initializes the gamepad
  12501. * @param id The id of the gamepad
  12502. * @param index The index of the gamepad
  12503. * @param browserGamepad The browser gamepad
  12504. * @param leftStickX The x component of the left joystick
  12505. * @param leftStickY The y component of the left joystick
  12506. * @param rightStickX The x component of the right joystick
  12507. * @param rightStickY The y component of the right joystick
  12508. */
  12509. constructor(
  12510. /**
  12511. * The id of the gamepad
  12512. */
  12513. id: string,
  12514. /**
  12515. * The index of the gamepad
  12516. */
  12517. index: number,
  12518. /**
  12519. * The browser gamepad
  12520. */
  12521. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12522. /**
  12523. * Callback triggered when the left joystick has changed
  12524. * @param callback
  12525. */
  12526. onleftstickchanged(callback: (values: StickValues) => void): void;
  12527. /**
  12528. * Callback triggered when the right joystick has changed
  12529. * @param callback
  12530. */
  12531. onrightstickchanged(callback: (values: StickValues) => void): void;
  12532. /**
  12533. * Gets the left joystick
  12534. */
  12535. /**
  12536. * Sets the left joystick values
  12537. */
  12538. leftStick: StickValues;
  12539. /**
  12540. * Gets the right joystick
  12541. */
  12542. /**
  12543. * Sets the right joystick value
  12544. */
  12545. rightStick: StickValues;
  12546. /**
  12547. * Updates the gamepad joystick positions
  12548. */
  12549. update(): void;
  12550. /**
  12551. * Disposes the gamepad
  12552. */
  12553. dispose(): void;
  12554. }
  12555. /**
  12556. * Represents a generic gamepad
  12557. */
  12558. export class GenericPad extends Gamepad {
  12559. private _buttons;
  12560. private _onbuttondown;
  12561. private _onbuttonup;
  12562. /**
  12563. * Observable triggered when a button has been pressed
  12564. */
  12565. onButtonDownObservable: Observable<number>;
  12566. /**
  12567. * Observable triggered when a button has been released
  12568. */
  12569. onButtonUpObservable: Observable<number>;
  12570. /**
  12571. * Callback triggered when a button has been pressed
  12572. * @param callback Called when a button has been pressed
  12573. */
  12574. onbuttondown(callback: (buttonPressed: number) => void): void;
  12575. /**
  12576. * Callback triggered when a button has been released
  12577. * @param callback Called when a button has been released
  12578. */
  12579. onbuttonup(callback: (buttonReleased: number) => void): void;
  12580. /**
  12581. * Initializes the generic gamepad
  12582. * @param id The id of the generic gamepad
  12583. * @param index The index of the generic gamepad
  12584. * @param browserGamepad The browser gamepad
  12585. */
  12586. constructor(id: string, index: number, browserGamepad: any);
  12587. private _setButtonValue;
  12588. /**
  12589. * Updates the generic gamepad
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the generic gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. }
  12598. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12599. import { Observable } from "babylonjs/Misc/observable";
  12600. import { Nullable } from "babylonjs/types";
  12601. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12602. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12604. import { Ray } from "babylonjs/Culling/ray";
  12605. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12606. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12607. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12608. /**
  12609. * Defines the types of pose enabled controllers that are supported
  12610. */
  12611. export enum PoseEnabledControllerType {
  12612. /**
  12613. * HTC Vive
  12614. */
  12615. VIVE = 0,
  12616. /**
  12617. * Oculus Rift
  12618. */
  12619. OCULUS = 1,
  12620. /**
  12621. * Windows mixed reality
  12622. */
  12623. WINDOWS = 2,
  12624. /**
  12625. * Samsung gear VR
  12626. */
  12627. GEAR_VR = 3,
  12628. /**
  12629. * Google Daydream
  12630. */
  12631. DAYDREAM = 4,
  12632. /**
  12633. * Generic
  12634. */
  12635. GENERIC = 5
  12636. }
  12637. /**
  12638. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12639. */
  12640. export interface MutableGamepadButton {
  12641. /**
  12642. * Value of the button/trigger
  12643. */
  12644. value: number;
  12645. /**
  12646. * If the button/trigger is currently touched
  12647. */
  12648. touched: boolean;
  12649. /**
  12650. * If the button/trigger is currently pressed
  12651. */
  12652. pressed: boolean;
  12653. }
  12654. /**
  12655. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12656. * @hidden
  12657. */
  12658. export interface ExtendedGamepadButton extends GamepadButton {
  12659. /**
  12660. * If the button/trigger is currently pressed
  12661. */
  12662. readonly pressed: boolean;
  12663. /**
  12664. * If the button/trigger is currently touched
  12665. */
  12666. readonly touched: boolean;
  12667. /**
  12668. * Value of the button/trigger
  12669. */
  12670. readonly value: number;
  12671. }
  12672. /** @hidden */
  12673. export interface _GamePadFactory {
  12674. /**
  12675. * Returns wether or not the current gamepad can be created for this type of controller.
  12676. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12677. * @returns true if it can be created, otherwise false
  12678. */
  12679. canCreate(gamepadInfo: any): boolean;
  12680. /**
  12681. * Creates a new instance of the Gamepad.
  12682. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12683. * @returns the new gamepad instance
  12684. */
  12685. create(gamepadInfo: any): Gamepad;
  12686. }
  12687. /**
  12688. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12689. */
  12690. export class PoseEnabledControllerHelper {
  12691. /** @hidden */
  12692. static _ControllerFactories: _GamePadFactory[];
  12693. /** @hidden */
  12694. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12695. /**
  12696. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12697. * @param vrGamepad the gamepad to initialized
  12698. * @returns a vr controller of the type the gamepad identified as
  12699. */
  12700. static InitiateController(vrGamepad: any): Gamepad;
  12701. }
  12702. /**
  12703. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12704. */
  12705. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12706. private _deviceRoomPosition;
  12707. private _deviceRoomRotationQuaternion;
  12708. /**
  12709. * The device position in babylon space
  12710. */
  12711. devicePosition: Vector3;
  12712. /**
  12713. * The device rotation in babylon space
  12714. */
  12715. deviceRotationQuaternion: Quaternion;
  12716. /**
  12717. * The scale factor of the device in babylon space
  12718. */
  12719. deviceScaleFactor: number;
  12720. /**
  12721. * (Likely devicePosition should be used instead) The device position in its room space
  12722. */
  12723. position: Vector3;
  12724. /**
  12725. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12726. */
  12727. rotationQuaternion: Quaternion;
  12728. /**
  12729. * The type of controller (Eg. Windows mixed reality)
  12730. */
  12731. controllerType: PoseEnabledControllerType;
  12732. protected _calculatedPosition: Vector3;
  12733. private _calculatedRotation;
  12734. /**
  12735. * The raw pose from the device
  12736. */
  12737. rawPose: DevicePose;
  12738. private _trackPosition;
  12739. private _maxRotationDistFromHeadset;
  12740. private _draggedRoomRotation;
  12741. /**
  12742. * @hidden
  12743. */
  12744. _disableTrackPosition(fixedPosition: Vector3): void;
  12745. /**
  12746. * Internal, the mesh attached to the controller
  12747. * @hidden
  12748. */
  12749. _mesh: Nullable<AbstractMesh>;
  12750. private _poseControlledCamera;
  12751. private _leftHandSystemQuaternion;
  12752. /**
  12753. * Internal, matrix used to convert room space to babylon space
  12754. * @hidden
  12755. */
  12756. _deviceToWorld: Matrix;
  12757. /**
  12758. * Node to be used when casting a ray from the controller
  12759. * @hidden
  12760. */
  12761. _pointingPoseNode: Nullable<TransformNode>;
  12762. /**
  12763. * Name of the child mesh that can be used to cast a ray from the controller
  12764. */
  12765. static readonly POINTING_POSE: string;
  12766. /**
  12767. * Creates a new PoseEnabledController from a gamepad
  12768. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12769. */
  12770. constructor(browserGamepad: any);
  12771. private _workingMatrix;
  12772. /**
  12773. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12774. */
  12775. update(): void;
  12776. /**
  12777. * Updates only the pose device and mesh without doing any button event checking
  12778. */
  12779. protected _updatePoseAndMesh(): void;
  12780. /**
  12781. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12782. * @param poseData raw pose fromthe device
  12783. */
  12784. updateFromDevice(poseData: DevicePose): void;
  12785. /**
  12786. * @hidden
  12787. */
  12788. _meshAttachedObservable: Observable<AbstractMesh>;
  12789. /**
  12790. * Attaches a mesh to the controller
  12791. * @param mesh the mesh to be attached
  12792. */
  12793. attachToMesh(mesh: AbstractMesh): void;
  12794. /**
  12795. * Attaches the controllers mesh to a camera
  12796. * @param camera the camera the mesh should be attached to
  12797. */
  12798. attachToPoseControlledCamera(camera: TargetCamera): void;
  12799. /**
  12800. * Disposes of the controller
  12801. */
  12802. dispose(): void;
  12803. /**
  12804. * The mesh that is attached to the controller
  12805. */
  12806. readonly mesh: Nullable<AbstractMesh>;
  12807. /**
  12808. * Gets the ray of the controller in the direction the controller is pointing
  12809. * @param length the length the resulting ray should be
  12810. * @returns a ray in the direction the controller is pointing
  12811. */
  12812. getForwardRay(length?: number): Ray;
  12813. }
  12814. }
  12815. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12816. import { Observable } from "babylonjs/Misc/observable";
  12817. import { Scene } from "babylonjs/scene";
  12818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12819. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12820. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12821. /**
  12822. * Defines the WebVRController object that represents controllers tracked in 3D space
  12823. */
  12824. export abstract class WebVRController extends PoseEnabledController {
  12825. /**
  12826. * Internal, the default controller model for the controller
  12827. */
  12828. protected _defaultModel: AbstractMesh;
  12829. /**
  12830. * Fired when the trigger state has changed
  12831. */
  12832. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12833. /**
  12834. * Fired when the main button state has changed
  12835. */
  12836. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12837. /**
  12838. * Fired when the secondary button state has changed
  12839. */
  12840. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12841. /**
  12842. * Fired when the pad state has changed
  12843. */
  12844. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12845. /**
  12846. * Fired when controllers stick values have changed
  12847. */
  12848. onPadValuesChangedObservable: Observable<StickValues>;
  12849. /**
  12850. * Array of button availible on the controller
  12851. */
  12852. protected _buttons: Array<MutableGamepadButton>;
  12853. private _onButtonStateChange;
  12854. /**
  12855. * Fired when a controller button's state has changed
  12856. * @param callback the callback containing the button that was modified
  12857. */
  12858. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12859. /**
  12860. * X and Y axis corrisponding to the controllers joystick
  12861. */
  12862. pad: StickValues;
  12863. /**
  12864. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12865. */
  12866. hand: string;
  12867. /**
  12868. * The default controller model for the controller
  12869. */
  12870. readonly defaultModel: AbstractMesh;
  12871. /**
  12872. * Creates a new WebVRController from a gamepad
  12873. * @param vrGamepad the gamepad that the WebVRController should be created from
  12874. */
  12875. constructor(vrGamepad: any);
  12876. /**
  12877. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12878. */
  12879. update(): void;
  12880. /**
  12881. * Function to be called when a button is modified
  12882. */
  12883. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12884. /**
  12885. * Loads a mesh and attaches it to the controller
  12886. * @param scene the scene the mesh should be added to
  12887. * @param meshLoaded callback for when the mesh has been loaded
  12888. */
  12889. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12890. private _setButtonValue;
  12891. private _changes;
  12892. private _checkChanges;
  12893. /**
  12894. * Disposes of th webVRCOntroller
  12895. */
  12896. dispose(): void;
  12897. }
  12898. }
  12899. declare module "babylonjs/Lights/hemisphericLight" {
  12900. import { Nullable } from "babylonjs/types";
  12901. import { Scene } from "babylonjs/scene";
  12902. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12903. import { Effect } from "babylonjs/Materials/effect";
  12904. import { Light } from "babylonjs/Lights/light";
  12905. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12906. /**
  12907. * The HemisphericLight simulates the ambient environment light,
  12908. * so the passed direction is the light reflection direction, not the incoming direction.
  12909. */
  12910. export class HemisphericLight extends Light {
  12911. /**
  12912. * The groundColor is the light in the opposite direction to the one specified during creation.
  12913. * 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.
  12914. */
  12915. groundColor: Color3;
  12916. /**
  12917. * The light reflection direction, not the incoming direction.
  12918. */
  12919. direction: Vector3;
  12920. /**
  12921. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12922. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12923. * The HemisphericLight can't cast shadows.
  12924. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12925. * @param name The friendly name of the light
  12926. * @param direction The direction of the light reflection
  12927. * @param scene The scene the light belongs to
  12928. */
  12929. constructor(name: string, direction: Vector3, scene: Scene);
  12930. protected _buildUniformLayout(): void;
  12931. /**
  12932. * Returns the string "HemisphericLight".
  12933. * @return The class name
  12934. */
  12935. getClassName(): string;
  12936. /**
  12937. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12938. * Returns the updated direction.
  12939. * @param target The target the direction should point to
  12940. * @return The computed direction
  12941. */
  12942. setDirectionToTarget(target: Vector3): Vector3;
  12943. /**
  12944. * Returns the shadow generator associated to the light.
  12945. * @returns Always null for hemispheric lights because it does not support shadows.
  12946. */
  12947. getShadowGenerator(): Nullable<IShadowGenerator>;
  12948. /**
  12949. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12950. * @param effect The effect to update
  12951. * @param lightIndex The index of the light in the effect to update
  12952. * @returns The hemispheric light
  12953. */
  12954. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12955. /**
  12956. * Computes the world matrix of the node
  12957. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12958. * @param useWasUpdatedFlag defines a reserved property
  12959. * @returns the world matrix
  12960. */
  12961. computeWorldMatrix(): Matrix;
  12962. /**
  12963. * Returns the integer 3.
  12964. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12965. */
  12966. getTypeID(): number;
  12967. /**
  12968. * Prepares the list of defines specific to the light type.
  12969. * @param defines the list of defines
  12970. * @param lightIndex defines the index of the light for the effect
  12971. */
  12972. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12973. }
  12974. }
  12975. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12976. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12977. import { Nullable } from "babylonjs/types";
  12978. import { Observable } from "babylonjs/Misc/observable";
  12979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12980. import { Scene } from "babylonjs/scene";
  12981. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12983. import { Node } from "babylonjs/node";
  12984. import { Ray } from "babylonjs/Culling/ray";
  12985. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12986. /**
  12987. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12988. * IMPORTANT!! The data is right-hand data.
  12989. * @export
  12990. * @interface DevicePose
  12991. */
  12992. export interface DevicePose {
  12993. /**
  12994. * The position of the device, values in array are [x,y,z].
  12995. */
  12996. readonly position: Nullable<Float32Array>;
  12997. /**
  12998. * The linearVelocity of the device, values in array are [x,y,z].
  12999. */
  13000. readonly linearVelocity: Nullable<Float32Array>;
  13001. /**
  13002. * The linearAcceleration of the device, values in array are [x,y,z].
  13003. */
  13004. readonly linearAcceleration: Nullable<Float32Array>;
  13005. /**
  13006. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13007. */
  13008. readonly orientation: Nullable<Float32Array>;
  13009. /**
  13010. * The angularVelocity of the device, values in array are [x,y,z].
  13011. */
  13012. readonly angularVelocity: Nullable<Float32Array>;
  13013. /**
  13014. * The angularAcceleration of the device, values in array are [x,y,z].
  13015. */
  13016. readonly angularAcceleration: Nullable<Float32Array>;
  13017. }
  13018. /**
  13019. * Interface representing a pose controlled object in Babylon.
  13020. * A pose controlled object has both regular pose values as well as pose values
  13021. * from an external device such as a VR head mounted display
  13022. */
  13023. export interface PoseControlled {
  13024. /**
  13025. * The position of the object in babylon space.
  13026. */
  13027. position: Vector3;
  13028. /**
  13029. * The rotation quaternion of the object in babylon space.
  13030. */
  13031. rotationQuaternion: Quaternion;
  13032. /**
  13033. * The position of the device in babylon space.
  13034. */
  13035. devicePosition?: Vector3;
  13036. /**
  13037. * The rotation quaternion of the device in babylon space.
  13038. */
  13039. deviceRotationQuaternion: Quaternion;
  13040. /**
  13041. * The raw pose coming from the device.
  13042. */
  13043. rawPose: Nullable<DevicePose>;
  13044. /**
  13045. * The scale of the device to be used when translating from device space to babylon space.
  13046. */
  13047. deviceScaleFactor: number;
  13048. /**
  13049. * Updates the poseControlled values based on the input device pose.
  13050. * @param poseData the pose data to update the object with
  13051. */
  13052. updateFromDevice(poseData: DevicePose): void;
  13053. }
  13054. /**
  13055. * Set of options to customize the webVRCamera
  13056. */
  13057. export interface WebVROptions {
  13058. /**
  13059. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13060. */
  13061. trackPosition?: boolean;
  13062. /**
  13063. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13064. */
  13065. positionScale?: number;
  13066. /**
  13067. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13068. */
  13069. displayName?: string;
  13070. /**
  13071. * Should the native controller meshes be initialized. (default: true)
  13072. */
  13073. controllerMeshes?: boolean;
  13074. /**
  13075. * Creating a default HemiLight only on controllers. (default: true)
  13076. */
  13077. defaultLightingOnControllers?: boolean;
  13078. /**
  13079. * If you don't want to use the default VR button of the helper. (default: false)
  13080. */
  13081. useCustomVRButton?: boolean;
  13082. /**
  13083. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13084. */
  13085. customVRButton?: HTMLButtonElement;
  13086. /**
  13087. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13088. */
  13089. rayLength?: number;
  13090. /**
  13091. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13092. */
  13093. defaultHeight?: number;
  13094. }
  13095. /**
  13096. * This represents a WebVR camera.
  13097. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13098. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13099. */
  13100. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13101. private webVROptions;
  13102. /**
  13103. * @hidden
  13104. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13105. */
  13106. _vrDevice: any;
  13107. /**
  13108. * The rawPose of the vrDevice.
  13109. */
  13110. rawPose: Nullable<DevicePose>;
  13111. private _onVREnabled;
  13112. private _specsVersion;
  13113. private _attached;
  13114. private _frameData;
  13115. protected _descendants: Array<Node>;
  13116. private _deviceRoomPosition;
  13117. /** @hidden */
  13118. _deviceRoomRotationQuaternion: Quaternion;
  13119. private _standingMatrix;
  13120. /**
  13121. * Represents device position in babylon space.
  13122. */
  13123. devicePosition: Vector3;
  13124. /**
  13125. * Represents device rotation in babylon space.
  13126. */
  13127. deviceRotationQuaternion: Quaternion;
  13128. /**
  13129. * The scale of the device to be used when translating from device space to babylon space.
  13130. */
  13131. deviceScaleFactor: number;
  13132. private _deviceToWorld;
  13133. private _worldToDevice;
  13134. /**
  13135. * References to the webVR controllers for the vrDevice.
  13136. */
  13137. controllers: Array<WebVRController>;
  13138. /**
  13139. * Emits an event when a controller is attached.
  13140. */
  13141. onControllersAttachedObservable: Observable<WebVRController[]>;
  13142. /**
  13143. * Emits an event when a controller's mesh has been loaded;
  13144. */
  13145. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13146. /**
  13147. * Emits an event when the HMD's pose has been updated.
  13148. */
  13149. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13150. private _poseSet;
  13151. /**
  13152. * If the rig cameras be used as parent instead of this camera.
  13153. */
  13154. rigParenting: boolean;
  13155. private _lightOnControllers;
  13156. private _defaultHeight?;
  13157. /**
  13158. * Instantiates a WebVRFreeCamera.
  13159. * @param name The name of the WebVRFreeCamera
  13160. * @param position The starting anchor position for the camera
  13161. * @param scene The scene the camera belongs to
  13162. * @param webVROptions a set of customizable options for the webVRCamera
  13163. */
  13164. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13165. /**
  13166. * Gets the device distance from the ground in meters.
  13167. * @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.
  13168. */
  13169. deviceDistanceToRoomGround(): number;
  13170. /**
  13171. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13172. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13173. */
  13174. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13175. /**
  13176. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13177. * @returns A promise with a boolean set to if the standing matrix is supported.
  13178. */
  13179. useStandingMatrixAsync(): Promise<boolean>;
  13180. /**
  13181. * Disposes the camera
  13182. */
  13183. dispose(): void;
  13184. /**
  13185. * Gets a vrController by name.
  13186. * @param name The name of the controller to retreive
  13187. * @returns the controller matching the name specified or null if not found
  13188. */
  13189. getControllerByName(name: string): Nullable<WebVRController>;
  13190. private _leftController;
  13191. /**
  13192. * The controller corrisponding to the users left hand.
  13193. */
  13194. readonly leftController: Nullable<WebVRController>;
  13195. private _rightController;
  13196. /**
  13197. * The controller corrisponding to the users right hand.
  13198. */
  13199. readonly rightController: Nullable<WebVRController>;
  13200. /**
  13201. * Casts a ray forward from the vrCamera's gaze.
  13202. * @param length Length of the ray (default: 100)
  13203. * @returns the ray corrisponding to the gaze
  13204. */
  13205. getForwardRay(length?: number): Ray;
  13206. /**
  13207. * @hidden
  13208. * Updates the camera based on device's frame data
  13209. */
  13210. _checkInputs(): void;
  13211. /**
  13212. * Updates the poseControlled values based on the input device pose.
  13213. * @param poseData Pose coming from the device
  13214. */
  13215. updateFromDevice(poseData: DevicePose): void;
  13216. private _htmlElementAttached;
  13217. private _detachIfAttached;
  13218. /**
  13219. * WebVR's attach control will start broadcasting frames to the device.
  13220. * Note that in certain browsers (chrome for example) this function must be called
  13221. * within a user-interaction callback. Example:
  13222. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13223. *
  13224. * @param element html element to attach the vrDevice to
  13225. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13226. */
  13227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13228. /**
  13229. * Detaches the camera from the html element and disables VR
  13230. *
  13231. * @param element html element to detach from
  13232. */
  13233. detachControl(element: HTMLElement): void;
  13234. /**
  13235. * @returns the name of this class
  13236. */
  13237. getClassName(): string;
  13238. /**
  13239. * Calls resetPose on the vrDisplay
  13240. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13241. */
  13242. resetToCurrentRotation(): void;
  13243. /**
  13244. * @hidden
  13245. * Updates the rig cameras (left and right eye)
  13246. */
  13247. _updateRigCameras(): void;
  13248. private _workingVector;
  13249. private _oneVector;
  13250. private _workingMatrix;
  13251. private updateCacheCalled;
  13252. private _correctPositionIfNotTrackPosition;
  13253. /**
  13254. * @hidden
  13255. * Updates the cached values of the camera
  13256. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13257. */
  13258. _updateCache(ignoreParentClass?: boolean): void;
  13259. /**
  13260. * @hidden
  13261. * Get current device position in babylon world
  13262. */
  13263. _computeDevicePosition(): void;
  13264. /**
  13265. * Updates the current device position and rotation in the babylon world
  13266. */
  13267. update(): void;
  13268. /**
  13269. * @hidden
  13270. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13271. * @returns an identity matrix
  13272. */
  13273. _getViewMatrix(): Matrix;
  13274. private _tmpMatrix;
  13275. /**
  13276. * This function is called by the two RIG cameras.
  13277. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13278. * @hidden
  13279. */
  13280. _getWebVRViewMatrix(): Matrix;
  13281. /** @hidden */
  13282. _getWebVRProjectionMatrix(): Matrix;
  13283. private _onGamepadConnectedObserver;
  13284. private _onGamepadDisconnectedObserver;
  13285. private _updateCacheWhenTrackingDisabledObserver;
  13286. /**
  13287. * Initializes the controllers and their meshes
  13288. */
  13289. initControllers(): void;
  13290. }
  13291. }
  13292. declare module "babylonjs/PostProcesses/postProcess" {
  13293. import { Nullable } from "babylonjs/types";
  13294. import { SmartArray } from "babylonjs/Misc/smartArray";
  13295. import { Observable } from "babylonjs/Misc/observable";
  13296. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13297. import { Camera } from "babylonjs/Cameras/camera";
  13298. import { Effect } from "babylonjs/Materials/effect";
  13299. import "babylonjs/Shaders/postprocess.vertex";
  13300. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13301. import { Engine } from "babylonjs/Engines/engine";
  13302. /**
  13303. * Size options for a post process
  13304. */
  13305. export type PostProcessOptions = {
  13306. width: number;
  13307. height: number;
  13308. };
  13309. /**
  13310. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13311. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13312. */
  13313. export class PostProcess {
  13314. /** Name of the PostProcess. */
  13315. name: string;
  13316. /**
  13317. * Gets or sets the unique id of the post process
  13318. */
  13319. uniqueId: number;
  13320. /**
  13321. * Width of the texture to apply the post process on
  13322. */
  13323. width: number;
  13324. /**
  13325. * Height of the texture to apply the post process on
  13326. */
  13327. height: number;
  13328. /**
  13329. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13330. * @hidden
  13331. */
  13332. _outputTexture: Nullable<InternalTexture>;
  13333. /**
  13334. * Sampling mode used by the shader
  13335. * See https://doc.babylonjs.com/classes/3.1/texture
  13336. */
  13337. renderTargetSamplingMode: number;
  13338. /**
  13339. * Clear color to use when screen clearing
  13340. */
  13341. clearColor: Color4;
  13342. /**
  13343. * If the buffer needs to be cleared before applying the post process. (default: true)
  13344. * Should be set to false if shader will overwrite all previous pixels.
  13345. */
  13346. autoClear: boolean;
  13347. /**
  13348. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13349. */
  13350. alphaMode: number;
  13351. /**
  13352. * Sets the setAlphaBlendConstants of the babylon engine
  13353. */
  13354. alphaConstants: Color4;
  13355. /**
  13356. * Animations to be used for the post processing
  13357. */
  13358. animations: import("babylonjs/Animations/animation").Animation[];
  13359. /**
  13360. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13361. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13362. */
  13363. enablePixelPerfectMode: boolean;
  13364. /**
  13365. * Force the postprocess to be applied without taking in account viewport
  13366. */
  13367. forceFullscreenViewport: boolean;
  13368. /**
  13369. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13370. *
  13371. * | Value | Type | Description |
  13372. * | ----- | ----------------------------------- | ----------- |
  13373. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13374. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13375. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13376. *
  13377. */
  13378. scaleMode: number;
  13379. /**
  13380. * Force textures to be a power of two (default: false)
  13381. */
  13382. alwaysForcePOT: boolean;
  13383. private _samples;
  13384. /**
  13385. * Number of sample textures (default: 1)
  13386. */
  13387. samples: number;
  13388. /**
  13389. * Modify the scale of the post process to be the same as the viewport (default: false)
  13390. */
  13391. adaptScaleToCurrentViewport: boolean;
  13392. private _camera;
  13393. private _scene;
  13394. private _engine;
  13395. private _options;
  13396. private _reusable;
  13397. private _textureType;
  13398. /**
  13399. * Smart array of input and output textures for the post process.
  13400. * @hidden
  13401. */
  13402. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13403. /**
  13404. * The index in _textures that corresponds to the output texture.
  13405. * @hidden
  13406. */
  13407. _currentRenderTextureInd: number;
  13408. private _effect;
  13409. private _samplers;
  13410. private _fragmentUrl;
  13411. private _vertexUrl;
  13412. private _parameters;
  13413. private _scaleRatio;
  13414. protected _indexParameters: any;
  13415. private _shareOutputWithPostProcess;
  13416. private _texelSize;
  13417. private _forcedOutputTexture;
  13418. /**
  13419. * Returns the fragment url or shader name used in the post process.
  13420. * @returns the fragment url or name in the shader store.
  13421. */
  13422. getEffectName(): string;
  13423. /**
  13424. * An event triggered when the postprocess is activated.
  13425. */
  13426. onActivateObservable: Observable<Camera>;
  13427. private _onActivateObserver;
  13428. /**
  13429. * A function that is added to the onActivateObservable
  13430. */
  13431. onActivate: Nullable<(camera: Camera) => void>;
  13432. /**
  13433. * An event triggered when the postprocess changes its size.
  13434. */
  13435. onSizeChangedObservable: Observable<PostProcess>;
  13436. private _onSizeChangedObserver;
  13437. /**
  13438. * A function that is added to the onSizeChangedObservable
  13439. */
  13440. onSizeChanged: (postProcess: PostProcess) => void;
  13441. /**
  13442. * An event triggered when the postprocess applies its effect.
  13443. */
  13444. onApplyObservable: Observable<Effect>;
  13445. private _onApplyObserver;
  13446. /**
  13447. * A function that is added to the onApplyObservable
  13448. */
  13449. onApply: (effect: Effect) => void;
  13450. /**
  13451. * An event triggered before rendering the postprocess
  13452. */
  13453. onBeforeRenderObservable: Observable<Effect>;
  13454. private _onBeforeRenderObserver;
  13455. /**
  13456. * A function that is added to the onBeforeRenderObservable
  13457. */
  13458. onBeforeRender: (effect: Effect) => void;
  13459. /**
  13460. * An event triggered after rendering the postprocess
  13461. */
  13462. onAfterRenderObservable: Observable<Effect>;
  13463. private _onAfterRenderObserver;
  13464. /**
  13465. * A function that is added to the onAfterRenderObservable
  13466. */
  13467. onAfterRender: (efect: Effect) => void;
  13468. /**
  13469. * 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
  13470. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13471. */
  13472. inputTexture: InternalTexture;
  13473. /**
  13474. * Gets the camera which post process is applied to.
  13475. * @returns The camera the post process is applied to.
  13476. */
  13477. getCamera(): Camera;
  13478. /**
  13479. * Gets the texel size of the postprocess.
  13480. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13481. */
  13482. readonly texelSize: Vector2;
  13483. /**
  13484. * Creates a new instance PostProcess
  13485. * @param name The name of the PostProcess.
  13486. * @param fragmentUrl The url of the fragment shader to be used.
  13487. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13488. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13489. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13490. * @param camera The camera to apply the render pass to.
  13491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13492. * @param engine The engine which the post process will be applied. (default: current engine)
  13493. * @param reusable If the post process can be reused on the same frame. (default: false)
  13494. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13495. * @param textureType Type of textures used when performing the post process. (default: 0)
  13496. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13497. * @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
  13498. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13499. */
  13500. constructor(
  13501. /** Name of the PostProcess. */
  13502. 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);
  13503. /**
  13504. * Gets a string idenfifying the name of the class
  13505. * @returns "PostProcess" string
  13506. */
  13507. getClassName(): string;
  13508. /**
  13509. * Gets the engine which this post process belongs to.
  13510. * @returns The engine the post process was enabled with.
  13511. */
  13512. getEngine(): Engine;
  13513. /**
  13514. * The effect that is created when initializing the post process.
  13515. * @returns The created effect corrisponding the the postprocess.
  13516. */
  13517. getEffect(): Effect;
  13518. /**
  13519. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13520. * @param postProcess The post process to share the output with.
  13521. * @returns This post process.
  13522. */
  13523. shareOutputWith(postProcess: PostProcess): PostProcess;
  13524. /**
  13525. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13526. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13527. */
  13528. useOwnOutput(): void;
  13529. /**
  13530. * Updates the effect with the current post process compile time values and recompiles the shader.
  13531. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13532. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13533. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13534. * @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
  13535. * @param onCompiled Called when the shader has been compiled.
  13536. * @param onError Called if there is an error when compiling a shader.
  13537. */
  13538. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13539. /**
  13540. * The post process is reusable if it can be used multiple times within one frame.
  13541. * @returns If the post process is reusable
  13542. */
  13543. isReusable(): boolean;
  13544. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13545. markTextureDirty(): void;
  13546. /**
  13547. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13548. * 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.
  13549. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13550. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13551. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13552. * @returns The target texture that was bound to be written to.
  13553. */
  13554. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13555. /**
  13556. * If the post process is supported.
  13557. */
  13558. readonly isSupported: boolean;
  13559. /**
  13560. * The aspect ratio of the output texture.
  13561. */
  13562. readonly aspectRatio: number;
  13563. /**
  13564. * Get a value indicating if the post-process is ready to be used
  13565. * @returns true if the post-process is ready (shader is compiled)
  13566. */
  13567. isReady(): boolean;
  13568. /**
  13569. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13570. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13571. */
  13572. apply(): Nullable<Effect>;
  13573. private _disposeTextures;
  13574. /**
  13575. * Disposes the post process.
  13576. * @param camera The camera to dispose the post process on.
  13577. */
  13578. dispose(camera?: Camera): void;
  13579. }
  13580. }
  13581. declare module "babylonjs/PostProcesses/postProcessManager" {
  13582. import { Nullable } from "babylonjs/types";
  13583. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13584. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13585. import { Scene } from "babylonjs/scene";
  13586. /**
  13587. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13588. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13589. */
  13590. export class PostProcessManager {
  13591. private _scene;
  13592. private _indexBuffer;
  13593. private _vertexBuffers;
  13594. /**
  13595. * Creates a new instance PostProcess
  13596. * @param scene The scene that the post process is associated with.
  13597. */
  13598. constructor(scene: Scene);
  13599. private _prepareBuffers;
  13600. private _buildIndexBuffer;
  13601. /**
  13602. * Rebuilds the vertex buffers of the manager.
  13603. * @hidden
  13604. */
  13605. _rebuild(): void;
  13606. /**
  13607. * Prepares a frame to be run through a post process.
  13608. * @param sourceTexture The input texture to the post procesess. (default: null)
  13609. * @param postProcesses An array of post processes to be run. (default: null)
  13610. * @returns True if the post processes were able to be run.
  13611. * @hidden
  13612. */
  13613. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13614. /**
  13615. * Manually render a set of post processes to a texture.
  13616. * @param postProcesses An array of post processes to be run.
  13617. * @param targetTexture The target texture to render to.
  13618. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13619. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13620. * @param lodLevel defines which lod of the texture to render to
  13621. */
  13622. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13623. /**
  13624. * Finalize the result of the output of the postprocesses.
  13625. * @param doNotPresent If true the result will not be displayed to the screen.
  13626. * @param targetTexture The target texture to render to.
  13627. * @param faceIndex The index of the face to bind the target texture to.
  13628. * @param postProcesses The array of post processes to render.
  13629. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13630. * @hidden
  13631. */
  13632. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13633. /**
  13634. * Disposes of the post process manager.
  13635. */
  13636. dispose(): void;
  13637. }
  13638. }
  13639. declare module "babylonjs/Layers/layerSceneComponent" {
  13640. import { Scene } from "babylonjs/scene";
  13641. import { ISceneComponent } from "babylonjs/sceneComponent";
  13642. import { Layer } from "babylonjs/Layers/layer";
  13643. module "babylonjs/abstractScene" {
  13644. interface AbstractScene {
  13645. /**
  13646. * The list of layers (background and foreground) of the scene
  13647. */
  13648. layers: Array<Layer>;
  13649. }
  13650. }
  13651. /**
  13652. * Defines the layer scene component responsible to manage any layers
  13653. * in a given scene.
  13654. */
  13655. export class LayerSceneComponent implements ISceneComponent {
  13656. /**
  13657. * The component name helpfull to identify the component in the list of scene components.
  13658. */
  13659. readonly name: string;
  13660. /**
  13661. * The scene the component belongs to.
  13662. */
  13663. scene: Scene;
  13664. private _engine;
  13665. /**
  13666. * Creates a new instance of the component for the given scene
  13667. * @param scene Defines the scene to register the component in
  13668. */
  13669. constructor(scene: Scene);
  13670. /**
  13671. * Registers the component in a given scene
  13672. */
  13673. register(): void;
  13674. /**
  13675. * Rebuilds the elements related to this component in case of
  13676. * context lost for instance.
  13677. */
  13678. rebuild(): void;
  13679. /**
  13680. * Disposes the component and the associated ressources.
  13681. */
  13682. dispose(): void;
  13683. private _draw;
  13684. private _drawCameraPredicate;
  13685. private _drawCameraBackground;
  13686. private _drawCameraForeground;
  13687. private _drawRenderTargetPredicate;
  13688. private _drawRenderTargetBackground;
  13689. private _drawRenderTargetForeground;
  13690. }
  13691. }
  13692. declare module "babylonjs/Shaders/layer.fragment" {
  13693. /** @hidden */
  13694. export var layerPixelShader: {
  13695. name: string;
  13696. shader: string;
  13697. };
  13698. }
  13699. declare module "babylonjs/Shaders/layer.vertex" {
  13700. /** @hidden */
  13701. export var layerVertexShader: {
  13702. name: string;
  13703. shader: string;
  13704. };
  13705. }
  13706. declare module "babylonjs/Layers/layer" {
  13707. import { Observable } from "babylonjs/Misc/observable";
  13708. import { Nullable } from "babylonjs/types";
  13709. import { Scene } from "babylonjs/scene";
  13710. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13711. import { Texture } from "babylonjs/Materials/Textures/texture";
  13712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13713. import "babylonjs/Shaders/layer.fragment";
  13714. import "babylonjs/Shaders/layer.vertex";
  13715. /**
  13716. * This represents a full screen 2d layer.
  13717. * This can be useful to display a picture in the background of your scene for instance.
  13718. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13719. */
  13720. export class Layer {
  13721. /**
  13722. * Define the name of the layer.
  13723. */
  13724. name: string;
  13725. /**
  13726. * Define the texture the layer should display.
  13727. */
  13728. texture: Nullable<Texture>;
  13729. /**
  13730. * Is the layer in background or foreground.
  13731. */
  13732. isBackground: boolean;
  13733. /**
  13734. * Define the color of the layer (instead of texture).
  13735. */
  13736. color: Color4;
  13737. /**
  13738. * Define the scale of the layer in order to zoom in out of the texture.
  13739. */
  13740. scale: Vector2;
  13741. /**
  13742. * Define an offset for the layer in order to shift the texture.
  13743. */
  13744. offset: Vector2;
  13745. /**
  13746. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13747. */
  13748. alphaBlendingMode: number;
  13749. /**
  13750. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13751. * Alpha test will not mix with the background color in case of transparency.
  13752. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13753. */
  13754. alphaTest: boolean;
  13755. /**
  13756. * Define a mask to restrict the layer to only some of the scene cameras.
  13757. */
  13758. layerMask: number;
  13759. /**
  13760. * Define the list of render target the layer is visible into.
  13761. */
  13762. renderTargetTextures: RenderTargetTexture[];
  13763. /**
  13764. * Define if the layer is only used in renderTarget or if it also
  13765. * renders in the main frame buffer of the canvas.
  13766. */
  13767. renderOnlyInRenderTargetTextures: boolean;
  13768. private _scene;
  13769. private _vertexBuffers;
  13770. private _indexBuffer;
  13771. private _effect;
  13772. private _alphaTestEffect;
  13773. /**
  13774. * An event triggered when the layer is disposed.
  13775. */
  13776. onDisposeObservable: Observable<Layer>;
  13777. private _onDisposeObserver;
  13778. /**
  13779. * Back compatibility with callback before the onDisposeObservable existed.
  13780. * The set callback will be triggered when the layer has been disposed.
  13781. */
  13782. onDispose: () => void;
  13783. /**
  13784. * An event triggered before rendering the scene
  13785. */
  13786. onBeforeRenderObservable: Observable<Layer>;
  13787. private _onBeforeRenderObserver;
  13788. /**
  13789. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13790. * The set callback will be triggered just before rendering the layer.
  13791. */
  13792. onBeforeRender: () => void;
  13793. /**
  13794. * An event triggered after rendering the scene
  13795. */
  13796. onAfterRenderObservable: Observable<Layer>;
  13797. private _onAfterRenderObserver;
  13798. /**
  13799. * Back compatibility with callback before the onAfterRenderObservable existed.
  13800. * The set callback will be triggered just after rendering the layer.
  13801. */
  13802. onAfterRender: () => void;
  13803. /**
  13804. * Instantiates a new layer.
  13805. * This represents a full screen 2d layer.
  13806. * This can be useful to display a picture in the background of your scene for instance.
  13807. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13808. * @param name Define the name of the layer in the scene
  13809. * @param imgUrl Define the url of the texture to display in the layer
  13810. * @param scene Define the scene the layer belongs to
  13811. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13812. * @param color Defines a color for the layer
  13813. */
  13814. constructor(
  13815. /**
  13816. * Define the name of the layer.
  13817. */
  13818. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13819. private _createIndexBuffer;
  13820. /** @hidden */
  13821. _rebuild(): void;
  13822. /**
  13823. * Renders the layer in the scene.
  13824. */
  13825. render(): void;
  13826. /**
  13827. * Disposes and releases the associated ressources.
  13828. */
  13829. dispose(): void;
  13830. }
  13831. }
  13832. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13833. import { Scene } from "babylonjs/scene";
  13834. import { ISceneComponent } from "babylonjs/sceneComponent";
  13835. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13836. module "babylonjs/abstractScene" {
  13837. interface AbstractScene {
  13838. /**
  13839. * The list of procedural textures added to the scene
  13840. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13841. */
  13842. proceduralTextures: Array<ProceduralTexture>;
  13843. }
  13844. }
  13845. /**
  13846. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13847. * in a given scene.
  13848. */
  13849. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13850. /**
  13851. * The component name helpfull to identify the component in the list of scene components.
  13852. */
  13853. readonly name: string;
  13854. /**
  13855. * The scene the component belongs to.
  13856. */
  13857. scene: Scene;
  13858. /**
  13859. * Creates a new instance of the component for the given scene
  13860. * @param scene Defines the scene to register the component in
  13861. */
  13862. constructor(scene: Scene);
  13863. /**
  13864. * Registers the component in a given scene
  13865. */
  13866. register(): void;
  13867. /**
  13868. * Rebuilds the elements related to this component in case of
  13869. * context lost for instance.
  13870. */
  13871. rebuild(): void;
  13872. /**
  13873. * Disposes the component and the associated ressources.
  13874. */
  13875. dispose(): void;
  13876. private _beforeClear;
  13877. }
  13878. }
  13879. declare module "babylonjs/Shaders/procedural.vertex" {
  13880. /** @hidden */
  13881. export var proceduralVertexShader: {
  13882. name: string;
  13883. shader: string;
  13884. };
  13885. }
  13886. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13887. import { Observable } from "babylonjs/Misc/observable";
  13888. import { Nullable } from "babylonjs/types";
  13889. import { Scene } from "babylonjs/scene";
  13890. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13891. import { Effect } from "babylonjs/Materials/effect";
  13892. import { Texture } from "babylonjs/Materials/Textures/texture";
  13893. import "babylonjs/Shaders/procedural.vertex";
  13894. /**
  13895. * 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.
  13896. * This is the base class of any Procedural texture and contains most of the shareable code.
  13897. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13898. */
  13899. export class ProceduralTexture extends Texture {
  13900. isCube: boolean;
  13901. /**
  13902. * Define if the texture is enabled or not (disabled texture will not render)
  13903. */
  13904. isEnabled: boolean;
  13905. /**
  13906. * Define if the texture must be cleared before rendering (default is true)
  13907. */
  13908. autoClear: boolean;
  13909. /**
  13910. * Callback called when the texture is generated
  13911. */
  13912. onGenerated: () => void;
  13913. /**
  13914. * Event raised when the texture is generated
  13915. */
  13916. onGeneratedObservable: Observable<ProceduralTexture>;
  13917. /** @hidden */
  13918. _generateMipMaps: boolean;
  13919. /** @hidden **/
  13920. _effect: Effect;
  13921. /** @hidden */
  13922. _textures: {
  13923. [key: string]: Texture;
  13924. };
  13925. private _size;
  13926. private _currentRefreshId;
  13927. private _refreshRate;
  13928. private _vertexBuffers;
  13929. private _indexBuffer;
  13930. private _uniforms;
  13931. private _samplers;
  13932. private _fragment;
  13933. private _floats;
  13934. private _ints;
  13935. private _floatsArrays;
  13936. private _colors3;
  13937. private _colors4;
  13938. private _vectors2;
  13939. private _vectors3;
  13940. private _matrices;
  13941. private _fallbackTexture;
  13942. private _fallbackTextureUsed;
  13943. private _engine;
  13944. private _cachedDefines;
  13945. private _contentUpdateId;
  13946. private _contentData;
  13947. /**
  13948. * Instantiates a new procedural texture.
  13949. * 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.
  13950. * This is the base class of any Procedural texture and contains most of the shareable code.
  13951. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13952. * @param name Define the name of the texture
  13953. * @param size Define the size of the texture to create
  13954. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13955. * @param scene Define the scene the texture belongs to
  13956. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13957. * @param generateMipMaps Define if the texture should creates mip maps or not
  13958. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13959. */
  13960. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13961. /**
  13962. * The effect that is created when initializing the post process.
  13963. * @returns The created effect corrisponding the the postprocess.
  13964. */
  13965. getEffect(): Effect;
  13966. /**
  13967. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13968. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13969. */
  13970. getContent(): Nullable<ArrayBufferView>;
  13971. private _createIndexBuffer;
  13972. /** @hidden */
  13973. _rebuild(): void;
  13974. /**
  13975. * Resets the texture in order to recreate its associated resources.
  13976. * This can be called in case of context loss
  13977. */
  13978. reset(): void;
  13979. protected _getDefines(): string;
  13980. /**
  13981. * Is the texture ready to be used ? (rendered at least once)
  13982. * @returns true if ready, otherwise, false.
  13983. */
  13984. isReady(): boolean;
  13985. /**
  13986. * Resets the refresh counter of the texture and start bak from scratch.
  13987. * Could be useful to regenerate the texture if it is setup to render only once.
  13988. */
  13989. resetRefreshCounter(): void;
  13990. /**
  13991. * Set the fragment shader to use in order to render the texture.
  13992. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13993. */
  13994. setFragment(fragment: any): void;
  13995. /**
  13996. * Define the refresh rate of the texture or the rendering frequency.
  13997. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13998. */
  13999. refreshRate: number;
  14000. /** @hidden */
  14001. _shouldRender(): boolean;
  14002. /**
  14003. * Get the size the texture is rendering at.
  14004. * @returns the size (texture is always squared)
  14005. */
  14006. getRenderSize(): number;
  14007. /**
  14008. * Resize the texture to new value.
  14009. * @param size Define the new size the texture should have
  14010. * @param generateMipMaps Define whether the new texture should create mip maps
  14011. */
  14012. resize(size: number, generateMipMaps: boolean): void;
  14013. private _checkUniform;
  14014. /**
  14015. * Set a texture in the shader program used to render.
  14016. * @param name Define the name of the uniform samplers as defined in the shader
  14017. * @param texture Define the texture to bind to this sampler
  14018. * @return the texture itself allowing "fluent" like uniform updates
  14019. */
  14020. setTexture(name: string, texture: Texture): ProceduralTexture;
  14021. /**
  14022. * Set a float in the shader.
  14023. * @param name Define the name of the uniform as defined in the shader
  14024. * @param value Define the value to give to the uniform
  14025. * @return the texture itself allowing "fluent" like uniform updates
  14026. */
  14027. setFloat(name: string, value: number): ProceduralTexture;
  14028. /**
  14029. * Set a int in the shader.
  14030. * @param name Define the name of the uniform as defined in the shader
  14031. * @param value Define the value to give to the uniform
  14032. * @return the texture itself allowing "fluent" like uniform updates
  14033. */
  14034. setInt(name: string, value: number): ProceduralTexture;
  14035. /**
  14036. * Set an array of floats in the shader.
  14037. * @param name Define the name of the uniform as defined in the shader
  14038. * @param value Define the value to give to the uniform
  14039. * @return the texture itself allowing "fluent" like uniform updates
  14040. */
  14041. setFloats(name: string, value: number[]): ProceduralTexture;
  14042. /**
  14043. * Set a vec3 in the shader from a Color3.
  14044. * @param name Define the name of the uniform as defined in the shader
  14045. * @param value Define the value to give to the uniform
  14046. * @return the texture itself allowing "fluent" like uniform updates
  14047. */
  14048. setColor3(name: string, value: Color3): ProceduralTexture;
  14049. /**
  14050. * Set a vec4 in the shader from a Color4.
  14051. * @param name Define the name of the uniform as defined in the shader
  14052. * @param value Define the value to give to the uniform
  14053. * @return the texture itself allowing "fluent" like uniform updates
  14054. */
  14055. setColor4(name: string, value: Color4): ProceduralTexture;
  14056. /**
  14057. * Set a vec2 in the shader from a Vector2.
  14058. * @param name Define the name of the uniform as defined in the shader
  14059. * @param value Define the value to give to the uniform
  14060. * @return the texture itself allowing "fluent" like uniform updates
  14061. */
  14062. setVector2(name: string, value: Vector2): ProceduralTexture;
  14063. /**
  14064. * Set a vec3 in the shader from a Vector3.
  14065. * @param name Define the name of the uniform as defined in the shader
  14066. * @param value Define the value to give to the uniform
  14067. * @return the texture itself allowing "fluent" like uniform updates
  14068. */
  14069. setVector3(name: string, value: Vector3): ProceduralTexture;
  14070. /**
  14071. * Set a mat4 in the shader from a MAtrix.
  14072. * @param name Define the name of the uniform as defined in the shader
  14073. * @param value Define the value to give to the uniform
  14074. * @return the texture itself allowing "fluent" like uniform updates
  14075. */
  14076. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14077. /**
  14078. * Render the texture to its associated render target.
  14079. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14080. */
  14081. render(useCameraPostProcess?: boolean): void;
  14082. /**
  14083. * Clone the texture.
  14084. * @returns the cloned texture
  14085. */
  14086. clone(): ProceduralTexture;
  14087. /**
  14088. * Dispose the texture and release its asoociated resources.
  14089. */
  14090. dispose(): void;
  14091. }
  14092. }
  14093. declare module "babylonjs/Particles/baseParticleSystem" {
  14094. import { Nullable } from "babylonjs/types";
  14095. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14097. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14098. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14099. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14100. import { Scene } from "babylonjs/scene";
  14101. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14102. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14103. import { Texture } from "babylonjs/Materials/Textures/texture";
  14104. import { Animation } from "babylonjs/Animations/animation";
  14105. /**
  14106. * This represents the base class for particle system in Babylon.
  14107. * 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.
  14108. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14109. * @example https://doc.babylonjs.com/babylon101/particles
  14110. */
  14111. export class BaseParticleSystem {
  14112. /**
  14113. * Source color is added to the destination color without alpha affecting the result
  14114. */
  14115. static BLENDMODE_ONEONE: number;
  14116. /**
  14117. * Blend current color and particle color using particle’s alpha
  14118. */
  14119. static BLENDMODE_STANDARD: number;
  14120. /**
  14121. * Add current color and particle color multiplied by particle’s alpha
  14122. */
  14123. static BLENDMODE_ADD: number;
  14124. /**
  14125. * Multiply current color with particle color
  14126. */
  14127. static BLENDMODE_MULTIPLY: number;
  14128. /**
  14129. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14130. */
  14131. static BLENDMODE_MULTIPLYADD: number;
  14132. /**
  14133. * List of animations used by the particle system.
  14134. */
  14135. animations: Animation[];
  14136. /**
  14137. * The id of the Particle system.
  14138. */
  14139. id: string;
  14140. /**
  14141. * The friendly name of the Particle system.
  14142. */
  14143. name: string;
  14144. /**
  14145. * The rendering group used by the Particle system to chose when to render.
  14146. */
  14147. renderingGroupId: number;
  14148. /**
  14149. * The emitter represents the Mesh or position we are attaching the particle system to.
  14150. */
  14151. emitter: Nullable<AbstractMesh | Vector3>;
  14152. /**
  14153. * The maximum number of particles to emit per frame
  14154. */
  14155. emitRate: number;
  14156. /**
  14157. * If you want to launch only a few particles at once, that can be done, as well.
  14158. */
  14159. manualEmitCount: number;
  14160. /**
  14161. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14162. */
  14163. updateSpeed: number;
  14164. /**
  14165. * The amount of time the particle system is running (depends of the overall update speed).
  14166. */
  14167. targetStopDuration: number;
  14168. /**
  14169. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14170. */
  14171. disposeOnStop: boolean;
  14172. /**
  14173. * Minimum power of emitting particles.
  14174. */
  14175. minEmitPower: number;
  14176. /**
  14177. * Maximum power of emitting particles.
  14178. */
  14179. maxEmitPower: number;
  14180. /**
  14181. * Minimum life time of emitting particles.
  14182. */
  14183. minLifeTime: number;
  14184. /**
  14185. * Maximum life time of emitting particles.
  14186. */
  14187. maxLifeTime: number;
  14188. /**
  14189. * Minimum Size of emitting particles.
  14190. */
  14191. minSize: number;
  14192. /**
  14193. * Maximum Size of emitting particles.
  14194. */
  14195. maxSize: number;
  14196. /**
  14197. * Minimum scale of emitting particles on X axis.
  14198. */
  14199. minScaleX: number;
  14200. /**
  14201. * Maximum scale of emitting particles on X axis.
  14202. */
  14203. maxScaleX: number;
  14204. /**
  14205. * Minimum scale of emitting particles on Y axis.
  14206. */
  14207. minScaleY: number;
  14208. /**
  14209. * Maximum scale of emitting particles on Y axis.
  14210. */
  14211. maxScaleY: number;
  14212. /**
  14213. * Gets or sets the minimal initial rotation in radians.
  14214. */
  14215. minInitialRotation: number;
  14216. /**
  14217. * Gets or sets the maximal initial rotation in radians.
  14218. */
  14219. maxInitialRotation: number;
  14220. /**
  14221. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14222. */
  14223. minAngularSpeed: number;
  14224. /**
  14225. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14226. */
  14227. maxAngularSpeed: number;
  14228. /**
  14229. * The texture used to render each particle. (this can be a spritesheet)
  14230. */
  14231. particleTexture: Nullable<Texture>;
  14232. /**
  14233. * The layer mask we are rendering the particles through.
  14234. */
  14235. layerMask: number;
  14236. /**
  14237. * This can help using your own shader to render the particle system.
  14238. * The according effect will be created
  14239. */
  14240. customShader: any;
  14241. /**
  14242. * By default particle system starts as soon as they are created. This prevents the
  14243. * automatic start to happen and let you decide when to start emitting particles.
  14244. */
  14245. preventAutoStart: boolean;
  14246. private _noiseTexture;
  14247. /**
  14248. * Gets or sets a texture used to add random noise to particle positions
  14249. */
  14250. noiseTexture: Nullable<ProceduralTexture>;
  14251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14252. noiseStrength: Vector3;
  14253. /**
  14254. * Callback triggered when the particle animation is ending.
  14255. */
  14256. onAnimationEnd: Nullable<() => void>;
  14257. /**
  14258. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14259. */
  14260. blendMode: number;
  14261. /**
  14262. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14263. * to override the particles.
  14264. */
  14265. forceDepthWrite: boolean;
  14266. /** 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 */
  14267. preWarmCycles: number;
  14268. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14269. preWarmStepOffset: number;
  14270. /**
  14271. * 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)
  14272. */
  14273. spriteCellChangeSpeed: number;
  14274. /**
  14275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14276. */
  14277. startSpriteCellID: number;
  14278. /**
  14279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14280. */
  14281. endSpriteCellID: number;
  14282. /**
  14283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14284. */
  14285. spriteCellWidth: number;
  14286. /**
  14287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14288. */
  14289. spriteCellHeight: number;
  14290. /**
  14291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14292. */
  14293. spriteRandomStartCell: boolean;
  14294. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14295. translationPivot: Vector2;
  14296. /** @hidden */
  14297. protected _isAnimationSheetEnabled: boolean;
  14298. /**
  14299. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14300. */
  14301. beginAnimationOnStart: boolean;
  14302. /**
  14303. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14304. */
  14305. beginAnimationFrom: number;
  14306. /**
  14307. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14308. */
  14309. beginAnimationTo: number;
  14310. /**
  14311. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14312. */
  14313. beginAnimationLoop: boolean;
  14314. /**
  14315. * Gets or sets a world offset applied to all particles
  14316. */
  14317. worldOffset: Vector3;
  14318. /**
  14319. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14320. */
  14321. isAnimationSheetEnabled: boolean;
  14322. /**
  14323. * Get hosting scene
  14324. * @returns the scene
  14325. */
  14326. getScene(): Scene;
  14327. /**
  14328. * You can use gravity if you want to give an orientation to your particles.
  14329. */
  14330. gravity: Vector3;
  14331. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14332. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14334. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14335. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14337. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14338. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14339. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14340. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14341. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14343. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14344. /**
  14345. * Defines the delay in milliseconds before starting the system (0 by default)
  14346. */
  14347. startDelay: number;
  14348. /**
  14349. * Gets the current list of drag gradients.
  14350. * You must use addDragGradient and removeDragGradient to udpate this list
  14351. * @returns the list of drag gradients
  14352. */
  14353. getDragGradients(): Nullable<Array<FactorGradient>>;
  14354. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14355. limitVelocityDamping: number;
  14356. /**
  14357. * Gets the current list of limit velocity gradients.
  14358. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14359. * @returns the list of limit velocity gradients
  14360. */
  14361. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of color gradients.
  14364. * You must use addColorGradient and removeColorGradient to udpate this list
  14365. * @returns the list of color gradients
  14366. */
  14367. getColorGradients(): Nullable<Array<ColorGradient>>;
  14368. /**
  14369. * Gets the current list of size gradients.
  14370. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14371. * @returns the list of size gradients
  14372. */
  14373. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of color remap gradients.
  14376. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14377. * @returns the list of color remap gradients
  14378. */
  14379. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Gets the current list of alpha remap gradients.
  14382. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14383. * @returns the list of alpha remap gradients
  14384. */
  14385. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Gets the current list of life time gradients.
  14388. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14389. * @returns the list of life time gradients
  14390. */
  14391. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Gets the current list of angular speed gradients.
  14394. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14395. * @returns the list of angular speed gradients
  14396. */
  14397. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14398. /**
  14399. * Gets the current list of velocity gradients.
  14400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14401. * @returns the list of velocity gradients
  14402. */
  14403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Gets the current list of start size gradients.
  14406. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14407. * @returns the list of start size gradients
  14408. */
  14409. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14410. /**
  14411. * Gets the current list of emit rate gradients.
  14412. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14413. * @returns the list of emit rate gradients
  14414. */
  14415. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14416. /**
  14417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14418. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14419. */
  14420. direction1: Vector3;
  14421. /**
  14422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14424. */
  14425. direction2: Vector3;
  14426. /**
  14427. * 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.
  14428. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14429. */
  14430. minEmitBox: Vector3;
  14431. /**
  14432. * 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.
  14433. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14434. */
  14435. maxEmitBox: Vector3;
  14436. /**
  14437. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14438. */
  14439. color1: Color4;
  14440. /**
  14441. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14442. */
  14443. color2: Color4;
  14444. /**
  14445. * Color the particle will have at the end of its lifetime
  14446. */
  14447. colorDead: Color4;
  14448. /**
  14449. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14450. */
  14451. textureMask: Color4;
  14452. /**
  14453. * The particle emitter type defines the emitter used by the particle system.
  14454. * It can be for example box, sphere, or cone...
  14455. */
  14456. particleEmitterType: IParticleEmitterType;
  14457. /** @hidden */
  14458. _isSubEmitter: boolean;
  14459. /**
  14460. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14461. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14462. */
  14463. billboardMode: number;
  14464. protected _isBillboardBased: boolean;
  14465. /**
  14466. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14467. */
  14468. isBillboardBased: boolean;
  14469. /**
  14470. * The scene the particle system belongs to.
  14471. */
  14472. protected _scene: Scene;
  14473. /**
  14474. * Local cache of defines for image processing.
  14475. */
  14476. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14477. /**
  14478. * Default configuration related to image processing available in the standard Material.
  14479. */
  14480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14481. /**
  14482. * Gets the image processing configuration used either in this material.
  14483. */
  14484. /**
  14485. * Sets the Default image processing configuration used either in the this material.
  14486. *
  14487. * If sets to null, the scene one is in use.
  14488. */
  14489. imageProcessingConfiguration: ImageProcessingConfiguration;
  14490. /**
  14491. * Attaches a new image processing configuration to the Standard Material.
  14492. * @param configuration
  14493. */
  14494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14495. /** @hidden */
  14496. protected _reset(): void;
  14497. /** @hidden */
  14498. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14499. /**
  14500. * Instantiates a particle system.
  14501. * 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.
  14502. * @param name The name of the particle system
  14503. */
  14504. constructor(name: string);
  14505. /**
  14506. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14509. * @returns the emitter
  14510. */
  14511. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14512. /**
  14513. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14514. * @param radius The radius of the hemisphere to emit from
  14515. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14516. * @returns the emitter
  14517. */
  14518. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14519. /**
  14520. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14521. * @param radius The radius of the sphere to emit from
  14522. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14523. * @returns the emitter
  14524. */
  14525. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14526. /**
  14527. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14528. * @param radius The radius of the sphere to emit from
  14529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14531. * @returns the emitter
  14532. */
  14533. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14534. /**
  14535. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14536. * @param radius The radius of the emission cylinder
  14537. * @param height The height of the emission cylinder
  14538. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14539. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14540. * @returns the emitter
  14541. */
  14542. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14543. /**
  14544. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14545. * @param radius The radius of the cylinder to emit from
  14546. * @param height The height of the emission cylinder
  14547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14550. * @returns the emitter
  14551. */
  14552. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14553. /**
  14554. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14555. * @param radius The radius of the cone to emit from
  14556. * @param angle The base angle of the cone
  14557. * @returns the emitter
  14558. */
  14559. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14560. /**
  14561. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14564. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14566. * @returns the emitter
  14567. */
  14568. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14569. }
  14570. }
  14571. declare module "babylonjs/Particles/subEmitter" {
  14572. import { Scene } from "babylonjs/scene";
  14573. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14574. /**
  14575. * Type of sub emitter
  14576. */
  14577. export enum SubEmitterType {
  14578. /**
  14579. * Attached to the particle over it's lifetime
  14580. */
  14581. ATTACHED = 0,
  14582. /**
  14583. * Created when the particle dies
  14584. */
  14585. END = 1
  14586. }
  14587. /**
  14588. * Sub emitter class used to emit particles from an existing particle
  14589. */
  14590. export class SubEmitter {
  14591. /**
  14592. * the particle system to be used by the sub emitter
  14593. */
  14594. particleSystem: ParticleSystem;
  14595. /**
  14596. * Type of the submitter (Default: END)
  14597. */
  14598. type: SubEmitterType;
  14599. /**
  14600. * 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)
  14601. * Note: This only is supported when using an emitter of type Mesh
  14602. */
  14603. inheritDirection: boolean;
  14604. /**
  14605. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14606. */
  14607. inheritedVelocityAmount: number;
  14608. /**
  14609. * Creates a sub emitter
  14610. * @param particleSystem the particle system to be used by the sub emitter
  14611. */
  14612. constructor(
  14613. /**
  14614. * the particle system to be used by the sub emitter
  14615. */
  14616. particleSystem: ParticleSystem);
  14617. /**
  14618. * Clones the sub emitter
  14619. * @returns the cloned sub emitter
  14620. */
  14621. clone(): SubEmitter;
  14622. /**
  14623. * Serialize current object to a JSON object
  14624. * @returns the serialized object
  14625. */
  14626. serialize(): any;
  14627. /** @hidden */
  14628. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14629. /**
  14630. * Creates a new SubEmitter from a serialized JSON version
  14631. * @param serializationObject defines the JSON object to read from
  14632. * @param scene defines the hosting scene
  14633. * @param rootUrl defines the rootUrl for data loading
  14634. * @returns a new SubEmitter
  14635. */
  14636. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14637. /** Release associated resources */
  14638. dispose(): void;
  14639. }
  14640. }
  14641. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14642. /** @hidden */
  14643. export var clipPlaneFragmentDeclaration: {
  14644. name: string;
  14645. shader: string;
  14646. };
  14647. }
  14648. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14649. /** @hidden */
  14650. export var imageProcessingDeclaration: {
  14651. name: string;
  14652. shader: string;
  14653. };
  14654. }
  14655. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14656. /** @hidden */
  14657. export var imageProcessingFunctions: {
  14658. name: string;
  14659. shader: string;
  14660. };
  14661. }
  14662. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14663. /** @hidden */
  14664. export var clipPlaneFragment: {
  14665. name: string;
  14666. shader: string;
  14667. };
  14668. }
  14669. declare module "babylonjs/Shaders/particles.fragment" {
  14670. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14671. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14673. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14674. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14675. /** @hidden */
  14676. export var particlesPixelShader: {
  14677. name: string;
  14678. shader: string;
  14679. };
  14680. }
  14681. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14682. /** @hidden */
  14683. export var clipPlaneVertexDeclaration: {
  14684. name: string;
  14685. shader: string;
  14686. };
  14687. }
  14688. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14689. /** @hidden */
  14690. export var clipPlaneVertex: {
  14691. name: string;
  14692. shader: string;
  14693. };
  14694. }
  14695. declare module "babylonjs/Shaders/particles.vertex" {
  14696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14697. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14698. /** @hidden */
  14699. export var particlesVertexShader: {
  14700. name: string;
  14701. shader: string;
  14702. };
  14703. }
  14704. declare module "babylonjs/Particles/particleSystem" {
  14705. import { Nullable } from "babylonjs/types";
  14706. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14707. import { Observable } from "babylonjs/Misc/observable";
  14708. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14709. import { Effect } from "babylonjs/Materials/effect";
  14710. import { Scene, IDisposable } from "babylonjs/scene";
  14711. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14712. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14713. import { Particle } from "babylonjs/Particles/particle";
  14714. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14715. import "babylonjs/Shaders/particles.fragment";
  14716. import "babylonjs/Shaders/particles.vertex";
  14717. /**
  14718. * This represents a particle system in Babylon.
  14719. * 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.
  14720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14721. * @example https://doc.babylonjs.com/babylon101/particles
  14722. */
  14723. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14724. /**
  14725. * Billboard mode will only apply to Y axis
  14726. */
  14727. static readonly BILLBOARDMODE_Y: number;
  14728. /**
  14729. * Billboard mode will apply to all axes
  14730. */
  14731. static readonly BILLBOARDMODE_ALL: number;
  14732. /**
  14733. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14734. */
  14735. static readonly BILLBOARDMODE_STRETCHED: number;
  14736. /**
  14737. * This function can be defined to provide custom update for active particles.
  14738. * This function will be called instead of regular update (age, position, color, etc.).
  14739. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14740. */
  14741. updateFunction: (particles: Particle[]) => void;
  14742. private _emitterWorldMatrix;
  14743. /**
  14744. * This function can be defined to specify initial direction for every new particle.
  14745. * It by default use the emitterType defined function
  14746. */
  14747. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14748. /**
  14749. * This function can be defined to specify initial position for every new particle.
  14750. * It by default use the emitterType defined function
  14751. */
  14752. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14753. /**
  14754. * @hidden
  14755. */
  14756. _inheritedVelocityOffset: Vector3;
  14757. /**
  14758. * An event triggered when the system is disposed
  14759. */
  14760. onDisposeObservable: Observable<ParticleSystem>;
  14761. private _onDisposeObserver;
  14762. /**
  14763. * Sets a callback that will be triggered when the system is disposed
  14764. */
  14765. onDispose: () => void;
  14766. private _particles;
  14767. private _epsilon;
  14768. private _capacity;
  14769. private _stockParticles;
  14770. private _newPartsExcess;
  14771. private _vertexData;
  14772. private _vertexBuffer;
  14773. private _vertexBuffers;
  14774. private _spriteBuffer;
  14775. private _indexBuffer;
  14776. private _effect;
  14777. private _customEffect;
  14778. private _cachedDefines;
  14779. private _scaledColorStep;
  14780. private _colorDiff;
  14781. private _scaledDirection;
  14782. private _scaledGravity;
  14783. private _currentRenderId;
  14784. private _alive;
  14785. private _useInstancing;
  14786. private _started;
  14787. private _stopped;
  14788. private _actualFrame;
  14789. private _scaledUpdateSpeed;
  14790. private _vertexBufferSize;
  14791. /** @hidden */
  14792. _currentEmitRateGradient: Nullable<FactorGradient>;
  14793. /** @hidden */
  14794. _currentEmitRate1: number;
  14795. /** @hidden */
  14796. _currentEmitRate2: number;
  14797. /** @hidden */
  14798. _currentStartSizeGradient: Nullable<FactorGradient>;
  14799. /** @hidden */
  14800. _currentStartSize1: number;
  14801. /** @hidden */
  14802. _currentStartSize2: number;
  14803. private readonly _rawTextureWidth;
  14804. private _rampGradientsTexture;
  14805. private _useRampGradients;
  14806. /** Gets or sets a boolean indicating that ramp gradients must be used
  14807. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14808. */
  14809. useRampGradients: boolean;
  14810. /**
  14811. * 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.
  14812. * 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: [])
  14813. */
  14814. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14815. private _subEmitters;
  14816. /**
  14817. * @hidden
  14818. * If the particle systems emitter should be disposed when the particle system is disposed
  14819. */
  14820. _disposeEmitterOnDispose: boolean;
  14821. /**
  14822. * The current active Sub-systems, this property is used by the root particle system only.
  14823. */
  14824. activeSubSystems: Array<ParticleSystem>;
  14825. private _rootParticleSystem;
  14826. /**
  14827. * Gets the current list of active particles
  14828. */
  14829. readonly particles: Particle[];
  14830. /**
  14831. * Returns the string "ParticleSystem"
  14832. * @returns a string containing the class name
  14833. */
  14834. getClassName(): string;
  14835. /**
  14836. * Instantiates a particle system.
  14837. * 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.
  14838. * @param name The name of the particle system
  14839. * @param capacity The max number of particles alive at the same time
  14840. * @param scene The scene the particle system belongs to
  14841. * @param customEffect a custom effect used to change the way particles are rendered by default
  14842. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14843. * @param epsilon Offset used to render the particles
  14844. */
  14845. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14846. private _addFactorGradient;
  14847. private _removeFactorGradient;
  14848. /**
  14849. * Adds a new life time gradient
  14850. * @param gradient defines the gradient to use (between 0 and 1)
  14851. * @param factor defines the life time factor to affect to the specified gradient
  14852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14853. * @returns the current particle system
  14854. */
  14855. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14856. /**
  14857. * Remove a specific life time gradient
  14858. * @param gradient defines the gradient to remove
  14859. * @returns the current particle system
  14860. */
  14861. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14862. /**
  14863. * Adds a new size gradient
  14864. * @param gradient defines the gradient to use (between 0 and 1)
  14865. * @param factor defines the size factor to affect to the specified gradient
  14866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14867. * @returns the current particle system
  14868. */
  14869. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14870. /**
  14871. * Remove a specific size gradient
  14872. * @param gradient defines the gradient to remove
  14873. * @returns the current particle system
  14874. */
  14875. removeSizeGradient(gradient: number): IParticleSystem;
  14876. /**
  14877. * Adds a new color remap gradient
  14878. * @param gradient defines the gradient to use (between 0 and 1)
  14879. * @param min defines the color remap minimal range
  14880. * @param max defines the color remap maximal range
  14881. * @returns the current particle system
  14882. */
  14883. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14884. /**
  14885. * Remove a specific color remap gradient
  14886. * @param gradient defines the gradient to remove
  14887. * @returns the current particle system
  14888. */
  14889. removeColorRemapGradient(gradient: number): IParticleSystem;
  14890. /**
  14891. * Adds a new alpha remap gradient
  14892. * @param gradient defines the gradient to use (between 0 and 1)
  14893. * @param min defines the alpha remap minimal range
  14894. * @param max defines the alpha remap maximal range
  14895. * @returns the current particle system
  14896. */
  14897. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14898. /**
  14899. * Remove a specific alpha remap gradient
  14900. * @param gradient defines the gradient to remove
  14901. * @returns the current particle system
  14902. */
  14903. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14904. /**
  14905. * Adds a new angular speed gradient
  14906. * @param gradient defines the gradient to use (between 0 and 1)
  14907. * @param factor defines the angular speed to affect to the specified gradient
  14908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14909. * @returns the current particle system
  14910. */
  14911. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14912. /**
  14913. * Remove a specific angular speed gradient
  14914. * @param gradient defines the gradient to remove
  14915. * @returns the current particle system
  14916. */
  14917. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14918. /**
  14919. * Adds a new velocity gradient
  14920. * @param gradient defines the gradient to use (between 0 and 1)
  14921. * @param factor defines the velocity to affect to the specified gradient
  14922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14923. * @returns the current particle system
  14924. */
  14925. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14926. /**
  14927. * Remove a specific velocity gradient
  14928. * @param gradient defines the gradient to remove
  14929. * @returns the current particle system
  14930. */
  14931. removeVelocityGradient(gradient: number): IParticleSystem;
  14932. /**
  14933. * Adds a new limit velocity gradient
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param factor defines the limit velocity value to affect to the specified gradient
  14936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14937. * @returns the current particle system
  14938. */
  14939. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14940. /**
  14941. * Remove a specific limit velocity gradient
  14942. * @param gradient defines the gradient to remove
  14943. * @returns the current particle system
  14944. */
  14945. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14946. /**
  14947. * Adds a new drag gradient
  14948. * @param gradient defines the gradient to use (between 0 and 1)
  14949. * @param factor defines the drag value to affect to the specified gradient
  14950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14951. * @returns the current particle system
  14952. */
  14953. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14954. /**
  14955. * Remove a specific drag gradient
  14956. * @param gradient defines the gradient to remove
  14957. * @returns the current particle system
  14958. */
  14959. removeDragGradient(gradient: number): IParticleSystem;
  14960. /**
  14961. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14962. * @param gradient defines the gradient to use (between 0 and 1)
  14963. * @param factor defines the emit rate value to affect to the specified gradient
  14964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14965. * @returns the current particle system
  14966. */
  14967. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14968. /**
  14969. * Remove a specific emit rate gradient
  14970. * @param gradient defines the gradient to remove
  14971. * @returns the current particle system
  14972. */
  14973. removeEmitRateGradient(gradient: number): IParticleSystem;
  14974. /**
  14975. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param factor defines the start size value to affect to the specified gradient
  14978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14979. * @returns the current particle system
  14980. */
  14981. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14982. /**
  14983. * Remove a specific start size gradient
  14984. * @param gradient defines the gradient to remove
  14985. * @returns the current particle system
  14986. */
  14987. removeStartSizeGradient(gradient: number): IParticleSystem;
  14988. private _createRampGradientTexture;
  14989. /**
  14990. * Gets the current list of ramp gradients.
  14991. * You must use addRampGradient and removeRampGradient to udpate this list
  14992. * @returns the list of ramp gradients
  14993. */
  14994. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14995. /**
  14996. * Adds a new ramp gradient used to remap particle colors
  14997. * @param gradient defines the gradient to use (between 0 and 1)
  14998. * @param color defines the color to affect to the specified gradient
  14999. * @returns the current particle system
  15000. */
  15001. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15002. /**
  15003. * Remove a specific ramp gradient
  15004. * @param gradient defines the gradient to remove
  15005. * @returns the current particle system
  15006. */
  15007. removeRampGradient(gradient: number): ParticleSystem;
  15008. /**
  15009. * Adds a new color gradient
  15010. * @param gradient defines the gradient to use (between 0 and 1)
  15011. * @param color1 defines the color to affect to the specified gradient
  15012. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15013. * @returns this particle system
  15014. */
  15015. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15016. /**
  15017. * Remove a specific color gradient
  15018. * @param gradient defines the gradient to remove
  15019. * @returns this particle system
  15020. */
  15021. removeColorGradient(gradient: number): IParticleSystem;
  15022. private _fetchR;
  15023. protected _reset(): void;
  15024. private _resetEffect;
  15025. private _createVertexBuffers;
  15026. private _createIndexBuffer;
  15027. /**
  15028. * Gets the maximum number of particles active at the same time.
  15029. * @returns The max number of active particles.
  15030. */
  15031. getCapacity(): number;
  15032. /**
  15033. * Gets whether there are still active particles in the system.
  15034. * @returns True if it is alive, otherwise false.
  15035. */
  15036. isAlive(): boolean;
  15037. /**
  15038. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15039. * @returns True if it has been started, otherwise false.
  15040. */
  15041. isStarted(): boolean;
  15042. private _prepareSubEmitterInternalArray;
  15043. /**
  15044. * Starts the particle system and begins to emit
  15045. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15046. */
  15047. start(delay?: number): void;
  15048. /**
  15049. * Stops the particle system.
  15050. * @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.
  15051. */
  15052. stop(stopSubEmitters?: boolean): void;
  15053. /**
  15054. * Remove all active particles
  15055. */
  15056. reset(): void;
  15057. /**
  15058. * @hidden (for internal use only)
  15059. */
  15060. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15061. /**
  15062. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15063. * Its lifetime will start back at 0.
  15064. */
  15065. recycleParticle: (particle: Particle) => void;
  15066. private _stopSubEmitters;
  15067. private _createParticle;
  15068. private _removeFromRoot;
  15069. private _emitFromParticle;
  15070. private _update;
  15071. /** @hidden */
  15072. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15073. /** @hidden */
  15074. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15075. /** @hidden */
  15076. private _getEffect;
  15077. /**
  15078. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15079. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15080. */
  15081. animate(preWarmOnly?: boolean): void;
  15082. private _appendParticleVertices;
  15083. /**
  15084. * Rebuilds the particle system.
  15085. */
  15086. rebuild(): void;
  15087. /**
  15088. * Is this system ready to be used/rendered
  15089. * @return true if the system is ready
  15090. */
  15091. isReady(): boolean;
  15092. private _render;
  15093. /**
  15094. * Renders the particle system in its current state.
  15095. * @returns the current number of particles
  15096. */
  15097. render(): number;
  15098. /**
  15099. * Disposes the particle system and free the associated resources
  15100. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15101. */
  15102. dispose(disposeTexture?: boolean): void;
  15103. /**
  15104. * Clones the particle system.
  15105. * @param name The name of the cloned object
  15106. * @param newEmitter The new emitter to use
  15107. * @returns the cloned particle system
  15108. */
  15109. clone(name: string, newEmitter: any): ParticleSystem;
  15110. /**
  15111. * Serializes the particle system to a JSON object.
  15112. * @returns the JSON object
  15113. */
  15114. serialize(): any;
  15115. /** @hidden */
  15116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15117. /** @hidden */
  15118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15119. /**
  15120. * Parses a JSON object to create a particle system.
  15121. * @param parsedParticleSystem The JSON object to parse
  15122. * @param scene The scene to create the particle system in
  15123. * @param rootUrl The root url to use to load external dependencies like texture
  15124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15125. * @returns the Parsed particle system
  15126. */
  15127. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15128. }
  15129. }
  15130. declare module "babylonjs/Particles/particle" {
  15131. import { Nullable } from "babylonjs/types";
  15132. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15133. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15134. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15135. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15136. /**
  15137. * A particle represents one of the element emitted by a particle system.
  15138. * This is mainly define by its coordinates, direction, velocity and age.
  15139. */
  15140. export class Particle {
  15141. /**
  15142. * The particle system the particle belongs to.
  15143. */
  15144. particleSystem: ParticleSystem;
  15145. private static _Count;
  15146. /**
  15147. * Unique ID of the particle
  15148. */
  15149. id: number;
  15150. /**
  15151. * The world position of the particle in the scene.
  15152. */
  15153. position: Vector3;
  15154. /**
  15155. * The world direction of the particle in the scene.
  15156. */
  15157. direction: Vector3;
  15158. /**
  15159. * The color of the particle.
  15160. */
  15161. color: Color4;
  15162. /**
  15163. * The color change of the particle per step.
  15164. */
  15165. colorStep: Color4;
  15166. /**
  15167. * Defines how long will the life of the particle be.
  15168. */
  15169. lifeTime: number;
  15170. /**
  15171. * The current age of the particle.
  15172. */
  15173. age: number;
  15174. /**
  15175. * The current size of the particle.
  15176. */
  15177. size: number;
  15178. /**
  15179. * The current scale of the particle.
  15180. */
  15181. scale: Vector2;
  15182. /**
  15183. * The current angle of the particle.
  15184. */
  15185. angle: number;
  15186. /**
  15187. * Defines how fast is the angle changing.
  15188. */
  15189. angularSpeed: number;
  15190. /**
  15191. * Defines the cell index used by the particle to be rendered from a sprite.
  15192. */
  15193. cellIndex: number;
  15194. /**
  15195. * The information required to support color remapping
  15196. */
  15197. remapData: Vector4;
  15198. /** @hidden */
  15199. _randomCellOffset?: number;
  15200. /** @hidden */
  15201. _initialDirection: Nullable<Vector3>;
  15202. /** @hidden */
  15203. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15204. /** @hidden */
  15205. _initialStartSpriteCellID: number;
  15206. /** @hidden */
  15207. _initialEndSpriteCellID: number;
  15208. /** @hidden */
  15209. _currentColorGradient: Nullable<ColorGradient>;
  15210. /** @hidden */
  15211. _currentColor1: Color4;
  15212. /** @hidden */
  15213. _currentColor2: Color4;
  15214. /** @hidden */
  15215. _currentSizeGradient: Nullable<FactorGradient>;
  15216. /** @hidden */
  15217. _currentSize1: number;
  15218. /** @hidden */
  15219. _currentSize2: number;
  15220. /** @hidden */
  15221. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15222. /** @hidden */
  15223. _currentAngularSpeed1: number;
  15224. /** @hidden */
  15225. _currentAngularSpeed2: number;
  15226. /** @hidden */
  15227. _currentVelocityGradient: Nullable<FactorGradient>;
  15228. /** @hidden */
  15229. _currentVelocity1: number;
  15230. /** @hidden */
  15231. _currentVelocity2: number;
  15232. /** @hidden */
  15233. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15234. /** @hidden */
  15235. _currentLimitVelocity1: number;
  15236. /** @hidden */
  15237. _currentLimitVelocity2: number;
  15238. /** @hidden */
  15239. _currentDragGradient: Nullable<FactorGradient>;
  15240. /** @hidden */
  15241. _currentDrag1: number;
  15242. /** @hidden */
  15243. _currentDrag2: number;
  15244. /** @hidden */
  15245. _randomNoiseCoordinates1: Vector3;
  15246. /** @hidden */
  15247. _randomNoiseCoordinates2: Vector3;
  15248. /**
  15249. * Creates a new instance Particle
  15250. * @param particleSystem the particle system the particle belongs to
  15251. */
  15252. constructor(
  15253. /**
  15254. * The particle system the particle belongs to.
  15255. */
  15256. particleSystem: ParticleSystem);
  15257. private updateCellInfoFromSystem;
  15258. /**
  15259. * Defines how the sprite cell index is updated for the particle
  15260. */
  15261. updateCellIndex(): void;
  15262. /** @hidden */
  15263. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15264. /** @hidden */
  15265. _inheritParticleInfoToSubEmitters(): void;
  15266. /** @hidden */
  15267. _reset(): void;
  15268. /**
  15269. * Copy the properties of particle to another one.
  15270. * @param other the particle to copy the information to.
  15271. */
  15272. copyTo(other: Particle): void;
  15273. }
  15274. }
  15275. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15276. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15277. import { Effect } from "babylonjs/Materials/effect";
  15278. import { Particle } from "babylonjs/Particles/particle";
  15279. /**
  15280. * Particle emitter represents a volume emitting particles.
  15281. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15282. */
  15283. export interface IParticleEmitterType {
  15284. /**
  15285. * Called by the particle System when the direction is computed for the created particle.
  15286. * @param worldMatrix is the world matrix of the particle system
  15287. * @param directionToUpdate is the direction vector to update with the result
  15288. * @param particle is the particle we are computed the direction for
  15289. */
  15290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15291. /**
  15292. * Called by the particle System when the position is computed for the created particle.
  15293. * @param worldMatrix is the world matrix of the particle system
  15294. * @param positionToUpdate is the position vector to update with the result
  15295. * @param particle is the particle we are computed the position for
  15296. */
  15297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15298. /**
  15299. * Clones the current emitter and returns a copy of it
  15300. * @returns the new emitter
  15301. */
  15302. clone(): IParticleEmitterType;
  15303. /**
  15304. * Called by the GPUParticleSystem to setup the update shader
  15305. * @param effect defines the update shader
  15306. */
  15307. applyToShader(effect: Effect): void;
  15308. /**
  15309. * Returns a string to use to update the GPU particles update shader
  15310. * @returns the effect defines string
  15311. */
  15312. getEffectDefines(): string;
  15313. /**
  15314. * Returns a string representing the class name
  15315. * @returns a string containing the class name
  15316. */
  15317. getClassName(): string;
  15318. /**
  15319. * Serializes the particle system to a JSON object.
  15320. * @returns the JSON object
  15321. */
  15322. serialize(): any;
  15323. /**
  15324. * Parse properties from a JSON object
  15325. * @param serializationObject defines the JSON object
  15326. */
  15327. parse(serializationObject: any): void;
  15328. }
  15329. }
  15330. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15331. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15332. import { Effect } from "babylonjs/Materials/effect";
  15333. import { Particle } from "babylonjs/Particles/particle";
  15334. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15335. /**
  15336. * Particle emitter emitting particles from the inside of a box.
  15337. * It emits the particles randomly between 2 given directions.
  15338. */
  15339. export class BoxParticleEmitter implements IParticleEmitterType {
  15340. /**
  15341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15342. */
  15343. direction1: Vector3;
  15344. /**
  15345. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15346. */
  15347. direction2: Vector3;
  15348. /**
  15349. * 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.
  15350. */
  15351. minEmitBox: Vector3;
  15352. /**
  15353. * 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.
  15354. */
  15355. maxEmitBox: Vector3;
  15356. /**
  15357. * Creates a new instance BoxParticleEmitter
  15358. */
  15359. constructor();
  15360. /**
  15361. * Called by the particle System when the direction is computed for the created particle.
  15362. * @param worldMatrix is the world matrix of the particle system
  15363. * @param directionToUpdate is the direction vector to update with the result
  15364. * @param particle is the particle we are computed the direction for
  15365. */
  15366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15367. /**
  15368. * Called by the particle System when the position is computed for the created particle.
  15369. * @param worldMatrix is the world matrix of the particle system
  15370. * @param positionToUpdate is the position vector to update with the result
  15371. * @param particle is the particle we are computed the position for
  15372. */
  15373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15374. /**
  15375. * Clones the current emitter and returns a copy of it
  15376. * @returns the new emitter
  15377. */
  15378. clone(): BoxParticleEmitter;
  15379. /**
  15380. * Called by the GPUParticleSystem to setup the update shader
  15381. * @param effect defines the update shader
  15382. */
  15383. applyToShader(effect: Effect): void;
  15384. /**
  15385. * Returns a string to use to update the GPU particles update shader
  15386. * @returns a string containng the defines string
  15387. */
  15388. getEffectDefines(): string;
  15389. /**
  15390. * Returns the string "BoxParticleEmitter"
  15391. * @returns a string containing the class name
  15392. */
  15393. getClassName(): string;
  15394. /**
  15395. * Serializes the particle system to a JSON object.
  15396. * @returns the JSON object
  15397. */
  15398. serialize(): any;
  15399. /**
  15400. * Parse properties from a JSON object
  15401. * @param serializationObject defines the JSON object
  15402. */
  15403. parse(serializationObject: any): void;
  15404. }
  15405. }
  15406. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15407. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15408. import { Effect } from "babylonjs/Materials/effect";
  15409. import { Particle } from "babylonjs/Particles/particle";
  15410. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15411. /**
  15412. * Particle emitter emitting particles from the inside of a cone.
  15413. * It emits the particles alongside the cone volume from the base to the particle.
  15414. * The emission direction might be randomized.
  15415. */
  15416. export class ConeParticleEmitter implements IParticleEmitterType {
  15417. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15418. directionRandomizer: number;
  15419. private _radius;
  15420. private _angle;
  15421. private _height;
  15422. /**
  15423. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15424. */
  15425. radiusRange: number;
  15426. /**
  15427. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15428. */
  15429. heightRange: number;
  15430. /**
  15431. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15432. */
  15433. emitFromSpawnPointOnly: boolean;
  15434. /**
  15435. * Gets or sets the radius of the emission cone
  15436. */
  15437. radius: number;
  15438. /**
  15439. * Gets or sets the angle of the emission cone
  15440. */
  15441. angle: number;
  15442. private _buildHeight;
  15443. /**
  15444. * Creates a new instance ConeParticleEmitter
  15445. * @param radius the radius of the emission cone (1 by default)
  15446. * @param angle the cone base angle (PI by default)
  15447. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15448. */
  15449. constructor(radius?: number, angle?: number,
  15450. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15451. directionRandomizer?: number);
  15452. /**
  15453. * Called by the particle System when the direction is computed for the created particle.
  15454. * @param worldMatrix is the world matrix of the particle system
  15455. * @param directionToUpdate is the direction vector to update with the result
  15456. * @param particle is the particle we are computed the direction for
  15457. */
  15458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15459. /**
  15460. * Called by the particle System when the position is computed for the created particle.
  15461. * @param worldMatrix is the world matrix of the particle system
  15462. * @param positionToUpdate is the position vector to update with the result
  15463. * @param particle is the particle we are computed the position for
  15464. */
  15465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15466. /**
  15467. * Clones the current emitter and returns a copy of it
  15468. * @returns the new emitter
  15469. */
  15470. clone(): ConeParticleEmitter;
  15471. /**
  15472. * Called by the GPUParticleSystem to setup the update shader
  15473. * @param effect defines the update shader
  15474. */
  15475. applyToShader(effect: Effect): void;
  15476. /**
  15477. * Returns a string to use to update the GPU particles update shader
  15478. * @returns a string containng the defines string
  15479. */
  15480. getEffectDefines(): string;
  15481. /**
  15482. * Returns the string "ConeParticleEmitter"
  15483. * @returns a string containing the class name
  15484. */
  15485. getClassName(): string;
  15486. /**
  15487. * Serializes the particle system to a JSON object.
  15488. * @returns the JSON object
  15489. */
  15490. serialize(): any;
  15491. /**
  15492. * Parse properties from a JSON object
  15493. * @param serializationObject defines the JSON object
  15494. */
  15495. parse(serializationObject: any): void;
  15496. }
  15497. }
  15498. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15499. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15500. import { Effect } from "babylonjs/Materials/effect";
  15501. import { Particle } from "babylonjs/Particles/particle";
  15502. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15503. /**
  15504. * Particle emitter emitting particles from the inside of a cylinder.
  15505. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15506. */
  15507. export class CylinderParticleEmitter implements IParticleEmitterType {
  15508. /**
  15509. * The radius of the emission cylinder.
  15510. */
  15511. radius: number;
  15512. /**
  15513. * The height of the emission cylinder.
  15514. */
  15515. height: number;
  15516. /**
  15517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15518. */
  15519. radiusRange: number;
  15520. /**
  15521. * How much to randomize the particle direction [0-1].
  15522. */
  15523. directionRandomizer: number;
  15524. /**
  15525. * Creates a new instance CylinderParticleEmitter
  15526. * @param radius the radius of the emission cylinder (1 by default)
  15527. * @param height the height of the emission cylinder (1 by default)
  15528. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15529. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15530. */
  15531. constructor(
  15532. /**
  15533. * The radius of the emission cylinder.
  15534. */
  15535. radius?: number,
  15536. /**
  15537. * The height of the emission cylinder.
  15538. */
  15539. height?: number,
  15540. /**
  15541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15542. */
  15543. radiusRange?: number,
  15544. /**
  15545. * How much to randomize the particle direction [0-1].
  15546. */
  15547. directionRandomizer?: number);
  15548. /**
  15549. * Called by the particle System when the direction is computed for the created particle.
  15550. * @param worldMatrix is the world matrix of the particle system
  15551. * @param directionToUpdate is the direction vector to update with the result
  15552. * @param particle is the particle we are computed the direction for
  15553. */
  15554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15555. /**
  15556. * Called by the particle System when the position is computed for the created particle.
  15557. * @param worldMatrix is the world matrix of the particle system
  15558. * @param positionToUpdate is the position vector to update with the result
  15559. * @param particle is the particle we are computed the position for
  15560. */
  15561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15562. /**
  15563. * Clones the current emitter and returns a copy of it
  15564. * @returns the new emitter
  15565. */
  15566. clone(): CylinderParticleEmitter;
  15567. /**
  15568. * Called by the GPUParticleSystem to setup the update shader
  15569. * @param effect defines the update shader
  15570. */
  15571. applyToShader(effect: Effect): void;
  15572. /**
  15573. * Returns a string to use to update the GPU particles update shader
  15574. * @returns a string containng the defines string
  15575. */
  15576. getEffectDefines(): string;
  15577. /**
  15578. * Returns the string "CylinderParticleEmitter"
  15579. * @returns a string containing the class name
  15580. */
  15581. getClassName(): string;
  15582. /**
  15583. * Serializes the particle system to a JSON object.
  15584. * @returns the JSON object
  15585. */
  15586. serialize(): any;
  15587. /**
  15588. * Parse properties from a JSON object
  15589. * @param serializationObject defines the JSON object
  15590. */
  15591. parse(serializationObject: any): void;
  15592. }
  15593. /**
  15594. * Particle emitter emitting particles from the inside of a cylinder.
  15595. * It emits the particles randomly between two vectors.
  15596. */
  15597. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15598. /**
  15599. * The min limit of the emission direction.
  15600. */
  15601. direction1: Vector3;
  15602. /**
  15603. * The max limit of the emission direction.
  15604. */
  15605. direction2: Vector3;
  15606. /**
  15607. * Creates a new instance CylinderDirectedParticleEmitter
  15608. * @param radius the radius of the emission cylinder (1 by default)
  15609. * @param height the height of the emission cylinder (1 by default)
  15610. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15611. * @param direction1 the min limit of the emission direction (up vector by default)
  15612. * @param direction2 the max limit of the emission direction (up vector by default)
  15613. */
  15614. constructor(radius?: number, height?: number, radiusRange?: number,
  15615. /**
  15616. * The min limit of the emission direction.
  15617. */
  15618. direction1?: Vector3,
  15619. /**
  15620. * The max limit of the emission direction.
  15621. */
  15622. direction2?: Vector3);
  15623. /**
  15624. * Called by the particle System when the direction is computed for the created particle.
  15625. * @param worldMatrix is the world matrix of the particle system
  15626. * @param directionToUpdate is the direction vector to update with the result
  15627. * @param particle is the particle we are computed the direction for
  15628. */
  15629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15630. /**
  15631. * Clones the current emitter and returns a copy of it
  15632. * @returns the new emitter
  15633. */
  15634. clone(): CylinderDirectedParticleEmitter;
  15635. /**
  15636. * Called by the GPUParticleSystem to setup the update shader
  15637. * @param effect defines the update shader
  15638. */
  15639. applyToShader(effect: Effect): void;
  15640. /**
  15641. * Returns a string to use to update the GPU particles update shader
  15642. * @returns a string containng the defines string
  15643. */
  15644. getEffectDefines(): string;
  15645. /**
  15646. * Returns the string "CylinderDirectedParticleEmitter"
  15647. * @returns a string containing the class name
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Serializes the particle system to a JSON object.
  15652. * @returns the JSON object
  15653. */
  15654. serialize(): any;
  15655. /**
  15656. * Parse properties from a JSON object
  15657. * @param serializationObject defines the JSON object
  15658. */
  15659. parse(serializationObject: any): void;
  15660. }
  15661. }
  15662. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15663. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15664. import { Effect } from "babylonjs/Materials/effect";
  15665. import { Particle } from "babylonjs/Particles/particle";
  15666. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15667. /**
  15668. * Particle emitter emitting particles from the inside of a hemisphere.
  15669. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15670. */
  15671. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15672. /**
  15673. * The radius of the emission hemisphere.
  15674. */
  15675. radius: number;
  15676. /**
  15677. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15678. */
  15679. radiusRange: number;
  15680. /**
  15681. * How much to randomize the particle direction [0-1].
  15682. */
  15683. directionRandomizer: number;
  15684. /**
  15685. * Creates a new instance HemisphericParticleEmitter
  15686. * @param radius the radius of the emission hemisphere (1 by default)
  15687. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15688. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15689. */
  15690. constructor(
  15691. /**
  15692. * The radius of the emission hemisphere.
  15693. */
  15694. radius?: number,
  15695. /**
  15696. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15697. */
  15698. radiusRange?: number,
  15699. /**
  15700. * How much to randomize the particle direction [0-1].
  15701. */
  15702. directionRandomizer?: number);
  15703. /**
  15704. * Called by the particle System when the direction is computed for the created particle.
  15705. * @param worldMatrix is the world matrix of the particle system
  15706. * @param directionToUpdate is the direction vector to update with the result
  15707. * @param particle is the particle we are computed the direction for
  15708. */
  15709. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15710. /**
  15711. * Called by the particle System when the position is computed for the created particle.
  15712. * @param worldMatrix is the world matrix of the particle system
  15713. * @param positionToUpdate is the position vector to update with the result
  15714. * @param particle is the particle we are computed the position for
  15715. */
  15716. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15717. /**
  15718. * Clones the current emitter and returns a copy of it
  15719. * @returns the new emitter
  15720. */
  15721. clone(): HemisphericParticleEmitter;
  15722. /**
  15723. * Called by the GPUParticleSystem to setup the update shader
  15724. * @param effect defines the update shader
  15725. */
  15726. applyToShader(effect: Effect): void;
  15727. /**
  15728. * Returns a string to use to update the GPU particles update shader
  15729. * @returns a string containng the defines string
  15730. */
  15731. getEffectDefines(): string;
  15732. /**
  15733. * Returns the string "HemisphericParticleEmitter"
  15734. * @returns a string containing the class name
  15735. */
  15736. getClassName(): string;
  15737. /**
  15738. * Serializes the particle system to a JSON object.
  15739. * @returns the JSON object
  15740. */
  15741. serialize(): any;
  15742. /**
  15743. * Parse properties from a JSON object
  15744. * @param serializationObject defines the JSON object
  15745. */
  15746. parse(serializationObject: any): void;
  15747. }
  15748. }
  15749. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15750. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15751. import { Effect } from "babylonjs/Materials/effect";
  15752. import { Particle } from "babylonjs/Particles/particle";
  15753. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15754. /**
  15755. * Particle emitter emitting particles from a point.
  15756. * It emits the particles randomly between 2 given directions.
  15757. */
  15758. export class PointParticleEmitter implements IParticleEmitterType {
  15759. /**
  15760. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15761. */
  15762. direction1: Vector3;
  15763. /**
  15764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15765. */
  15766. direction2: Vector3;
  15767. /**
  15768. * Creates a new instance PointParticleEmitter
  15769. */
  15770. constructor();
  15771. /**
  15772. * Called by the particle System when the direction is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param directionToUpdate is the direction vector to update with the result
  15775. * @param particle is the particle we are computed the direction for
  15776. */
  15777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15778. /**
  15779. * Called by the particle System when the position is computed for the created particle.
  15780. * @param worldMatrix is the world matrix of the particle system
  15781. * @param positionToUpdate is the position vector to update with the result
  15782. * @param particle is the particle we are computed the position for
  15783. */
  15784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15785. /**
  15786. * Clones the current emitter and returns a copy of it
  15787. * @returns the new emitter
  15788. */
  15789. clone(): PointParticleEmitter;
  15790. /**
  15791. * Called by the GPUParticleSystem to setup the update shader
  15792. * @param effect defines the update shader
  15793. */
  15794. applyToShader(effect: Effect): void;
  15795. /**
  15796. * Returns a string to use to update the GPU particles update shader
  15797. * @returns a string containng the defines string
  15798. */
  15799. getEffectDefines(): string;
  15800. /**
  15801. * Returns the string "PointParticleEmitter"
  15802. * @returns a string containing the class name
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Serializes the particle system to a JSON object.
  15807. * @returns the JSON object
  15808. */
  15809. serialize(): any;
  15810. /**
  15811. * Parse properties from a JSON object
  15812. * @param serializationObject defines the JSON object
  15813. */
  15814. parse(serializationObject: any): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15818. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15819. import { Effect } from "babylonjs/Materials/effect";
  15820. import { Particle } from "babylonjs/Particles/particle";
  15821. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15822. /**
  15823. * Particle emitter emitting particles from the inside of a sphere.
  15824. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15825. */
  15826. export class SphereParticleEmitter implements IParticleEmitterType {
  15827. /**
  15828. * The radius of the emission sphere.
  15829. */
  15830. radius: number;
  15831. /**
  15832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15833. */
  15834. radiusRange: number;
  15835. /**
  15836. * How much to randomize the particle direction [0-1].
  15837. */
  15838. directionRandomizer: number;
  15839. /**
  15840. * Creates a new instance SphereParticleEmitter
  15841. * @param radius the radius of the emission sphere (1 by default)
  15842. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15843. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15844. */
  15845. constructor(
  15846. /**
  15847. * The radius of the emission sphere.
  15848. */
  15849. radius?: number,
  15850. /**
  15851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15852. */
  15853. radiusRange?: number,
  15854. /**
  15855. * How much to randomize the particle direction [0-1].
  15856. */
  15857. directionRandomizer?: number);
  15858. /**
  15859. * Called by the particle System when the direction is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param directionToUpdate is the direction vector to update with the result
  15862. * @param particle is the particle we are computed the direction for
  15863. */
  15864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15865. /**
  15866. * Called by the particle System when the position is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param positionToUpdate is the position vector to update with the result
  15869. * @param particle is the particle we are computed the position for
  15870. */
  15871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15872. /**
  15873. * Clones the current emitter and returns a copy of it
  15874. * @returns the new emitter
  15875. */
  15876. clone(): SphereParticleEmitter;
  15877. /**
  15878. * Called by the GPUParticleSystem to setup the update shader
  15879. * @param effect defines the update shader
  15880. */
  15881. applyToShader(effect: Effect): void;
  15882. /**
  15883. * Returns a string to use to update the GPU particles update shader
  15884. * @returns a string containng the defines string
  15885. */
  15886. getEffectDefines(): string;
  15887. /**
  15888. * Returns the string "SphereParticleEmitter"
  15889. * @returns a string containing the class name
  15890. */
  15891. getClassName(): string;
  15892. /**
  15893. * Serializes the particle system to a JSON object.
  15894. * @returns the JSON object
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Parse properties from a JSON object
  15899. * @param serializationObject defines the JSON object
  15900. */
  15901. parse(serializationObject: any): void;
  15902. }
  15903. /**
  15904. * Particle emitter emitting particles from the inside of a sphere.
  15905. * It emits the particles randomly between two vectors.
  15906. */
  15907. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15908. /**
  15909. * The min limit of the emission direction.
  15910. */
  15911. direction1: Vector3;
  15912. /**
  15913. * The max limit of the emission direction.
  15914. */
  15915. direction2: Vector3;
  15916. /**
  15917. * Creates a new instance SphereDirectedParticleEmitter
  15918. * @param radius the radius of the emission sphere (1 by default)
  15919. * @param direction1 the min limit of the emission direction (up vector by default)
  15920. * @param direction2 the max limit of the emission direction (up vector by default)
  15921. */
  15922. constructor(radius?: number,
  15923. /**
  15924. * The min limit of the emission direction.
  15925. */
  15926. direction1?: Vector3,
  15927. /**
  15928. * The max limit of the emission direction.
  15929. */
  15930. direction2?: Vector3);
  15931. /**
  15932. * Called by the particle System when the direction is computed for the created particle.
  15933. * @param worldMatrix is the world matrix of the particle system
  15934. * @param directionToUpdate is the direction vector to update with the result
  15935. * @param particle is the particle we are computed the direction for
  15936. */
  15937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15938. /**
  15939. * Clones the current emitter and returns a copy of it
  15940. * @returns the new emitter
  15941. */
  15942. clone(): SphereDirectedParticleEmitter;
  15943. /**
  15944. * Called by the GPUParticleSystem to setup the update shader
  15945. * @param effect defines the update shader
  15946. */
  15947. applyToShader(effect: Effect): void;
  15948. /**
  15949. * Returns a string to use to update the GPU particles update shader
  15950. * @returns a string containng the defines string
  15951. */
  15952. getEffectDefines(): string;
  15953. /**
  15954. * Returns the string "SphereDirectedParticleEmitter"
  15955. * @returns a string containing the class name
  15956. */
  15957. getClassName(): string;
  15958. /**
  15959. * Serializes the particle system to a JSON object.
  15960. * @returns the JSON object
  15961. */
  15962. serialize(): any;
  15963. /**
  15964. * Parse properties from a JSON object
  15965. * @param serializationObject defines the JSON object
  15966. */
  15967. parse(serializationObject: any): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Particles/EmitterTypes/index" {
  15971. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15972. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15973. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15974. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15975. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15976. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15977. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15978. }
  15979. declare module "babylonjs/Particles/IParticleSystem" {
  15980. import { Nullable } from "babylonjs/types";
  15981. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15984. import { Texture } from "babylonjs/Materials/Textures/texture";
  15985. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15986. import { Scene } from "babylonjs/scene";
  15987. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15988. import { Animation } from "babylonjs/Animations/animation";
  15989. /**
  15990. * Interface representing a particle system in Babylon.js.
  15991. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15992. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15993. */
  15994. export interface IParticleSystem {
  15995. /**
  15996. * List of animations used by the particle system.
  15997. */
  15998. animations: Animation[];
  15999. /**
  16000. * The id of the Particle system.
  16001. */
  16002. id: string;
  16003. /**
  16004. * The name of the Particle system.
  16005. */
  16006. name: string;
  16007. /**
  16008. * The emitter represents the Mesh or position we are attaching the particle system to.
  16009. */
  16010. emitter: Nullable<AbstractMesh | Vector3>;
  16011. /**
  16012. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16013. */
  16014. isBillboardBased: boolean;
  16015. /**
  16016. * The rendering group used by the Particle system to chose when to render.
  16017. */
  16018. renderingGroupId: number;
  16019. /**
  16020. * The layer mask we are rendering the particles through.
  16021. */
  16022. layerMask: number;
  16023. /**
  16024. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16025. */
  16026. updateSpeed: number;
  16027. /**
  16028. * The amount of time the particle system is running (depends of the overall update speed).
  16029. */
  16030. targetStopDuration: number;
  16031. /**
  16032. * The texture used to render each particle. (this can be a spritesheet)
  16033. */
  16034. particleTexture: Nullable<Texture>;
  16035. /**
  16036. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16037. */
  16038. blendMode: number;
  16039. /**
  16040. * Minimum life time of emitting particles.
  16041. */
  16042. minLifeTime: number;
  16043. /**
  16044. * Maximum life time of emitting particles.
  16045. */
  16046. maxLifeTime: number;
  16047. /**
  16048. * Minimum Size of emitting particles.
  16049. */
  16050. minSize: number;
  16051. /**
  16052. * Maximum Size of emitting particles.
  16053. */
  16054. maxSize: number;
  16055. /**
  16056. * Minimum scale of emitting particles on X axis.
  16057. */
  16058. minScaleX: number;
  16059. /**
  16060. * Maximum scale of emitting particles on X axis.
  16061. */
  16062. maxScaleX: number;
  16063. /**
  16064. * Minimum scale of emitting particles on Y axis.
  16065. */
  16066. minScaleY: number;
  16067. /**
  16068. * Maximum scale of emitting particles on Y axis.
  16069. */
  16070. maxScaleY: number;
  16071. /**
  16072. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16073. */
  16074. color1: Color4;
  16075. /**
  16076. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16077. */
  16078. color2: Color4;
  16079. /**
  16080. * Color the particle will have at the end of its lifetime.
  16081. */
  16082. colorDead: Color4;
  16083. /**
  16084. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16085. */
  16086. emitRate: number;
  16087. /**
  16088. * You can use gravity if you want to give an orientation to your particles.
  16089. */
  16090. gravity: Vector3;
  16091. /**
  16092. * Minimum power of emitting particles.
  16093. */
  16094. minEmitPower: number;
  16095. /**
  16096. * Maximum power of emitting particles.
  16097. */
  16098. maxEmitPower: number;
  16099. /**
  16100. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16101. */
  16102. minAngularSpeed: number;
  16103. /**
  16104. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16105. */
  16106. maxAngularSpeed: number;
  16107. /**
  16108. * Gets or sets the minimal initial rotation in radians.
  16109. */
  16110. minInitialRotation: number;
  16111. /**
  16112. * Gets or sets the maximal initial rotation in radians.
  16113. */
  16114. maxInitialRotation: number;
  16115. /**
  16116. * The particle emitter type defines the emitter used by the particle system.
  16117. * It can be for example box, sphere, or cone...
  16118. */
  16119. particleEmitterType: Nullable<IParticleEmitterType>;
  16120. /**
  16121. * Defines the delay in milliseconds before starting the system (0 by default)
  16122. */
  16123. startDelay: number;
  16124. /**
  16125. * 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
  16126. */
  16127. preWarmCycles: number;
  16128. /**
  16129. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16130. */
  16131. preWarmStepOffset: number;
  16132. /**
  16133. * 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)
  16134. */
  16135. spriteCellChangeSpeed: number;
  16136. /**
  16137. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16138. */
  16139. startSpriteCellID: number;
  16140. /**
  16141. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16142. */
  16143. endSpriteCellID: number;
  16144. /**
  16145. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16146. */
  16147. spriteCellWidth: number;
  16148. /**
  16149. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16150. */
  16151. spriteCellHeight: number;
  16152. /**
  16153. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16154. */
  16155. spriteRandomStartCell: boolean;
  16156. /**
  16157. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16158. */
  16159. isAnimationSheetEnabled: boolean;
  16160. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16161. translationPivot: Vector2;
  16162. /**
  16163. * Gets or sets a texture used to add random noise to particle positions
  16164. */
  16165. noiseTexture: Nullable<BaseTexture>;
  16166. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16167. noiseStrength: Vector3;
  16168. /**
  16169. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16170. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16171. */
  16172. billboardMode: number;
  16173. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16174. limitVelocityDamping: number;
  16175. /**
  16176. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16177. */
  16178. beginAnimationOnStart: boolean;
  16179. /**
  16180. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16181. */
  16182. beginAnimationFrom: number;
  16183. /**
  16184. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16185. */
  16186. beginAnimationTo: number;
  16187. /**
  16188. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16189. */
  16190. beginAnimationLoop: boolean;
  16191. /**
  16192. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16193. */
  16194. disposeOnStop: boolean;
  16195. /**
  16196. * Gets the maximum number of particles active at the same time.
  16197. * @returns The max number of active particles.
  16198. */
  16199. getCapacity(): number;
  16200. /**
  16201. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16202. * @returns True if it has been started, otherwise false.
  16203. */
  16204. isStarted(): boolean;
  16205. /**
  16206. * Animates the particle system for this frame.
  16207. */
  16208. animate(): void;
  16209. /**
  16210. * Renders the particle system in its current state.
  16211. * @returns the current number of particles
  16212. */
  16213. render(): number;
  16214. /**
  16215. * Dispose the particle system and frees its associated resources.
  16216. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16217. */
  16218. dispose(disposeTexture?: boolean): void;
  16219. /**
  16220. * Clones the particle system.
  16221. * @param name The name of the cloned object
  16222. * @param newEmitter The new emitter to use
  16223. * @returns the cloned particle system
  16224. */
  16225. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16226. /**
  16227. * Serializes the particle system to a JSON object.
  16228. * @returns the JSON object
  16229. */
  16230. serialize(): any;
  16231. /**
  16232. * Rebuild the particle system
  16233. */
  16234. rebuild(): void;
  16235. /**
  16236. * Starts the particle system and begins to emit
  16237. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16238. */
  16239. start(delay?: number): void;
  16240. /**
  16241. * Stops the particle system.
  16242. */
  16243. stop(): void;
  16244. /**
  16245. * Remove all active particles
  16246. */
  16247. reset(): void;
  16248. /**
  16249. * Is this system ready to be used/rendered
  16250. * @return true if the system is ready
  16251. */
  16252. isReady(): boolean;
  16253. /**
  16254. * Adds a new color gradient
  16255. * @param gradient defines the gradient to use (between 0 and 1)
  16256. * @param color1 defines the color to affect to the specified gradient
  16257. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16258. * @returns the current particle system
  16259. */
  16260. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16261. /**
  16262. * Remove a specific color gradient
  16263. * @param gradient defines the gradient to remove
  16264. * @returns the current particle system
  16265. */
  16266. removeColorGradient(gradient: number): IParticleSystem;
  16267. /**
  16268. * Adds a new size gradient
  16269. * @param gradient defines the gradient to use (between 0 and 1)
  16270. * @param factor defines the size factor to affect to the specified gradient
  16271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16272. * @returns the current particle system
  16273. */
  16274. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16275. /**
  16276. * Remove a specific size gradient
  16277. * @param gradient defines the gradient to remove
  16278. * @returns the current particle system
  16279. */
  16280. removeSizeGradient(gradient: number): IParticleSystem;
  16281. /**
  16282. * Gets the current list of color gradients.
  16283. * You must use addColorGradient and removeColorGradient to udpate this list
  16284. * @returns the list of color gradients
  16285. */
  16286. getColorGradients(): Nullable<Array<ColorGradient>>;
  16287. /**
  16288. * Gets the current list of size gradients.
  16289. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16290. * @returns the list of size gradients
  16291. */
  16292. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16293. /**
  16294. * Gets the current list of angular speed gradients.
  16295. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16296. * @returns the list of angular speed gradients
  16297. */
  16298. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16299. /**
  16300. * Adds a new angular speed gradient
  16301. * @param gradient defines the gradient to use (between 0 and 1)
  16302. * @param factor defines the angular speed to affect to the specified gradient
  16303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16304. * @returns the current particle system
  16305. */
  16306. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16307. /**
  16308. * Remove a specific angular speed gradient
  16309. * @param gradient defines the gradient to remove
  16310. * @returns the current particle system
  16311. */
  16312. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16313. /**
  16314. * Gets the current list of velocity gradients.
  16315. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16316. * @returns the list of velocity gradients
  16317. */
  16318. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16319. /**
  16320. * Adds a new velocity gradient
  16321. * @param gradient defines the gradient to use (between 0 and 1)
  16322. * @param factor defines the velocity to affect to the specified gradient
  16323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16324. * @returns the current particle system
  16325. */
  16326. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16327. /**
  16328. * Remove a specific velocity gradient
  16329. * @param gradient defines the gradient to remove
  16330. * @returns the current particle system
  16331. */
  16332. removeVelocityGradient(gradient: number): IParticleSystem;
  16333. /**
  16334. * Gets the current list of limit velocity gradients.
  16335. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16336. * @returns the list of limit velocity gradients
  16337. */
  16338. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16339. /**
  16340. * Adds a new limit velocity gradient
  16341. * @param gradient defines the gradient to use (between 0 and 1)
  16342. * @param factor defines the limit velocity to affect to the specified gradient
  16343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16344. * @returns the current particle system
  16345. */
  16346. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16347. /**
  16348. * Remove a specific limit velocity gradient
  16349. * @param gradient defines the gradient to remove
  16350. * @returns the current particle system
  16351. */
  16352. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16353. /**
  16354. * Adds a new drag gradient
  16355. * @param gradient defines the gradient to use (between 0 and 1)
  16356. * @param factor defines the drag to affect to the specified gradient
  16357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16358. * @returns the current particle system
  16359. */
  16360. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16361. /**
  16362. * Remove a specific drag gradient
  16363. * @param gradient defines the gradient to remove
  16364. * @returns the current particle system
  16365. */
  16366. removeDragGradient(gradient: number): IParticleSystem;
  16367. /**
  16368. * Gets the current list of drag gradients.
  16369. * You must use addDragGradient and removeDragGradient to udpate this list
  16370. * @returns the list of drag gradients
  16371. */
  16372. getDragGradients(): Nullable<Array<FactorGradient>>;
  16373. /**
  16374. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param factor defines the emit rate to affect to the specified gradient
  16377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16378. * @returns the current particle system
  16379. */
  16380. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16381. /**
  16382. * Remove a specific emit rate gradient
  16383. * @param gradient defines the gradient to remove
  16384. * @returns the current particle system
  16385. */
  16386. removeEmitRateGradient(gradient: number): IParticleSystem;
  16387. /**
  16388. * Gets the current list of emit rate gradients.
  16389. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16390. * @returns the list of emit rate gradients
  16391. */
  16392. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16393. /**
  16394. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16395. * @param gradient defines the gradient to use (between 0 and 1)
  16396. * @param factor defines the start size to affect to the specified gradient
  16397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16398. * @returns the current particle system
  16399. */
  16400. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16401. /**
  16402. * Remove a specific start size gradient
  16403. * @param gradient defines the gradient to remove
  16404. * @returns the current particle system
  16405. */
  16406. removeStartSizeGradient(gradient: number): IParticleSystem;
  16407. /**
  16408. * Gets the current list of start size gradients.
  16409. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16410. * @returns the list of start size gradients
  16411. */
  16412. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Adds a new life time gradient
  16415. * @param gradient defines the gradient to use (between 0 and 1)
  16416. * @param factor defines the life time factor to affect to the specified gradient
  16417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16418. * @returns the current particle system
  16419. */
  16420. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16421. /**
  16422. * Remove a specific life time gradient
  16423. * @param gradient defines the gradient to remove
  16424. * @returns the current particle system
  16425. */
  16426. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16427. /**
  16428. * Gets the current list of life time gradients.
  16429. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16430. * @returns the list of life time gradients
  16431. */
  16432. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16433. /**
  16434. * Gets the current list of color gradients.
  16435. * You must use addColorGradient and removeColorGradient to udpate this list
  16436. * @returns the list of color gradients
  16437. */
  16438. getColorGradients(): Nullable<Array<ColorGradient>>;
  16439. /**
  16440. * Adds a new ramp gradient used to remap particle colors
  16441. * @param gradient defines the gradient to use (between 0 and 1)
  16442. * @param color defines the color to affect to the specified gradient
  16443. * @returns the current particle system
  16444. */
  16445. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16446. /**
  16447. * Gets the current list of ramp gradients.
  16448. * You must use addRampGradient and removeRampGradient to udpate this list
  16449. * @returns the list of ramp gradients
  16450. */
  16451. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16452. /** Gets or sets a boolean indicating that ramp gradients must be used
  16453. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16454. */
  16455. useRampGradients: boolean;
  16456. /**
  16457. * Adds a new color remap gradient
  16458. * @param gradient defines the gradient to use (between 0 and 1)
  16459. * @param min defines the color remap minimal range
  16460. * @param max defines the color remap maximal range
  16461. * @returns the current particle system
  16462. */
  16463. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16464. /**
  16465. * Gets the current list of color remap gradients.
  16466. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16467. * @returns the list of color remap gradients
  16468. */
  16469. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16470. /**
  16471. * Adds a new alpha remap gradient
  16472. * @param gradient defines the gradient to use (between 0 and 1)
  16473. * @param min defines the alpha remap minimal range
  16474. * @param max defines the alpha remap maximal range
  16475. * @returns the current particle system
  16476. */
  16477. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of alpha remap gradients.
  16480. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16481. * @returns the list of alpha remap gradients
  16482. */
  16483. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16488. * @returns the emitter
  16489. */
  16490. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16491. /**
  16492. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16493. * @param radius The radius of the hemisphere to emit from
  16494. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16495. * @returns the emitter
  16496. */
  16497. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16498. /**
  16499. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16500. * @param radius The radius of the sphere to emit from
  16501. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16502. * @returns the emitter
  16503. */
  16504. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16505. /**
  16506. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16507. * @param radius The radius of the sphere to emit from
  16508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16510. * @returns the emitter
  16511. */
  16512. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16513. /**
  16514. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16515. * @param radius The radius of the emission cylinder
  16516. * @param height The height of the emission cylinder
  16517. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16518. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16519. * @returns the emitter
  16520. */
  16521. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16522. /**
  16523. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16524. * @param radius The radius of the cylinder to emit from
  16525. * @param height The height of the emission cylinder
  16526. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16527. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16528. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16529. * @returns the emitter
  16530. */
  16531. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16532. /**
  16533. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16534. * @param radius The radius of the cone to emit from
  16535. * @param angle The base angle of the cone
  16536. * @returns the emitter
  16537. */
  16538. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16539. /**
  16540. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16543. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16544. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16545. * @returns the emitter
  16546. */
  16547. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16548. /**
  16549. * Get hosting scene
  16550. * @returns the scene
  16551. */
  16552. getScene(): Scene;
  16553. }
  16554. }
  16555. declare module "babylonjs/Meshes/instancedMesh" {
  16556. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16557. import { Vector3 } from "babylonjs/Maths/math";
  16558. import { Camera } from "babylonjs/Cameras/camera";
  16559. import { Node } from "babylonjs/node";
  16560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16561. import { Mesh } from "babylonjs/Meshes/mesh";
  16562. import { Material } from "babylonjs/Materials/material";
  16563. import { Skeleton } from "babylonjs/Bones/skeleton";
  16564. /**
  16565. * Creates an instance based on a source mesh.
  16566. */
  16567. export class InstancedMesh extends AbstractMesh {
  16568. private _sourceMesh;
  16569. private _currentLOD;
  16570. /** @hidden */
  16571. _indexInSourceMeshInstanceArray: number;
  16572. constructor(name: string, source: Mesh);
  16573. /**
  16574. * Returns the string "InstancedMesh".
  16575. */
  16576. getClassName(): string;
  16577. /**
  16578. * If the source mesh receives shadows
  16579. */
  16580. readonly receiveShadows: boolean;
  16581. /**
  16582. * The material of the source mesh
  16583. */
  16584. readonly material: Nullable<Material>;
  16585. /**
  16586. * Visibility of the source mesh
  16587. */
  16588. readonly visibility: number;
  16589. /**
  16590. * Skeleton of the source mesh
  16591. */
  16592. readonly skeleton: Nullable<Skeleton>;
  16593. /**
  16594. * Rendering ground id of the source mesh
  16595. */
  16596. renderingGroupId: number;
  16597. /**
  16598. * Returns the total number of vertices (integer).
  16599. */
  16600. getTotalVertices(): number;
  16601. /**
  16602. * Returns a positive integer : the total number of indices in this mesh geometry.
  16603. * @returns the numner of indices or zero if the mesh has no geometry.
  16604. */
  16605. getTotalIndices(): number;
  16606. /**
  16607. * The source mesh of the instance
  16608. */
  16609. readonly sourceMesh: Mesh;
  16610. /**
  16611. * Is this node ready to be used/rendered
  16612. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16613. * @return {boolean} is it ready
  16614. */
  16615. isReady(completeCheck?: boolean): boolean;
  16616. /**
  16617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16618. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16619. * @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.
  16620. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16621. */
  16622. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16623. /**
  16624. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16625. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16626. * The `data` are either a numeric array either a Float32Array.
  16627. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16628. * 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).
  16629. * Note that a new underlying VertexBuffer object is created each call.
  16630. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16631. *
  16632. * Possible `kind` values :
  16633. * - VertexBuffer.PositionKind
  16634. * - VertexBuffer.UVKind
  16635. * - VertexBuffer.UV2Kind
  16636. * - VertexBuffer.UV3Kind
  16637. * - VertexBuffer.UV4Kind
  16638. * - VertexBuffer.UV5Kind
  16639. * - VertexBuffer.UV6Kind
  16640. * - VertexBuffer.ColorKind
  16641. * - VertexBuffer.MatricesIndicesKind
  16642. * - VertexBuffer.MatricesIndicesExtraKind
  16643. * - VertexBuffer.MatricesWeightsKind
  16644. * - VertexBuffer.MatricesWeightsExtraKind
  16645. *
  16646. * Returns the Mesh.
  16647. */
  16648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16649. /**
  16650. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16651. * If the mesh has no geometry, it is simply returned as it is.
  16652. * The `data` are either a numeric array either a Float32Array.
  16653. * No new underlying VertexBuffer object is created.
  16654. * 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.
  16655. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16656. *
  16657. * Possible `kind` values :
  16658. * - VertexBuffer.PositionKind
  16659. * - VertexBuffer.UVKind
  16660. * - VertexBuffer.UV2Kind
  16661. * - VertexBuffer.UV3Kind
  16662. * - VertexBuffer.UV4Kind
  16663. * - VertexBuffer.UV5Kind
  16664. * - VertexBuffer.UV6Kind
  16665. * - VertexBuffer.ColorKind
  16666. * - VertexBuffer.MatricesIndicesKind
  16667. * - VertexBuffer.MatricesIndicesExtraKind
  16668. * - VertexBuffer.MatricesWeightsKind
  16669. * - VertexBuffer.MatricesWeightsExtraKind
  16670. *
  16671. * Returns the Mesh.
  16672. */
  16673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16674. /**
  16675. * Sets the mesh indices.
  16676. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16677. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16678. * This method creates a new index buffer each call.
  16679. * Returns the Mesh.
  16680. */
  16681. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16682. /**
  16683. * Boolean : True if the mesh owns the requested kind of data.
  16684. */
  16685. isVerticesDataPresent(kind: string): boolean;
  16686. /**
  16687. * Returns an array of indices (IndicesArray).
  16688. */
  16689. getIndices(): Nullable<IndicesArray>;
  16690. readonly _positions: Nullable<Vector3[]>;
  16691. /**
  16692. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16693. * This means the mesh underlying bounding box and sphere are recomputed.
  16694. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16695. * @returns the current mesh
  16696. */
  16697. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16698. /** @hidden */
  16699. _preActivate(): InstancedMesh;
  16700. /** @hidden */
  16701. _activate(renderId: number): InstancedMesh;
  16702. /**
  16703. * Returns the current associated LOD AbstractMesh.
  16704. */
  16705. getLOD(camera: Camera): AbstractMesh;
  16706. /** @hidden */
  16707. _syncSubMeshes(): InstancedMesh;
  16708. /** @hidden */
  16709. _generatePointsArray(): boolean;
  16710. /**
  16711. * Creates a new InstancedMesh from the current mesh.
  16712. * - name (string) : the cloned mesh name
  16713. * - newParent (optional Node) : the optional Node to parent the clone to.
  16714. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16715. *
  16716. * Returns the clone.
  16717. */
  16718. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16719. /**
  16720. * Disposes the InstancedMesh.
  16721. * Returns nothing.
  16722. */
  16723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16724. }
  16725. }
  16726. declare module "babylonjs/Materials/shaderMaterial" {
  16727. import { Scene } from "babylonjs/scene";
  16728. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16730. import { Mesh } from "babylonjs/Meshes/mesh";
  16731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16732. import { Texture } from "babylonjs/Materials/Textures/texture";
  16733. import { Material } from "babylonjs/Materials/material";
  16734. /**
  16735. * Defines the options associated with the creation of a shader material.
  16736. */
  16737. export interface IShaderMaterialOptions {
  16738. /**
  16739. * Does the material work in alpha blend mode
  16740. */
  16741. needAlphaBlending: boolean;
  16742. /**
  16743. * Does the material work in alpha test mode
  16744. */
  16745. needAlphaTesting: boolean;
  16746. /**
  16747. * The list of attribute names used in the shader
  16748. */
  16749. attributes: string[];
  16750. /**
  16751. * The list of unifrom names used in the shader
  16752. */
  16753. uniforms: string[];
  16754. /**
  16755. * The list of UBO names used in the shader
  16756. */
  16757. uniformBuffers: string[];
  16758. /**
  16759. * The list of sampler names used in the shader
  16760. */
  16761. samplers: string[];
  16762. /**
  16763. * The list of defines used in the shader
  16764. */
  16765. defines: string[];
  16766. }
  16767. /**
  16768. * 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.
  16769. *
  16770. * This returned material effects how the mesh will look based on the code in the shaders.
  16771. *
  16772. * @see http://doc.babylonjs.com/how_to/shader_material
  16773. */
  16774. export class ShaderMaterial extends Material {
  16775. private _shaderPath;
  16776. private _options;
  16777. private _textures;
  16778. private _textureArrays;
  16779. private _floats;
  16780. private _ints;
  16781. private _floatsArrays;
  16782. private _colors3;
  16783. private _colors3Arrays;
  16784. private _colors4;
  16785. private _vectors2;
  16786. private _vectors3;
  16787. private _vectors4;
  16788. private _matrices;
  16789. private _matrices3x3;
  16790. private _matrices2x2;
  16791. private _vectors2Arrays;
  16792. private _vectors3Arrays;
  16793. private _cachedWorldViewMatrix;
  16794. private _renderId;
  16795. /**
  16796. * Instantiate a new shader material.
  16797. * 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.
  16798. * This returned material effects how the mesh will look based on the code in the shaders.
  16799. * @see http://doc.babylonjs.com/how_to/shader_material
  16800. * @param name Define the name of the material in the scene
  16801. * @param scene Define the scene the material belongs to
  16802. * @param shaderPath Defines the route to the shader code in one of three ways:
  16803. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16804. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16805. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16806. * @param options Define the options used to create the shader
  16807. */
  16808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16809. /**
  16810. * Gets the options used to compile the shader.
  16811. * They can be modified to trigger a new compilation
  16812. */
  16813. readonly options: IShaderMaterialOptions;
  16814. /**
  16815. * Gets the current class name of the material e.g. "ShaderMaterial"
  16816. * Mainly use in serialization.
  16817. * @returns the class name
  16818. */
  16819. getClassName(): string;
  16820. /**
  16821. * Specifies if the material will require alpha blending
  16822. * @returns a boolean specifying if alpha blending is needed
  16823. */
  16824. needAlphaBlending(): boolean;
  16825. /**
  16826. * Specifies if this material should be rendered in alpha test mode
  16827. * @returns a boolean specifying if an alpha test is needed.
  16828. */
  16829. needAlphaTesting(): boolean;
  16830. private _checkUniform;
  16831. /**
  16832. * Set a texture in the shader.
  16833. * @param name Define the name of the uniform samplers as defined in the shader
  16834. * @param texture Define the texture to bind to this sampler
  16835. * @return the material itself allowing "fluent" like uniform updates
  16836. */
  16837. setTexture(name: string, texture: Texture): ShaderMaterial;
  16838. /**
  16839. * Set a texture array in the shader.
  16840. * @param name Define the name of the uniform sampler array as defined in the shader
  16841. * @param textures Define the list of textures to bind to this sampler
  16842. * @return the material itself allowing "fluent" like uniform updates
  16843. */
  16844. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16845. /**
  16846. * Set a float in the shader.
  16847. * @param name Define the name of the uniform as defined in the shader
  16848. * @param value Define the value to give to the uniform
  16849. * @return the material itself allowing "fluent" like uniform updates
  16850. */
  16851. setFloat(name: string, value: number): ShaderMaterial;
  16852. /**
  16853. * Set a int in the shader.
  16854. * @param name Define the name of the uniform as defined in the shader
  16855. * @param value Define the value to give to the uniform
  16856. * @return the material itself allowing "fluent" like uniform updates
  16857. */
  16858. setInt(name: string, value: number): ShaderMaterial;
  16859. /**
  16860. * Set an array of floats in the shader.
  16861. * @param name Define the name of the uniform as defined in the shader
  16862. * @param value Define the value to give to the uniform
  16863. * @return the material itself allowing "fluent" like uniform updates
  16864. */
  16865. setFloats(name: string, value: number[]): ShaderMaterial;
  16866. /**
  16867. * Set a vec3 in the shader from a Color3.
  16868. * @param name Define the name of the uniform as defined in the shader
  16869. * @param value Define the value to give to the uniform
  16870. * @return the material itself allowing "fluent" like uniform updates
  16871. */
  16872. setColor3(name: string, value: Color3): ShaderMaterial;
  16873. /**
  16874. * Set a vec3 array in the shader from a Color3 array.
  16875. * @param name Define the name of the uniform as defined in the shader
  16876. * @param value Define the value to give to the uniform
  16877. * @return the material itself allowing "fluent" like uniform updates
  16878. */
  16879. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16880. /**
  16881. * Set a vec4 in the shader from a Color4.
  16882. * @param name Define the name of the uniform as defined in the shader
  16883. * @param value Define the value to give to the uniform
  16884. * @return the material itself allowing "fluent" like uniform updates
  16885. */
  16886. setColor4(name: string, value: Color4): ShaderMaterial;
  16887. /**
  16888. * Set a vec2 in the shader from a Vector2.
  16889. * @param name Define the name of the uniform as defined in the shader
  16890. * @param value Define the value to give to the uniform
  16891. * @return the material itself allowing "fluent" like uniform updates
  16892. */
  16893. setVector2(name: string, value: Vector2): ShaderMaterial;
  16894. /**
  16895. * Set a vec3 in the shader from a Vector3.
  16896. * @param name Define the name of the uniform as defined in the shader
  16897. * @param value Define the value to give to the uniform
  16898. * @return the material itself allowing "fluent" like uniform updates
  16899. */
  16900. setVector3(name: string, value: Vector3): ShaderMaterial;
  16901. /**
  16902. * Set a vec4 in the shader from a Vector4.
  16903. * @param name Define the name of the uniform as defined in the shader
  16904. * @param value Define the value to give to the uniform
  16905. * @return the material itself allowing "fluent" like uniform updates
  16906. */
  16907. setVector4(name: string, value: Vector4): ShaderMaterial;
  16908. /**
  16909. * Set a mat4 in the shader from a Matrix.
  16910. * @param name Define the name of the uniform as defined in the shader
  16911. * @param value Define the value to give to the uniform
  16912. * @return the material itself allowing "fluent" like uniform updates
  16913. */
  16914. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16915. /**
  16916. * Set a mat3 in the shader from a Float32Array.
  16917. * @param name Define the name of the uniform as defined in the shader
  16918. * @param value Define the value to give to the uniform
  16919. * @return the material itself allowing "fluent" like uniform updates
  16920. */
  16921. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16922. /**
  16923. * Set a mat2 in the shader from a Float32Array.
  16924. * @param name Define the name of the uniform as defined in the shader
  16925. * @param value Define the value to give to the uniform
  16926. * @return the material itself allowing "fluent" like uniform updates
  16927. */
  16928. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16929. /**
  16930. * Set a vec2 array in the shader from a number array.
  16931. * @param name Define the name of the uniform as defined in the shader
  16932. * @param value Define the value to give to the uniform
  16933. * @return the material itself allowing "fluent" like uniform updates
  16934. */
  16935. setArray2(name: string, value: number[]): ShaderMaterial;
  16936. /**
  16937. * Set a vec3 array in the shader from a number array.
  16938. * @param name Define the name of the uniform as defined in the shader
  16939. * @param value Define the value to give to the uniform
  16940. * @return the material itself allowing "fluent" like uniform updates
  16941. */
  16942. setArray3(name: string, value: number[]): ShaderMaterial;
  16943. private _checkCache;
  16944. /**
  16945. * Checks if the material is ready to render the requested mesh
  16946. * @param mesh Define the mesh to render
  16947. * @param useInstances Define whether or not the material is used with instances
  16948. * @returns true if ready, otherwise false
  16949. */
  16950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16951. /**
  16952. * Binds the world matrix to the material
  16953. * @param world defines the world transformation matrix
  16954. */
  16955. bindOnlyWorldMatrix(world: Matrix): void;
  16956. /**
  16957. * Binds the material to the mesh
  16958. * @param world defines the world transformation matrix
  16959. * @param mesh defines the mesh to bind the material to
  16960. */
  16961. bind(world: Matrix, mesh?: Mesh): void;
  16962. /**
  16963. * Gets the active textures from the material
  16964. * @returns an array of textures
  16965. */
  16966. getActiveTextures(): BaseTexture[];
  16967. /**
  16968. * Specifies if the material uses a texture
  16969. * @param texture defines the texture to check against the material
  16970. * @returns a boolean specifying if the material uses the texture
  16971. */
  16972. hasTexture(texture: BaseTexture): boolean;
  16973. /**
  16974. * Makes a duplicate of the material, and gives it a new name
  16975. * @param name defines the new name for the duplicated material
  16976. * @returns the cloned material
  16977. */
  16978. clone(name: string): ShaderMaterial;
  16979. /**
  16980. * Disposes the material
  16981. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16982. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16983. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16984. */
  16985. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16986. /**
  16987. * Serializes this material in a JSON representation
  16988. * @returns the serialized material object
  16989. */
  16990. serialize(): any;
  16991. /**
  16992. * Creates a shader material from parsed shader material data
  16993. * @param source defines the JSON represnetation of the material
  16994. * @param scene defines the hosting scene
  16995. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16996. * @returns a new material
  16997. */
  16998. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16999. }
  17000. }
  17001. declare module "babylonjs/Shaders/color.fragment" {
  17002. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17003. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17004. /** @hidden */
  17005. export var colorPixelShader: {
  17006. name: string;
  17007. shader: string;
  17008. };
  17009. }
  17010. declare module "babylonjs/Shaders/color.vertex" {
  17011. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17012. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17013. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17014. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17015. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17016. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17017. /** @hidden */
  17018. export var colorVertexShader: {
  17019. name: string;
  17020. shader: string;
  17021. };
  17022. }
  17023. declare module "babylonjs/Meshes/linesMesh" {
  17024. import { Nullable } from "babylonjs/types";
  17025. import { Scene } from "babylonjs/scene";
  17026. import { Color3 } from "babylonjs/Maths/math";
  17027. import { Node } from "babylonjs/node";
  17028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17029. import { Mesh } from "babylonjs/Meshes/mesh";
  17030. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17031. import { Effect } from "babylonjs/Materials/effect";
  17032. import { Material } from "babylonjs/Materials/material";
  17033. import "babylonjs/Shaders/color.fragment";
  17034. import "babylonjs/Shaders/color.vertex";
  17035. /**
  17036. * Line mesh
  17037. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17038. */
  17039. export class LinesMesh extends Mesh {
  17040. /**
  17041. * If vertex color should be applied to the mesh
  17042. */
  17043. useVertexColor?: boolean | undefined;
  17044. /**
  17045. * If vertex alpha should be applied to the mesh
  17046. */
  17047. useVertexAlpha?: boolean | undefined;
  17048. /**
  17049. * Color of the line (Default: White)
  17050. */
  17051. color: Color3;
  17052. /**
  17053. * Alpha of the line (Default: 1)
  17054. */
  17055. alpha: number;
  17056. /**
  17057. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17058. * This margin is expressed in world space coordinates, so its value may vary.
  17059. * Default value is 0.1
  17060. */
  17061. intersectionThreshold: number;
  17062. private _colorShader;
  17063. /**
  17064. * Creates a new LinesMesh
  17065. * @param name defines the name
  17066. * @param scene defines the hosting scene
  17067. * @param parent defines the parent mesh if any
  17068. * @param source defines the optional source LinesMesh used to clone data from
  17069. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17070. * When false, achieved by calling a clone(), also passing False.
  17071. * This will make creation of children, recursive.
  17072. * @param useVertexColor defines if this LinesMesh supports vertex color
  17073. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17074. */
  17075. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17076. /**
  17077. * If vertex color should be applied to the mesh
  17078. */
  17079. useVertexColor?: boolean | undefined,
  17080. /**
  17081. * If vertex alpha should be applied to the mesh
  17082. */
  17083. useVertexAlpha?: boolean | undefined);
  17084. private _addClipPlaneDefine;
  17085. private _removeClipPlaneDefine;
  17086. isReady(): boolean;
  17087. /**
  17088. * Returns the string "LineMesh"
  17089. */
  17090. getClassName(): string;
  17091. /**
  17092. * @hidden
  17093. */
  17094. /**
  17095. * @hidden
  17096. */
  17097. material: Material;
  17098. /**
  17099. * @hidden
  17100. */
  17101. readonly checkCollisions: boolean;
  17102. /** @hidden */
  17103. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17104. /** @hidden */
  17105. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17106. /**
  17107. * Disposes of the line mesh
  17108. * @param doNotRecurse If children should be disposed
  17109. */
  17110. dispose(doNotRecurse?: boolean): void;
  17111. /**
  17112. * Returns a new LineMesh object cloned from the current one.
  17113. */
  17114. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17115. /**
  17116. * Creates a new InstancedLinesMesh object from the mesh model.
  17117. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17118. * @param name defines the name of the new instance
  17119. * @returns a new InstancedLinesMesh
  17120. */
  17121. createInstance(name: string): InstancedLinesMesh;
  17122. }
  17123. /**
  17124. * Creates an instance based on a source LinesMesh
  17125. */
  17126. export class InstancedLinesMesh extends InstancedMesh {
  17127. /**
  17128. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17129. * This margin is expressed in world space coordinates, so its value may vary.
  17130. * Initilized with the intersectionThreshold value of the source LinesMesh
  17131. */
  17132. intersectionThreshold: number;
  17133. constructor(name: string, source: LinesMesh);
  17134. /**
  17135. * Returns the string "InstancedLinesMesh".
  17136. */
  17137. getClassName(): string;
  17138. }
  17139. }
  17140. declare module "babylonjs/Shaders/line.fragment" {
  17141. /** @hidden */
  17142. export var linePixelShader: {
  17143. name: string;
  17144. shader: string;
  17145. };
  17146. }
  17147. declare module "babylonjs/Shaders/line.vertex" {
  17148. /** @hidden */
  17149. export var lineVertexShader: {
  17150. name: string;
  17151. shader: string;
  17152. };
  17153. }
  17154. declare module "babylonjs/Rendering/edgesRenderer" {
  17155. import { Nullable } from "babylonjs/types";
  17156. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17158. import { Vector3 } from "babylonjs/Maths/math";
  17159. import { IDisposable } from "babylonjs/scene";
  17160. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17161. import "babylonjs/Shaders/line.fragment";
  17162. import "babylonjs/Shaders/line.vertex";
  17163. module "babylonjs/Meshes/abstractMesh" {
  17164. interface AbstractMesh {
  17165. /**
  17166. * Disables the mesh edge rendering mode
  17167. * @returns the currentAbstractMesh
  17168. */
  17169. disableEdgesRendering(): AbstractMesh;
  17170. /**
  17171. * Enables the edge rendering mode on the mesh.
  17172. * This mode makes the mesh edges visible
  17173. * @param epsilon defines the maximal distance between two angles to detect a face
  17174. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17175. * @returns the currentAbstractMesh
  17176. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17177. */
  17178. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17179. /**
  17180. * Gets the edgesRenderer associated with the mesh
  17181. */
  17182. edgesRenderer: Nullable<EdgesRenderer>;
  17183. }
  17184. }
  17185. module "babylonjs/Meshes/linesMesh" {
  17186. interface LinesMesh {
  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 currentAbstractMesh
  17193. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17194. */
  17195. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17196. }
  17197. }
  17198. module "babylonjs/Meshes/linesMesh" {
  17199. interface InstancedLinesMesh {
  17200. /**
  17201. * Enables the edge rendering mode on the mesh.
  17202. * This mode makes the mesh edges visible
  17203. * @param epsilon defines the maximal distance between two angles to detect a face
  17204. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17205. * @returns the current InstancedLinesMesh
  17206. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17207. */
  17208. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17209. }
  17210. }
  17211. /**
  17212. * Defines the minimum contract an Edges renderer should follow.
  17213. */
  17214. export interface IEdgesRenderer extends IDisposable {
  17215. /**
  17216. * Gets or sets a boolean indicating if the edgesRenderer is active
  17217. */
  17218. isEnabled: boolean;
  17219. /**
  17220. * Renders the edges of the attached mesh,
  17221. */
  17222. render(): void;
  17223. /**
  17224. * Checks wether or not the edges renderer is ready to render.
  17225. * @return true if ready, otherwise false.
  17226. */
  17227. isReady(): boolean;
  17228. }
  17229. /**
  17230. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17231. */
  17232. export class EdgesRenderer implements IEdgesRenderer {
  17233. /**
  17234. * Define the size of the edges with an orthographic camera
  17235. */
  17236. edgesWidthScalerForOrthographic: number;
  17237. /**
  17238. * Define the size of the edges with a perspective camera
  17239. */
  17240. edgesWidthScalerForPerspective: number;
  17241. protected _source: AbstractMesh;
  17242. protected _linesPositions: number[];
  17243. protected _linesNormals: number[];
  17244. protected _linesIndices: number[];
  17245. protected _epsilon: number;
  17246. protected _indicesCount: number;
  17247. protected _lineShader: ShaderMaterial;
  17248. protected _ib: WebGLBuffer;
  17249. protected _buffers: {
  17250. [key: string]: Nullable<VertexBuffer>;
  17251. };
  17252. protected _checkVerticesInsteadOfIndices: boolean;
  17253. private _meshRebuildObserver;
  17254. private _meshDisposeObserver;
  17255. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17256. isEnabled: boolean;
  17257. /**
  17258. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17259. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17260. * @param source Mesh used to create edges
  17261. * @param epsilon sum of angles in adjacency to check for edge
  17262. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17263. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17264. */
  17265. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17266. protected _prepareRessources(): void;
  17267. /** @hidden */
  17268. _rebuild(): void;
  17269. /**
  17270. * Releases the required resources for the edges renderer
  17271. */
  17272. dispose(): void;
  17273. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17274. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17275. /**
  17276. * Checks if the pair of p0 and p1 is en edge
  17277. * @param faceIndex
  17278. * @param edge
  17279. * @param faceNormals
  17280. * @param p0
  17281. * @param p1
  17282. * @private
  17283. */
  17284. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17285. /**
  17286. * push line into the position, normal and index buffer
  17287. * @protected
  17288. */
  17289. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17290. /**
  17291. * Generates lines edges from adjacencjes
  17292. * @private
  17293. */
  17294. _generateEdgesLines(): void;
  17295. /**
  17296. * Checks wether or not the edges renderer is ready to render.
  17297. * @return true if ready, otherwise false.
  17298. */
  17299. isReady(): boolean;
  17300. /**
  17301. * Renders the edges of the attached mesh,
  17302. */
  17303. render(): void;
  17304. }
  17305. /**
  17306. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17307. */
  17308. export class LineEdgesRenderer extends EdgesRenderer {
  17309. /**
  17310. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17311. * @param source LineMesh used to generate edges
  17312. * @param epsilon not important (specified angle for edge detection)
  17313. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17314. */
  17315. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17316. /**
  17317. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17318. */
  17319. _generateEdgesLines(): void;
  17320. }
  17321. }
  17322. declare module "babylonjs/Rendering/renderingGroup" {
  17323. import { SmartArray } from "babylonjs/Misc/smartArray";
  17324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17326. import { Nullable } from "babylonjs/types";
  17327. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17328. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17329. import { Material } from "babylonjs/Materials/material";
  17330. import { Scene } from "babylonjs/scene";
  17331. /**
  17332. * This represents the object necessary to create a rendering group.
  17333. * This is exclusively used and created by the rendering manager.
  17334. * To modify the behavior, you use the available helpers in your scene or meshes.
  17335. * @hidden
  17336. */
  17337. export class RenderingGroup {
  17338. index: number;
  17339. private _scene;
  17340. private _opaqueSubMeshes;
  17341. private _transparentSubMeshes;
  17342. private _alphaTestSubMeshes;
  17343. private _depthOnlySubMeshes;
  17344. private _particleSystems;
  17345. private _spriteManagers;
  17346. private _opaqueSortCompareFn;
  17347. private _alphaTestSortCompareFn;
  17348. private _transparentSortCompareFn;
  17349. private _renderOpaque;
  17350. private _renderAlphaTest;
  17351. private _renderTransparent;
  17352. private _edgesRenderers;
  17353. onBeforeTransparentRendering: () => void;
  17354. /**
  17355. * Set the opaque sort comparison function.
  17356. * If null the sub meshes will be render in the order they were created
  17357. */
  17358. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17359. /**
  17360. * Set the alpha test sort comparison function.
  17361. * If null the sub meshes will be render in the order they were created
  17362. */
  17363. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17364. /**
  17365. * Set the transparent sort comparison function.
  17366. * If null the sub meshes will be render in the order they were created
  17367. */
  17368. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17369. /**
  17370. * Creates a new rendering group.
  17371. * @param index The rendering group index
  17372. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17373. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17374. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17375. */
  17376. 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>);
  17377. /**
  17378. * Render all the sub meshes contained in the group.
  17379. * @param customRenderFunction Used to override the default render behaviour of the group.
  17380. * @returns true if rendered some submeshes.
  17381. */
  17382. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17383. /**
  17384. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17385. * @param subMeshes The submeshes to render
  17386. */
  17387. private renderOpaqueSorted;
  17388. /**
  17389. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17390. * @param subMeshes The submeshes to render
  17391. */
  17392. private renderAlphaTestSorted;
  17393. /**
  17394. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private renderTransparentSorted;
  17398. /**
  17399. * Renders the submeshes in a specified order.
  17400. * @param subMeshes The submeshes to sort before render
  17401. * @param sortCompareFn The comparison function use to sort
  17402. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17403. * @param transparent Specifies to activate blending if true
  17404. */
  17405. private static renderSorted;
  17406. /**
  17407. * Renders the submeshes in the order they were dispatched (no sort applied).
  17408. * @param subMeshes The submeshes to render
  17409. */
  17410. private static renderUnsorted;
  17411. /**
  17412. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17413. * are rendered back to front if in the same alpha index.
  17414. *
  17415. * @param a The first submesh
  17416. * @param b The second submesh
  17417. * @returns The result of the comparison
  17418. */
  17419. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17420. /**
  17421. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17422. * are rendered back to front.
  17423. *
  17424. * @param a The first submesh
  17425. * @param b The second submesh
  17426. * @returns The result of the comparison
  17427. */
  17428. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17429. /**
  17430. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17431. * are rendered front to back (prevent overdraw).
  17432. *
  17433. * @param a The first submesh
  17434. * @param b The second submesh
  17435. * @returns The result of the comparison
  17436. */
  17437. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17438. /**
  17439. * Resets the different lists of submeshes to prepare a new frame.
  17440. */
  17441. prepare(): void;
  17442. dispose(): void;
  17443. /**
  17444. * Inserts the submesh in its correct queue depending on its material.
  17445. * @param subMesh The submesh to dispatch
  17446. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17447. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17448. */
  17449. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17450. dispatchSprites(spriteManager: ISpriteManager): void;
  17451. dispatchParticles(particleSystem: IParticleSystem): void;
  17452. private _renderParticles;
  17453. private _renderSprites;
  17454. }
  17455. }
  17456. declare module "babylonjs/Rendering/renderingManager" {
  17457. import { Nullable } from "babylonjs/types";
  17458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17460. import { SmartArray } from "babylonjs/Misc/smartArray";
  17461. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17462. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17463. import { Material } from "babylonjs/Materials/material";
  17464. import { Scene } from "babylonjs/scene";
  17465. import { Camera } from "babylonjs/Cameras/camera";
  17466. /**
  17467. * Interface describing the different options available in the rendering manager
  17468. * regarding Auto Clear between groups.
  17469. */
  17470. export interface IRenderingManagerAutoClearSetup {
  17471. /**
  17472. * Defines whether or not autoclear is enable.
  17473. */
  17474. autoClear: boolean;
  17475. /**
  17476. * Defines whether or not to autoclear the depth buffer.
  17477. */
  17478. depth: boolean;
  17479. /**
  17480. * Defines whether or not to autoclear the stencil buffer.
  17481. */
  17482. stencil: boolean;
  17483. }
  17484. /**
  17485. * This class is used by the onRenderingGroupObservable
  17486. */
  17487. export class RenderingGroupInfo {
  17488. /**
  17489. * The Scene that being rendered
  17490. */
  17491. scene: Scene;
  17492. /**
  17493. * The camera currently used for the rendering pass
  17494. */
  17495. camera: Nullable<Camera>;
  17496. /**
  17497. * The ID of the renderingGroup being processed
  17498. */
  17499. renderingGroupId: number;
  17500. }
  17501. /**
  17502. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17503. * It is enable to manage the different groups as well as the different necessary sort functions.
  17504. * This should not be used directly aside of the few static configurations
  17505. */
  17506. export class RenderingManager {
  17507. /**
  17508. * The max id used for rendering groups (not included)
  17509. */
  17510. static MAX_RENDERINGGROUPS: number;
  17511. /**
  17512. * The min id used for rendering groups (included)
  17513. */
  17514. static MIN_RENDERINGGROUPS: number;
  17515. /**
  17516. * Used to globally prevent autoclearing scenes.
  17517. */
  17518. static AUTOCLEAR: boolean;
  17519. /**
  17520. * @hidden
  17521. */
  17522. _useSceneAutoClearSetup: boolean;
  17523. private _scene;
  17524. private _renderingGroups;
  17525. private _depthStencilBufferAlreadyCleaned;
  17526. private _autoClearDepthStencil;
  17527. private _customOpaqueSortCompareFn;
  17528. private _customAlphaTestSortCompareFn;
  17529. private _customTransparentSortCompareFn;
  17530. private _renderingGroupInfo;
  17531. /**
  17532. * Instantiates a new rendering group for a particular scene
  17533. * @param scene Defines the scene the groups belongs to
  17534. */
  17535. constructor(scene: Scene);
  17536. private _clearDepthStencilBuffer;
  17537. /**
  17538. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17539. * @hidden
  17540. */
  17541. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17542. /**
  17543. * Resets the different information of the group to prepare a new frame
  17544. * @hidden
  17545. */
  17546. reset(): void;
  17547. /**
  17548. * Dispose and release the group and its associated resources.
  17549. * @hidden
  17550. */
  17551. dispose(): void;
  17552. /**
  17553. * Clear the info related to rendering groups preventing retention points during dispose.
  17554. */
  17555. freeRenderingGroups(): void;
  17556. private _prepareRenderingGroup;
  17557. /**
  17558. * Add a sprite manager to the rendering manager in order to render it this frame.
  17559. * @param spriteManager Define the sprite manager to render
  17560. */
  17561. dispatchSprites(spriteManager: ISpriteManager): void;
  17562. /**
  17563. * Add a particle system to the rendering manager in order to render it this frame.
  17564. * @param particleSystem Define the particle system to render
  17565. */
  17566. dispatchParticles(particleSystem: IParticleSystem): void;
  17567. /**
  17568. * Add a submesh to the manager in order to render it this frame
  17569. * @param subMesh The submesh to dispatch
  17570. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17571. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17572. */
  17573. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17574. /**
  17575. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17576. * This allowed control for front to back rendering or reversly depending of the special needs.
  17577. *
  17578. * @param renderingGroupId The rendering group id corresponding to its index
  17579. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17580. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17581. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17582. */
  17583. 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;
  17584. /**
  17585. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17586. *
  17587. * @param renderingGroupId The rendering group id corresponding to its index
  17588. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17589. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17590. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17591. */
  17592. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17593. /**
  17594. * Gets the current auto clear configuration for one rendering group of the rendering
  17595. * manager.
  17596. * @param index the rendering group index to get the information for
  17597. * @returns The auto clear setup for the requested rendering group
  17598. */
  17599. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17600. }
  17601. }
  17602. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17603. import { Observable } from "babylonjs/Misc/observable";
  17604. import { SmartArray } from "babylonjs/Misc/smartArray";
  17605. import { Nullable } from "babylonjs/types";
  17606. import { Camera } from "babylonjs/Cameras/camera";
  17607. import { Scene } from "babylonjs/scene";
  17608. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17609. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17612. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17613. import { Texture } from "babylonjs/Materials/Textures/texture";
  17614. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17615. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17616. import { Engine } from "babylonjs/Engines/engine";
  17617. /**
  17618. * This Helps creating a texture that will be created from a camera in your scene.
  17619. * It is basically a dynamic texture that could be used to create special effects for instance.
  17620. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17621. */
  17622. export class RenderTargetTexture extends Texture {
  17623. isCube: boolean;
  17624. /**
  17625. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17626. */
  17627. static readonly REFRESHRATE_RENDER_ONCE: number;
  17628. /**
  17629. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17630. */
  17631. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17632. /**
  17633. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17634. * the central point of your effect and can save a lot of performances.
  17635. */
  17636. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17637. /**
  17638. * Use this predicate to dynamically define the list of mesh you want to render.
  17639. * If set, the renderList property will be overwritten.
  17640. */
  17641. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17642. private _renderList;
  17643. /**
  17644. * Use this list to define the list of mesh you want to render.
  17645. */
  17646. renderList: Nullable<Array<AbstractMesh>>;
  17647. private _hookArray;
  17648. /**
  17649. * Define if particles should be rendered in your texture.
  17650. */
  17651. renderParticles: boolean;
  17652. /**
  17653. * Define if sprites should be rendered in your texture.
  17654. */
  17655. renderSprites: boolean;
  17656. /**
  17657. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17658. */
  17659. coordinatesMode: number;
  17660. /**
  17661. * Define the camera used to render the texture.
  17662. */
  17663. activeCamera: Nullable<Camera>;
  17664. /**
  17665. * Override the render function of the texture with your own one.
  17666. */
  17667. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17668. /**
  17669. * Define if camera post processes should be use while rendering the texture.
  17670. */
  17671. useCameraPostProcesses: boolean;
  17672. /**
  17673. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17674. */
  17675. ignoreCameraViewport: boolean;
  17676. private _postProcessManager;
  17677. private _postProcesses;
  17678. private _resizeObserver;
  17679. /**
  17680. * An event triggered when the texture is unbind.
  17681. */
  17682. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17683. /**
  17684. * An event triggered when the texture is unbind.
  17685. */
  17686. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17687. private _onAfterUnbindObserver;
  17688. /**
  17689. * Set a after unbind callback in the texture.
  17690. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17691. */
  17692. onAfterUnbind: () => void;
  17693. /**
  17694. * An event triggered before rendering the texture
  17695. */
  17696. onBeforeRenderObservable: Observable<number>;
  17697. private _onBeforeRenderObserver;
  17698. /**
  17699. * Set a before render callback in the texture.
  17700. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17701. */
  17702. onBeforeRender: (faceIndex: number) => void;
  17703. /**
  17704. * An event triggered after rendering the texture
  17705. */
  17706. onAfterRenderObservable: Observable<number>;
  17707. private _onAfterRenderObserver;
  17708. /**
  17709. * Set a after render callback in the texture.
  17710. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17711. */
  17712. onAfterRender: (faceIndex: number) => void;
  17713. /**
  17714. * An event triggered after the texture clear
  17715. */
  17716. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17717. private _onClearObserver;
  17718. /**
  17719. * Set a clear callback in the texture.
  17720. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17721. */
  17722. onClear: (Engine: Engine) => void;
  17723. /**
  17724. * Define the clear color of the Render Target if it should be different from the scene.
  17725. */
  17726. clearColor: Color4;
  17727. protected _size: number | {
  17728. width: number;
  17729. height: number;
  17730. };
  17731. protected _initialSizeParameter: number | {
  17732. width: number;
  17733. height: number;
  17734. } | {
  17735. ratio: number;
  17736. };
  17737. protected _sizeRatio: Nullable<number>;
  17738. /** @hidden */
  17739. _generateMipMaps: boolean;
  17740. protected _renderingManager: RenderingManager;
  17741. /** @hidden */
  17742. _waitingRenderList: string[];
  17743. protected _doNotChangeAspectRatio: boolean;
  17744. protected _currentRefreshId: number;
  17745. protected _refreshRate: number;
  17746. protected _textureMatrix: Matrix;
  17747. protected _samples: number;
  17748. protected _renderTargetOptions: RenderTargetCreationOptions;
  17749. /**
  17750. * Gets render target creation options that were used.
  17751. */
  17752. readonly renderTargetOptions: RenderTargetCreationOptions;
  17753. protected _engine: Engine;
  17754. protected _onRatioRescale(): void;
  17755. /**
  17756. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17757. * It must define where the camera used to render the texture is set
  17758. */
  17759. boundingBoxPosition: Vector3;
  17760. private _boundingBoxSize;
  17761. /**
  17762. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17763. * When defined, the cubemap will switch to local mode
  17764. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17765. * @example https://www.babylonjs-playground.com/#RNASML
  17766. */
  17767. boundingBoxSize: Vector3;
  17768. /**
  17769. * In case the RTT has been created with a depth texture, get the associated
  17770. * depth texture.
  17771. * Otherwise, return null.
  17772. */
  17773. depthStencilTexture: Nullable<InternalTexture>;
  17774. /**
  17775. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17776. * or used a shadow, depth texture...
  17777. * @param name The friendly name of the texture
  17778. * @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)
  17779. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17780. * @param generateMipMaps True if mip maps need to be generated after render.
  17781. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17782. * @param type The type of the buffer in the RTT (int, half float, float...)
  17783. * @param isCube True if a cube texture needs to be created
  17784. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17785. * @param generateDepthBuffer True to generate a depth buffer
  17786. * @param generateStencilBuffer True to generate a stencil buffer
  17787. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17788. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17789. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17790. */
  17791. constructor(name: string, size: number | {
  17792. width: number;
  17793. height: number;
  17794. } | {
  17795. ratio: number;
  17796. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17797. /**
  17798. * Creates a depth stencil texture.
  17799. * This is only available in WebGL 2 or with the depth texture extension available.
  17800. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17801. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17802. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17803. */
  17804. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17805. private _processSizeParameter;
  17806. /**
  17807. * Define the number of samples to use in case of MSAA.
  17808. * It defaults to one meaning no MSAA has been enabled.
  17809. */
  17810. samples: number;
  17811. /**
  17812. * Resets the refresh counter of the texture and start bak from scratch.
  17813. * Could be useful to regenerate the texture if it is setup to render only once.
  17814. */
  17815. resetRefreshCounter(): void;
  17816. /**
  17817. * Define the refresh rate of the texture or the rendering frequency.
  17818. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17819. */
  17820. refreshRate: number;
  17821. /**
  17822. * Adds a post process to the render target rendering passes.
  17823. * @param postProcess define the post process to add
  17824. */
  17825. addPostProcess(postProcess: PostProcess): void;
  17826. /**
  17827. * Clear all the post processes attached to the render target
  17828. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17829. */
  17830. clearPostProcesses(dispose?: boolean): void;
  17831. /**
  17832. * Remove one of the post process from the list of attached post processes to the texture
  17833. * @param postProcess define the post process to remove from the list
  17834. */
  17835. removePostProcess(postProcess: PostProcess): void;
  17836. /** @hidden */
  17837. _shouldRender(): boolean;
  17838. /**
  17839. * Gets the actual render size of the texture.
  17840. * @returns the width of the render size
  17841. */
  17842. getRenderSize(): number;
  17843. /**
  17844. * Gets the actual render width of the texture.
  17845. * @returns the width of the render size
  17846. */
  17847. getRenderWidth(): number;
  17848. /**
  17849. * Gets the actual render height of the texture.
  17850. * @returns the height of the render size
  17851. */
  17852. getRenderHeight(): number;
  17853. /**
  17854. * Get if the texture can be rescaled or not.
  17855. */
  17856. readonly canRescale: boolean;
  17857. /**
  17858. * Resize the texture using a ratio.
  17859. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17860. */
  17861. scale(ratio: number): void;
  17862. /**
  17863. * Get the texture reflection matrix used to rotate/transform the reflection.
  17864. * @returns the reflection matrix
  17865. */
  17866. getReflectionTextureMatrix(): Matrix;
  17867. /**
  17868. * Resize the texture to a new desired size.
  17869. * Be carrefull as it will recreate all the data in the new texture.
  17870. * @param size Define the new size. It can be:
  17871. * - a number for squared texture,
  17872. * - an object containing { width: number, height: number }
  17873. * - or an object containing a ratio { ratio: number }
  17874. */
  17875. resize(size: number | {
  17876. width: number;
  17877. height: number;
  17878. } | {
  17879. ratio: number;
  17880. }): void;
  17881. /**
  17882. * Renders all the objects from the render list into the texture.
  17883. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17884. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17885. */
  17886. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17887. private _bestReflectionRenderTargetDimension;
  17888. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17889. private renderToTarget;
  17890. /**
  17891. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17892. * This allowed control for front to back rendering or reversly depending of the special needs.
  17893. *
  17894. * @param renderingGroupId The rendering group id corresponding to its index
  17895. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17896. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17897. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17898. */
  17899. 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;
  17900. /**
  17901. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17902. *
  17903. * @param renderingGroupId The rendering group id corresponding to its index
  17904. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17905. */
  17906. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17907. /**
  17908. * Clones the texture.
  17909. * @returns the cloned texture
  17910. */
  17911. clone(): RenderTargetTexture;
  17912. /**
  17913. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17914. * @returns The JSON representation of the texture
  17915. */
  17916. serialize(): any;
  17917. /**
  17918. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17919. */
  17920. disposeFramebufferObjects(): void;
  17921. /**
  17922. * Dispose the texture and release its associated resources.
  17923. */
  17924. dispose(): void;
  17925. /** @hidden */
  17926. _rebuild(): void;
  17927. /**
  17928. * Clear the info related to rendering groups preventing retention point in material dispose.
  17929. */
  17930. freeRenderingGroups(): void;
  17931. }
  17932. }
  17933. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17934. import { Scene } from "babylonjs/scene";
  17935. import { Plane } from "babylonjs/Maths/math";
  17936. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17937. /**
  17938. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17939. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17940. * You can then easily use it as a reflectionTexture on a flat surface.
  17941. * In case the surface is not a plane, please consider relying on reflection probes.
  17942. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17943. */
  17944. export class MirrorTexture extends RenderTargetTexture {
  17945. private scene;
  17946. /**
  17947. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17948. * 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.
  17949. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17950. */
  17951. mirrorPlane: Plane;
  17952. /**
  17953. * Define the blur ratio used to blur the reflection if needed.
  17954. */
  17955. blurRatio: number;
  17956. /**
  17957. * Define the adaptive blur kernel used to blur the reflection if needed.
  17958. * This will autocompute the closest best match for the `blurKernel`
  17959. */
  17960. adaptiveBlurKernel: number;
  17961. /**
  17962. * Define the blur kernel used to blur the reflection if needed.
  17963. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17964. */
  17965. blurKernel: number;
  17966. /**
  17967. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17968. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17969. */
  17970. blurKernelX: number;
  17971. /**
  17972. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17973. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17974. */
  17975. blurKernelY: number;
  17976. private _autoComputeBlurKernel;
  17977. protected _onRatioRescale(): void;
  17978. private _updateGammaSpace;
  17979. private _imageProcessingConfigChangeObserver;
  17980. private _transformMatrix;
  17981. private _mirrorMatrix;
  17982. private _savedViewMatrix;
  17983. private _blurX;
  17984. private _blurY;
  17985. private _adaptiveBlurKernel;
  17986. private _blurKernelX;
  17987. private _blurKernelY;
  17988. private _blurRatio;
  17989. /**
  17990. * Instantiates a Mirror Texture.
  17991. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17992. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17993. * You can then easily use it as a reflectionTexture on a flat surface.
  17994. * In case the surface is not a plane, please consider relying on reflection probes.
  17995. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17996. * @param name
  17997. * @param size
  17998. * @param scene
  17999. * @param generateMipMaps
  18000. * @param type
  18001. * @param samplingMode
  18002. * @param generateDepthBuffer
  18003. */
  18004. constructor(name: string, size: number | {
  18005. width: number;
  18006. height: number;
  18007. } | {
  18008. ratio: number;
  18009. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18010. private _preparePostProcesses;
  18011. /**
  18012. * Clone the mirror texture.
  18013. * @returns the cloned texture
  18014. */
  18015. clone(): MirrorTexture;
  18016. /**
  18017. * Serialize the texture to a JSON representation you could use in Parse later on
  18018. * @returns the serialized JSON representation
  18019. */
  18020. serialize(): any;
  18021. /**
  18022. * Dispose the texture and release its associated resources.
  18023. */
  18024. dispose(): void;
  18025. }
  18026. }
  18027. declare module "babylonjs/Materials/Textures/texture" {
  18028. import { Observable } from "babylonjs/Misc/observable";
  18029. import { Nullable } from "babylonjs/types";
  18030. import { Scene } from "babylonjs/scene";
  18031. import { Matrix } from "babylonjs/Maths/math";
  18032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18033. /**
  18034. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18035. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18036. */
  18037. export class Texture extends BaseTexture {
  18038. /** @hidden */
  18039. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18040. /** @hidden */
  18041. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18042. /** @hidden */
  18043. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18044. /** nearest is mag = nearest and min = nearest and mip = linear */
  18045. static readonly NEAREST_SAMPLINGMODE: number;
  18046. /** nearest is mag = nearest and min = nearest and mip = linear */
  18047. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18048. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18049. static readonly BILINEAR_SAMPLINGMODE: number;
  18050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18051. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18052. /** Trilinear is mag = linear and min = linear and mip = linear */
  18053. static readonly TRILINEAR_SAMPLINGMODE: number;
  18054. /** Trilinear is mag = linear and min = linear and mip = linear */
  18055. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18056. /** mag = nearest and min = nearest and mip = nearest */
  18057. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18058. /** mag = nearest and min = linear and mip = nearest */
  18059. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18060. /** mag = nearest and min = linear and mip = linear */
  18061. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18062. /** mag = nearest and min = linear and mip = none */
  18063. static readonly NEAREST_LINEAR: number;
  18064. /** mag = nearest and min = nearest and mip = none */
  18065. static readonly NEAREST_NEAREST: number;
  18066. /** mag = linear and min = nearest and mip = nearest */
  18067. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18068. /** mag = linear and min = nearest and mip = linear */
  18069. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18070. /** mag = linear and min = linear and mip = none */
  18071. static readonly LINEAR_LINEAR: number;
  18072. /** mag = linear and min = nearest and mip = none */
  18073. static readonly LINEAR_NEAREST: number;
  18074. /** Explicit coordinates mode */
  18075. static readonly EXPLICIT_MODE: number;
  18076. /** Spherical coordinates mode */
  18077. static readonly SPHERICAL_MODE: number;
  18078. /** Planar coordinates mode */
  18079. static readonly PLANAR_MODE: number;
  18080. /** Cubic coordinates mode */
  18081. static readonly CUBIC_MODE: number;
  18082. /** Projection coordinates mode */
  18083. static readonly PROJECTION_MODE: number;
  18084. /** Inverse Cubic coordinates mode */
  18085. static readonly SKYBOX_MODE: number;
  18086. /** Inverse Cubic coordinates mode */
  18087. static readonly INVCUBIC_MODE: number;
  18088. /** Equirectangular coordinates mode */
  18089. static readonly EQUIRECTANGULAR_MODE: number;
  18090. /** Equirectangular Fixed coordinates mode */
  18091. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18092. /** Equirectangular Fixed Mirrored coordinates mode */
  18093. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18094. /** Texture is not repeating outside of 0..1 UVs */
  18095. static readonly CLAMP_ADDRESSMODE: number;
  18096. /** Texture is repeating outside of 0..1 UVs */
  18097. static readonly WRAP_ADDRESSMODE: number;
  18098. /** Texture is repeating and mirrored */
  18099. static readonly MIRROR_ADDRESSMODE: number;
  18100. /**
  18101. * 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
  18102. */
  18103. static UseSerializedUrlIfAny: boolean;
  18104. /**
  18105. * Define the url of the texture.
  18106. */
  18107. url: Nullable<string>;
  18108. /**
  18109. * Define an offset on the texture to offset the u coordinates of the UVs
  18110. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18111. */
  18112. uOffset: number;
  18113. /**
  18114. * Define an offset on the texture to offset the v coordinates of the UVs
  18115. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18116. */
  18117. vOffset: number;
  18118. /**
  18119. * Define an offset on the texture to scale the u coordinates of the UVs
  18120. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18121. */
  18122. uScale: number;
  18123. /**
  18124. * Define an offset on the texture to scale the v coordinates of the UVs
  18125. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18126. */
  18127. vScale: number;
  18128. /**
  18129. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18130. * @see http://doc.babylonjs.com/how_to/more_materials
  18131. */
  18132. uAng: number;
  18133. /**
  18134. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18135. * @see http://doc.babylonjs.com/how_to/more_materials
  18136. */
  18137. vAng: number;
  18138. /**
  18139. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18140. * @see http://doc.babylonjs.com/how_to/more_materials
  18141. */
  18142. wAng: number;
  18143. /**
  18144. * Defines the center of rotation (U)
  18145. */
  18146. uRotationCenter: number;
  18147. /**
  18148. * Defines the center of rotation (V)
  18149. */
  18150. vRotationCenter: number;
  18151. /**
  18152. * Defines the center of rotation (W)
  18153. */
  18154. wRotationCenter: number;
  18155. /**
  18156. * Are mip maps generated for this texture or not.
  18157. */
  18158. readonly noMipmap: boolean;
  18159. private _noMipmap;
  18160. /** @hidden */
  18161. _invertY: boolean;
  18162. private _rowGenerationMatrix;
  18163. private _cachedTextureMatrix;
  18164. private _projectionModeMatrix;
  18165. private _t0;
  18166. private _t1;
  18167. private _t2;
  18168. private _cachedUOffset;
  18169. private _cachedVOffset;
  18170. private _cachedUScale;
  18171. private _cachedVScale;
  18172. private _cachedUAng;
  18173. private _cachedVAng;
  18174. private _cachedWAng;
  18175. private _cachedProjectionMatrixId;
  18176. private _cachedCoordinatesMode;
  18177. /** @hidden */
  18178. protected _initialSamplingMode: number;
  18179. /** @hidden */
  18180. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18181. private _deleteBuffer;
  18182. protected _format: Nullable<number>;
  18183. private _delayedOnLoad;
  18184. private _delayedOnError;
  18185. /**
  18186. * Observable triggered once the texture has been loaded.
  18187. */
  18188. onLoadObservable: Observable<Texture>;
  18189. protected _isBlocking: boolean;
  18190. /**
  18191. * Is the texture preventing material to render while loading.
  18192. * If false, a default texture will be used instead of the loading one during the preparation step.
  18193. */
  18194. isBlocking: boolean;
  18195. /**
  18196. * Get the current sampling mode associated with the texture.
  18197. */
  18198. readonly samplingMode: number;
  18199. /**
  18200. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18201. */
  18202. readonly invertY: boolean;
  18203. /**
  18204. * Instantiates a new texture.
  18205. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18206. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18207. * @param url define the url of the picture to load as a texture
  18208. * @param scene define the scene the texture will belong to
  18209. * @param noMipmap define if the texture will require mip maps or not
  18210. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18211. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18212. * @param onLoad define a callback triggered when the texture has been loaded
  18213. * @param onError define a callback triggered when an error occurred during the loading session
  18214. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18215. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18217. */
  18218. 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);
  18219. /**
  18220. * Update the url (and optional buffer) of this texture if url was null during construction.
  18221. * @param url the url of the texture
  18222. * @param buffer the buffer of the texture (defaults to null)
  18223. * @param onLoad callback called when the texture is loaded (defaults to null)
  18224. */
  18225. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18226. /**
  18227. * Finish the loading sequence of a texture flagged as delayed load.
  18228. * @hidden
  18229. */
  18230. delayLoad(): void;
  18231. private _prepareRowForTextureGeneration;
  18232. /**
  18233. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18234. * @returns the transform matrix of the texture.
  18235. */
  18236. getTextureMatrix(): Matrix;
  18237. /**
  18238. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18239. * @returns The reflection texture transform
  18240. */
  18241. getReflectionTextureMatrix(): Matrix;
  18242. /**
  18243. * Clones the texture.
  18244. * @returns the cloned texture
  18245. */
  18246. clone(): Texture;
  18247. /**
  18248. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18249. * @returns The JSON representation of the texture
  18250. */
  18251. serialize(): any;
  18252. /**
  18253. * Get the current class name of the texture useful for serialization or dynamic coding.
  18254. * @returns "Texture"
  18255. */
  18256. getClassName(): string;
  18257. /**
  18258. * Dispose the texture and release its associated resources.
  18259. */
  18260. dispose(): void;
  18261. /**
  18262. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18263. * @param parsedTexture Define the JSON representation of the texture
  18264. * @param scene Define the scene the parsed texture should be instantiated in
  18265. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18266. * @returns The parsed texture if successful
  18267. */
  18268. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18269. /**
  18270. * Creates a texture from its base 64 representation.
  18271. * @param data Define the base64 payload without the data: prefix
  18272. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18273. * @param scene Define the scene the texture should belong to
  18274. * @param noMipmap Forces the texture to not create mip map information if true
  18275. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18276. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18277. * @param onLoad define a callback triggered when the texture has been loaded
  18278. * @param onError define a callback triggered when an error occurred during the loading session
  18279. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18280. * @returns the created texture
  18281. */
  18282. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18283. /**
  18284. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18285. * @param data Define the base64 payload without the data: prefix
  18286. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18287. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18288. * @param scene Define the scene the texture should belong to
  18289. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18290. * @param noMipmap Forces the texture to not create mip map information if true
  18291. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18292. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18293. * @param onLoad define a callback triggered when the texture has been loaded
  18294. * @param onError define a callback triggered when an error occurred during the loading session
  18295. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18296. * @returns the created texture
  18297. */
  18298. 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;
  18299. }
  18300. }
  18301. declare module "babylonjs/Materials/Textures/rawTexture" {
  18302. import { Scene } from "babylonjs/scene";
  18303. import { Texture } from "babylonjs/Materials/Textures/texture";
  18304. /**
  18305. * Raw texture can help creating a texture directly from an array of data.
  18306. * This can be super useful if you either get the data from an uncompressed source or
  18307. * if you wish to create your texture pixel by pixel.
  18308. */
  18309. export class RawTexture extends Texture {
  18310. /**
  18311. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18312. */
  18313. format: number;
  18314. private _engine;
  18315. /**
  18316. * Instantiates a new RawTexture.
  18317. * Raw texture can help creating a texture directly from an array of data.
  18318. * This can be super useful if you either get the data from an uncompressed source or
  18319. * if you wish to create your texture pixel by pixel.
  18320. * @param data define the array of data to use to create the texture
  18321. * @param width define the width of the texture
  18322. * @param height define the height of the texture
  18323. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18324. * @param scene define the scene the texture belongs to
  18325. * @param generateMipMaps define whether mip maps should be generated or not
  18326. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18327. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18328. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18329. */
  18330. constructor(data: ArrayBufferView, width: number, height: number,
  18331. /**
  18332. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18333. */
  18334. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18335. /**
  18336. * Updates the texture underlying data.
  18337. * @param data Define the new data of the texture
  18338. */
  18339. update(data: ArrayBufferView): void;
  18340. /**
  18341. * Creates a luminance texture from some data.
  18342. * @param data Define the texture data
  18343. * @param width Define the width of the texture
  18344. * @param height Define the height of the texture
  18345. * @param scene Define the scene the texture belongs to
  18346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18349. * @returns the luminance texture
  18350. */
  18351. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18352. /**
  18353. * Creates a luminance alpha texture from some data.
  18354. * @param data Define the texture data
  18355. * @param width Define the width of the texture
  18356. * @param height Define the height of the texture
  18357. * @param scene Define the scene the texture belongs to
  18358. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18359. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18360. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18361. * @returns the luminance alpha texture
  18362. */
  18363. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18364. /**
  18365. * Creates an alpha texture from some data.
  18366. * @param data Define the texture data
  18367. * @param width Define the width of the texture
  18368. * @param height Define the height of the texture
  18369. * @param scene Define the scene the texture belongs to
  18370. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18371. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18372. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18373. * @returns the alpha texture
  18374. */
  18375. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18376. /**
  18377. * Creates a RGB 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 RGB alpha texture
  18387. */
  18388. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18389. /**
  18390. * Creates a RGBA 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 RGBA texture
  18400. */
  18401. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18402. /**
  18403. * Creates a R texture from some data.
  18404. * @param data Define the texture data
  18405. * @param width Define the width of the texture
  18406. * @param height Define the height of the texture
  18407. * @param scene Define the scene the texture belongs to
  18408. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18409. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18410. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18411. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18412. * @returns the R texture
  18413. */
  18414. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18415. }
  18416. }
  18417. declare module "babylonjs/Animations/runtimeAnimation" {
  18418. import { Animation } from "babylonjs/Animations/animation";
  18419. import { Animatable } from "babylonjs/Animations/animatable";
  18420. import { Scene } from "babylonjs/scene";
  18421. /**
  18422. * Defines a runtime animation
  18423. */
  18424. export class RuntimeAnimation {
  18425. private _events;
  18426. /**
  18427. * The current frame of the runtime animation
  18428. */
  18429. private _currentFrame;
  18430. /**
  18431. * The animation used by the runtime animation
  18432. */
  18433. private _animation;
  18434. /**
  18435. * The target of the runtime animation
  18436. */
  18437. private _target;
  18438. /**
  18439. * The initiating animatable
  18440. */
  18441. private _host;
  18442. /**
  18443. * The original value of the runtime animation
  18444. */
  18445. private _originalValue;
  18446. /**
  18447. * The original blend value of the runtime animation
  18448. */
  18449. private _originalBlendValue;
  18450. /**
  18451. * The offsets cache of the runtime animation
  18452. */
  18453. private _offsetsCache;
  18454. /**
  18455. * The high limits cache of the runtime animation
  18456. */
  18457. private _highLimitsCache;
  18458. /**
  18459. * Specifies if the runtime animation has been stopped
  18460. */
  18461. private _stopped;
  18462. /**
  18463. * The blending factor of the runtime animation
  18464. */
  18465. private _blendingFactor;
  18466. /**
  18467. * The BabylonJS scene
  18468. */
  18469. private _scene;
  18470. /**
  18471. * The current value of the runtime animation
  18472. */
  18473. private _currentValue;
  18474. /** @hidden */
  18475. _workValue: any;
  18476. /**
  18477. * The active target of the runtime animation
  18478. */
  18479. private _activeTarget;
  18480. /**
  18481. * The target path of the runtime animation
  18482. */
  18483. private _targetPath;
  18484. /**
  18485. * The weight of the runtime animation
  18486. */
  18487. private _weight;
  18488. /**
  18489. * The ratio offset of the runtime animation
  18490. */
  18491. private _ratioOffset;
  18492. /**
  18493. * The previous delay of the runtime animation
  18494. */
  18495. private _previousDelay;
  18496. /**
  18497. * The previous ratio of the runtime animation
  18498. */
  18499. private _previousRatio;
  18500. /**
  18501. * Gets the current frame of the runtime animation
  18502. */
  18503. readonly currentFrame: number;
  18504. /**
  18505. * Gets the weight of the runtime animation
  18506. */
  18507. readonly weight: number;
  18508. /**
  18509. * Gets the current value of the runtime animation
  18510. */
  18511. readonly currentValue: any;
  18512. /**
  18513. * Gets the target path of the runtime animation
  18514. */
  18515. readonly targetPath: string;
  18516. /**
  18517. * Gets the actual target of the runtime animation
  18518. */
  18519. readonly target: any;
  18520. /**
  18521. * Create a new RuntimeAnimation object
  18522. * @param target defines the target of the animation
  18523. * @param animation defines the source animation object
  18524. * @param scene defines the hosting scene
  18525. * @param host defines the initiating Animatable
  18526. */
  18527. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18528. /**
  18529. * Gets the animation from the runtime animation
  18530. */
  18531. readonly animation: Animation;
  18532. /**
  18533. * Resets the runtime animation to the beginning
  18534. * @param restoreOriginal defines whether to restore the target property to the original value
  18535. */
  18536. reset(restoreOriginal?: boolean): void;
  18537. /**
  18538. * Specifies if the runtime animation is stopped
  18539. * @returns Boolean specifying if the runtime animation is stopped
  18540. */
  18541. isStopped(): boolean;
  18542. /**
  18543. * Disposes of the runtime animation
  18544. */
  18545. dispose(): void;
  18546. /**
  18547. * Interpolates the animation from the current frame
  18548. * @param currentFrame The frame to interpolate the animation to
  18549. * @param repeatCount The number of times that the animation should loop
  18550. * @param loopMode The type of looping mode to use
  18551. * @param offsetValue Animation offset value
  18552. * @param highLimitValue The high limit value
  18553. * @returns The interpolated value
  18554. */
  18555. private _interpolate;
  18556. /**
  18557. * Apply the interpolated value to the target
  18558. * @param currentValue defines the value computed by the animation
  18559. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18560. */
  18561. setValue(currentValue: any, weight?: number): void;
  18562. private _setValue;
  18563. /**
  18564. * Gets the loop pmode of the runtime animation
  18565. * @returns Loop Mode
  18566. */
  18567. private _getCorrectLoopMode;
  18568. /**
  18569. * Move the current animation to a given frame
  18570. * @param frame defines the frame to move to
  18571. */
  18572. goToFrame(frame: number): void;
  18573. /**
  18574. * @hidden Internal use only
  18575. */
  18576. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18577. /**
  18578. * Execute the current animation
  18579. * @param delay defines the delay to add to the current frame
  18580. * @param from defines the lower bound of the animation range
  18581. * @param to defines the upper bound of the animation range
  18582. * @param loop defines if the current animation must loop
  18583. * @param speedRatio defines the current speed ratio
  18584. * @param weight defines the weight of the animation (default is -1 so no weight)
  18585. * @param onLoop optional callback called when animation loops
  18586. * @returns a boolean indicating if the animation is running
  18587. */
  18588. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18589. }
  18590. }
  18591. declare module "babylonjs/Animations/animatable" {
  18592. import { Animation } from "babylonjs/Animations/animation";
  18593. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18594. import { Nullable } from "babylonjs/types";
  18595. import { Observable } from "babylonjs/Misc/observable";
  18596. import { Scene } from "babylonjs/scene";
  18597. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18598. import { Node } from "babylonjs/node";
  18599. /**
  18600. * Class used to store an actual running animation
  18601. */
  18602. export class Animatable {
  18603. /** defines the target object */
  18604. target: any;
  18605. /** defines the starting frame number (default is 0) */
  18606. fromFrame: number;
  18607. /** defines the ending frame number (default is 100) */
  18608. toFrame: number;
  18609. /** defines if the animation must loop (default is false) */
  18610. loopAnimation: boolean;
  18611. /** defines a callback to call when animation ends if it is not looping */
  18612. onAnimationEnd?: (() => void) | null | undefined;
  18613. /** defines a callback to call when animation loops */
  18614. onAnimationLoop?: (() => void) | null | undefined;
  18615. private _localDelayOffset;
  18616. private _pausedDelay;
  18617. private _runtimeAnimations;
  18618. private _paused;
  18619. private _scene;
  18620. private _speedRatio;
  18621. private _weight;
  18622. private _syncRoot;
  18623. /**
  18624. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18625. * This will only apply for non looping animation (default is true)
  18626. */
  18627. disposeOnEnd: boolean;
  18628. /**
  18629. * Gets a boolean indicating if the animation has started
  18630. */
  18631. animationStarted: boolean;
  18632. /**
  18633. * Observer raised when the animation ends
  18634. */
  18635. onAnimationEndObservable: Observable<Animatable>;
  18636. /**
  18637. * Observer raised when the animation loops
  18638. */
  18639. onAnimationLoopObservable: Observable<Animatable>;
  18640. /**
  18641. * Gets the root Animatable used to synchronize and normalize animations
  18642. */
  18643. readonly syncRoot: Animatable;
  18644. /**
  18645. * Gets the current frame of the first RuntimeAnimation
  18646. * Used to synchronize Animatables
  18647. */
  18648. readonly masterFrame: number;
  18649. /**
  18650. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18651. */
  18652. weight: number;
  18653. /**
  18654. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18655. */
  18656. speedRatio: number;
  18657. /**
  18658. * Creates a new Animatable
  18659. * @param scene defines the hosting scene
  18660. * @param target defines the target object
  18661. * @param fromFrame defines the starting frame number (default is 0)
  18662. * @param toFrame defines the ending frame number (default is 100)
  18663. * @param loopAnimation defines if the animation must loop (default is false)
  18664. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18665. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18666. * @param animations defines a group of animation to add to the new Animatable
  18667. * @param onAnimationLoop defines a callback to call when animation loops
  18668. */
  18669. constructor(scene: Scene,
  18670. /** defines the target object */
  18671. target: any,
  18672. /** defines the starting frame number (default is 0) */
  18673. fromFrame?: number,
  18674. /** defines the ending frame number (default is 100) */
  18675. toFrame?: number,
  18676. /** defines if the animation must loop (default is false) */
  18677. loopAnimation?: boolean, speedRatio?: number,
  18678. /** defines a callback to call when animation ends if it is not looping */
  18679. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18680. /** defines a callback to call when animation loops */
  18681. onAnimationLoop?: (() => void) | null | undefined);
  18682. /**
  18683. * Synchronize and normalize current Animatable with a source Animatable
  18684. * This is useful when using animation weights and when animations are not of the same length
  18685. * @param root defines the root Animatable to synchronize with
  18686. * @returns the current Animatable
  18687. */
  18688. syncWith(root: Animatable): Animatable;
  18689. /**
  18690. * Gets the list of runtime animations
  18691. * @returns an array of RuntimeAnimation
  18692. */
  18693. getAnimations(): RuntimeAnimation[];
  18694. /**
  18695. * Adds more animations to the current animatable
  18696. * @param target defines the target of the animations
  18697. * @param animations defines the new animations to add
  18698. */
  18699. appendAnimations(target: any, animations: Animation[]): void;
  18700. /**
  18701. * Gets the source animation for a specific property
  18702. * @param property defines the propertyu to look for
  18703. * @returns null or the source animation for the given property
  18704. */
  18705. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18706. /**
  18707. * Gets the runtime animation for a specific property
  18708. * @param property defines the propertyu to look for
  18709. * @returns null or the runtime animation for the given property
  18710. */
  18711. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18712. /**
  18713. * Resets the animatable to its original state
  18714. */
  18715. reset(): void;
  18716. /**
  18717. * Allows the animatable to blend with current running animations
  18718. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18719. * @param blendingSpeed defines the blending speed to use
  18720. */
  18721. enableBlending(blendingSpeed: number): void;
  18722. /**
  18723. * Disable animation blending
  18724. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18725. */
  18726. disableBlending(): void;
  18727. /**
  18728. * Jump directly to a given frame
  18729. * @param frame defines the frame to jump to
  18730. */
  18731. goToFrame(frame: number): void;
  18732. /**
  18733. * Pause the animation
  18734. */
  18735. pause(): void;
  18736. /**
  18737. * Restart the animation
  18738. */
  18739. restart(): void;
  18740. private _raiseOnAnimationEnd;
  18741. /**
  18742. * Stop and delete the current animation
  18743. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18744. * @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)
  18745. */
  18746. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18747. /**
  18748. * Wait asynchronously for the animation to end
  18749. * @returns a promise which will be fullfilled when the animation ends
  18750. */
  18751. waitAsync(): Promise<Animatable>;
  18752. /** @hidden */
  18753. _animate(delay: number): boolean;
  18754. }
  18755. module "babylonjs/scene" {
  18756. interface Scene {
  18757. /** @hidden */
  18758. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18759. /** @hidden */
  18760. _processLateAnimationBindingsForMatrices(holder: {
  18761. totalWeight: number;
  18762. animations: RuntimeAnimation[];
  18763. originalValue: Matrix;
  18764. }): any;
  18765. /** @hidden */
  18766. _processLateAnimationBindingsForQuaternions(holder: {
  18767. totalWeight: number;
  18768. animations: RuntimeAnimation[];
  18769. originalValue: Quaternion;
  18770. }, refQuaternion: Quaternion): Quaternion;
  18771. /** @hidden */
  18772. _processLateAnimationBindings(): void;
  18773. /**
  18774. * Will start the animation sequence of a given target
  18775. * @param target defines the target
  18776. * @param from defines from which frame should animation start
  18777. * @param to defines until which frame should animation run.
  18778. * @param weight defines the weight to apply to the animation (1.0 by default)
  18779. * @param loop defines if the animation loops
  18780. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18781. * @param onAnimationEnd defines the function to be executed when the animation ends
  18782. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18783. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18784. * @param onAnimationLoop defines the callback to call when an animation loops
  18785. * @returns the animatable object created for this animation
  18786. */
  18787. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18788. /**
  18789. * Will start the animation sequence of a given target
  18790. * @param target defines the target
  18791. * @param from defines from which frame should animation start
  18792. * @param to defines until which frame should animation run.
  18793. * @param loop defines if the animation loops
  18794. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18795. * @param onAnimationEnd defines the function to be executed when the animation ends
  18796. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18797. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18798. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18799. * @param onAnimationLoop defines the callback to call when an animation loops
  18800. * @returns the animatable object created for this animation
  18801. */
  18802. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18803. /**
  18804. * Will start the animation sequence of a given target and its hierarchy
  18805. * @param target defines the target
  18806. * @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.
  18807. * @param from defines from which frame should animation start
  18808. * @param to defines until which frame should animation run.
  18809. * @param loop defines if the animation loops
  18810. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18811. * @param onAnimationEnd defines the function to be executed when the animation ends
  18812. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18813. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18814. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18815. * @param onAnimationLoop defines the callback to call when an animation loops
  18816. * @returns the list of created animatables
  18817. */
  18818. 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[];
  18819. /**
  18820. * Begin a new animation on a given node
  18821. * @param target defines the target where the animation will take place
  18822. * @param animations defines the list of animations to start
  18823. * @param from defines the initial value
  18824. * @param to defines the final value
  18825. * @param loop defines if you want animation to loop (off by default)
  18826. * @param speedRatio defines the speed ratio to apply to all animations
  18827. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18828. * @param onAnimationLoop defines the callback to call when an animation loops
  18829. * @returns the list of created animatables
  18830. */
  18831. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18832. /**
  18833. * Begin a new animation on a given node and its hierarchy
  18834. * @param target defines the root node where the animation will take place
  18835. * @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.
  18836. * @param animations defines the list of animations to start
  18837. * @param from defines the initial value
  18838. * @param to defines the final value
  18839. * @param loop defines if you want animation to loop (off by default)
  18840. * @param speedRatio defines the speed ratio to apply to all animations
  18841. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18842. * @param onAnimationLoop defines the callback to call when an animation loops
  18843. * @returns the list of animatables created for all nodes
  18844. */
  18845. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18846. /**
  18847. * Gets the animatable associated with a specific target
  18848. * @param target defines the target of the animatable
  18849. * @returns the required animatable if found
  18850. */
  18851. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18852. /**
  18853. * Gets all animatables associated with a given target
  18854. * @param target defines the target to look animatables for
  18855. * @returns an array of Animatables
  18856. */
  18857. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18858. /**
  18859. * Will stop the animation of the given target
  18860. * @param target - the target
  18861. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18862. * @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)
  18863. */
  18864. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18865. /**
  18866. * Stops and removes all animations that have been applied to the scene
  18867. */
  18868. stopAllAnimations(): void;
  18869. }
  18870. }
  18871. module "babylonjs/Bones/bone" {
  18872. interface Bone {
  18873. /**
  18874. * Copy an animation range from another bone
  18875. * @param source defines the source bone
  18876. * @param rangeName defines the range name to copy
  18877. * @param frameOffset defines the frame offset
  18878. * @param rescaleAsRequired defines if rescaling must be applied if required
  18879. * @param skelDimensionsRatio defines the scaling ratio
  18880. * @returns true if operation was successful
  18881. */
  18882. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18883. }
  18884. }
  18885. }
  18886. declare module "babylonjs/Bones/skeleton" {
  18887. import { Bone } from "babylonjs/Bones/bone";
  18888. import { IAnimatable } from "babylonjs/Misc/tools";
  18889. import { Observable } from "babylonjs/Misc/observable";
  18890. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18891. import { Scene } from "babylonjs/scene";
  18892. import { Nullable } from "babylonjs/types";
  18893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18894. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18895. import { Animatable } from "babylonjs/Animations/animatable";
  18896. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18897. import { Animation } from "babylonjs/Animations/animation";
  18898. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18899. /**
  18900. * Class used to handle skinning animations
  18901. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18902. */
  18903. export class Skeleton implements IAnimatable {
  18904. /** defines the skeleton name */
  18905. name: string;
  18906. /** defines the skeleton Id */
  18907. id: string;
  18908. /**
  18909. * Defines the list of child bones
  18910. */
  18911. bones: Bone[];
  18912. /**
  18913. * Defines an estimate of the dimension of the skeleton at rest
  18914. */
  18915. dimensionsAtRest: Vector3;
  18916. /**
  18917. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18918. */
  18919. needInitialSkinMatrix: boolean;
  18920. /**
  18921. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18922. */
  18923. overrideMesh: Nullable<AbstractMesh>;
  18924. /**
  18925. * Gets the list of animations attached to this skeleton
  18926. */
  18927. animations: Array<Animation>;
  18928. private _scene;
  18929. private _isDirty;
  18930. private _transformMatrices;
  18931. private _transformMatrixTexture;
  18932. private _meshesWithPoseMatrix;
  18933. private _animatables;
  18934. private _identity;
  18935. private _synchronizedWithMesh;
  18936. private _ranges;
  18937. private _lastAbsoluteTransformsUpdateId;
  18938. private _canUseTextureForBones;
  18939. /** @hidden */
  18940. _numBonesWithLinkedTransformNode: number;
  18941. /**
  18942. * Specifies if the skeleton should be serialized
  18943. */
  18944. doNotSerialize: boolean;
  18945. /**
  18946. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18947. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18948. */
  18949. useTextureToStoreBoneMatrices: boolean;
  18950. private _animationPropertiesOverride;
  18951. /**
  18952. * Gets or sets the animation properties override
  18953. */
  18954. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18955. /**
  18956. * An observable triggered before computing the skeleton's matrices
  18957. */
  18958. onBeforeComputeObservable: Observable<Skeleton>;
  18959. /**
  18960. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18961. */
  18962. readonly isUsingTextureForMatrices: boolean;
  18963. /**
  18964. * Creates a new skeleton
  18965. * @param name defines the skeleton name
  18966. * @param id defines the skeleton Id
  18967. * @param scene defines the hosting scene
  18968. */
  18969. constructor(
  18970. /** defines the skeleton name */
  18971. name: string,
  18972. /** defines the skeleton Id */
  18973. id: string, scene: Scene);
  18974. /**
  18975. * Gets the current object class name.
  18976. * @return the class name
  18977. */
  18978. getClassName(): string;
  18979. /**
  18980. * Returns an array containing the root bones
  18981. * @returns an array containing the root bones
  18982. */
  18983. getChildren(): Array<Bone>;
  18984. /**
  18985. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18986. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18987. * @returns a Float32Array containing matrices data
  18988. */
  18989. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18990. /**
  18991. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18992. * @returns a raw texture containing the data
  18993. */
  18994. getTransformMatrixTexture(): Nullable<RawTexture>;
  18995. /**
  18996. * Gets the current hosting scene
  18997. * @returns a scene object
  18998. */
  18999. getScene(): Scene;
  19000. /**
  19001. * Gets a string representing the current skeleton data
  19002. * @param fullDetails defines a boolean indicating if we want a verbose version
  19003. * @returns a string representing the current skeleton data
  19004. */
  19005. toString(fullDetails?: boolean): string;
  19006. /**
  19007. * Get bone's index searching by name
  19008. * @param name defines bone's name to search for
  19009. * @return the indice of the bone. Returns -1 if not found
  19010. */
  19011. getBoneIndexByName(name: string): number;
  19012. /**
  19013. * Creater a new animation range
  19014. * @param name defines the name of the range
  19015. * @param from defines the start key
  19016. * @param to defines the end key
  19017. */
  19018. createAnimationRange(name: string, from: number, to: number): void;
  19019. /**
  19020. * Delete a specific animation range
  19021. * @param name defines the name of the range
  19022. * @param deleteFrames defines if frames must be removed as well
  19023. */
  19024. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19025. /**
  19026. * Gets a specific animation range
  19027. * @param name defines the name of the range to look for
  19028. * @returns the requested animation range or null if not found
  19029. */
  19030. getAnimationRange(name: string): Nullable<AnimationRange>;
  19031. /**
  19032. * Gets the list of all animation ranges defined on this skeleton
  19033. * @returns an array
  19034. */
  19035. getAnimationRanges(): Nullable<AnimationRange>[];
  19036. /**
  19037. * Copy animation range from a source skeleton.
  19038. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19039. * @param source defines the source skeleton
  19040. * @param name defines the name of the range to copy
  19041. * @param rescaleAsRequired defines if rescaling must be applied if required
  19042. * @returns true if operation was successful
  19043. */
  19044. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19045. /**
  19046. * Forces the skeleton to go to rest pose
  19047. */
  19048. returnToRest(): void;
  19049. private _getHighestAnimationFrame;
  19050. /**
  19051. * Begin a specific animation range
  19052. * @param name defines the name of the range to start
  19053. * @param loop defines if looping must be turned on (false by default)
  19054. * @param speedRatio defines the speed ratio to apply (1 by default)
  19055. * @param onAnimationEnd defines a callback which will be called when animation will end
  19056. * @returns a new animatable
  19057. */
  19058. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19059. /** @hidden */
  19060. _markAsDirty(): void;
  19061. /** @hidden */
  19062. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19063. /** @hidden */
  19064. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19065. private _computeTransformMatrices;
  19066. /**
  19067. * Build all resources required to render a skeleton
  19068. */
  19069. prepare(): void;
  19070. /**
  19071. * Gets the list of animatables currently running for this skeleton
  19072. * @returns an array of animatables
  19073. */
  19074. getAnimatables(): IAnimatable[];
  19075. /**
  19076. * Clone the current skeleton
  19077. * @param name defines the name of the new skeleton
  19078. * @param id defines the id of the enw skeleton
  19079. * @returns the new skeleton
  19080. */
  19081. clone(name: string, id: string): Skeleton;
  19082. /**
  19083. * Enable animation blending for this skeleton
  19084. * @param blendingSpeed defines the blending speed to apply
  19085. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19086. */
  19087. enableBlending(blendingSpeed?: number): void;
  19088. /**
  19089. * Releases all resources associated with the current skeleton
  19090. */
  19091. dispose(): void;
  19092. /**
  19093. * Serialize the skeleton in a JSON object
  19094. * @returns a JSON object
  19095. */
  19096. serialize(): any;
  19097. /**
  19098. * Creates a new skeleton from serialized data
  19099. * @param parsedSkeleton defines the serialized data
  19100. * @param scene defines the hosting scene
  19101. * @returns a new skeleton
  19102. */
  19103. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19104. /**
  19105. * Compute all node absolute transforms
  19106. * @param forceUpdate defines if computation must be done even if cache is up to date
  19107. */
  19108. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19109. /**
  19110. * Gets the root pose matrix
  19111. * @returns a matrix
  19112. */
  19113. getPoseMatrix(): Nullable<Matrix>;
  19114. /**
  19115. * Sorts bones per internal index
  19116. */
  19117. sortBones(): void;
  19118. private _sortBones;
  19119. }
  19120. }
  19121. declare module "babylonjs/Morph/morphTarget" {
  19122. import { IAnimatable } from "babylonjs/Misc/tools";
  19123. import { Observable } from "babylonjs/Misc/observable";
  19124. import { Nullable, FloatArray } from "babylonjs/types";
  19125. import { Scene } from "babylonjs/scene";
  19126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19127. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19128. /**
  19129. * Defines a target to use with MorphTargetManager
  19130. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19131. */
  19132. export class MorphTarget implements IAnimatable {
  19133. /** defines the name of the target */
  19134. name: string;
  19135. /**
  19136. * Gets or sets the list of animations
  19137. */
  19138. animations: import("babylonjs/Animations/animation").Animation[];
  19139. private _scene;
  19140. private _positions;
  19141. private _normals;
  19142. private _tangents;
  19143. private _influence;
  19144. /**
  19145. * Observable raised when the influence changes
  19146. */
  19147. onInfluenceChanged: Observable<boolean>;
  19148. /** @hidden */
  19149. _onDataLayoutChanged: Observable<void>;
  19150. /**
  19151. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19152. */
  19153. influence: number;
  19154. /**
  19155. * Gets or sets the id of the morph Target
  19156. */
  19157. id: string;
  19158. private _animationPropertiesOverride;
  19159. /**
  19160. * Gets or sets the animation properties override
  19161. */
  19162. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19163. /**
  19164. * Creates a new MorphTarget
  19165. * @param name defines the name of the target
  19166. * @param influence defines the influence to use
  19167. * @param scene defines the scene the morphtarget belongs to
  19168. */
  19169. constructor(
  19170. /** defines the name of the target */
  19171. name: string, influence?: number, scene?: Nullable<Scene>);
  19172. /**
  19173. * Gets a boolean defining if the target contains position data
  19174. */
  19175. readonly hasPositions: boolean;
  19176. /**
  19177. * Gets a boolean defining if the target contains normal data
  19178. */
  19179. readonly hasNormals: boolean;
  19180. /**
  19181. * Gets a boolean defining if the target contains tangent data
  19182. */
  19183. readonly hasTangents: boolean;
  19184. /**
  19185. * Affects position data to this target
  19186. * @param data defines the position data to use
  19187. */
  19188. setPositions(data: Nullable<FloatArray>): void;
  19189. /**
  19190. * Gets the position data stored in this target
  19191. * @returns a FloatArray containing the position data (or null if not present)
  19192. */
  19193. getPositions(): Nullable<FloatArray>;
  19194. /**
  19195. * Affects normal data to this target
  19196. * @param data defines the normal data to use
  19197. */
  19198. setNormals(data: Nullable<FloatArray>): void;
  19199. /**
  19200. * Gets the normal data stored in this target
  19201. * @returns a FloatArray containing the normal data (or null if not present)
  19202. */
  19203. getNormals(): Nullable<FloatArray>;
  19204. /**
  19205. * Affects tangent data to this target
  19206. * @param data defines the tangent data to use
  19207. */
  19208. setTangents(data: Nullable<FloatArray>): void;
  19209. /**
  19210. * Gets the tangent data stored in this target
  19211. * @returns a FloatArray containing the tangent data (or null if not present)
  19212. */
  19213. getTangents(): Nullable<FloatArray>;
  19214. /**
  19215. * Serializes the current target into a Serialization object
  19216. * @returns the serialized object
  19217. */
  19218. serialize(): any;
  19219. /**
  19220. * Returns the string "MorphTarget"
  19221. * @returns "MorphTarget"
  19222. */
  19223. getClassName(): string;
  19224. /**
  19225. * Creates a new target from serialized data
  19226. * @param serializationObject defines the serialized data to use
  19227. * @returns a new MorphTarget
  19228. */
  19229. static Parse(serializationObject: any): MorphTarget;
  19230. /**
  19231. * Creates a MorphTarget from mesh data
  19232. * @param mesh defines the source mesh
  19233. * @param name defines the name to use for the new target
  19234. * @param influence defines the influence to attach to the target
  19235. * @returns a new MorphTarget
  19236. */
  19237. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19238. }
  19239. }
  19240. declare module "babylonjs/Morph/morphTargetManager" {
  19241. import { Nullable } from "babylonjs/types";
  19242. import { Scene } from "babylonjs/scene";
  19243. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19244. /**
  19245. * This class is used to deform meshes using morphing between different targets
  19246. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19247. */
  19248. export class MorphTargetManager {
  19249. private _targets;
  19250. private _targetInfluenceChangedObservers;
  19251. private _targetDataLayoutChangedObservers;
  19252. private _activeTargets;
  19253. private _scene;
  19254. private _influences;
  19255. private _supportsNormals;
  19256. private _supportsTangents;
  19257. private _vertexCount;
  19258. private _uniqueId;
  19259. private _tempInfluences;
  19260. /**
  19261. * Creates a new MorphTargetManager
  19262. * @param scene defines the current scene
  19263. */
  19264. constructor(scene?: Nullable<Scene>);
  19265. /**
  19266. * Gets the unique ID of this manager
  19267. */
  19268. readonly uniqueId: number;
  19269. /**
  19270. * Gets the number of vertices handled by this manager
  19271. */
  19272. readonly vertexCount: number;
  19273. /**
  19274. * Gets a boolean indicating if this manager supports morphing of normals
  19275. */
  19276. readonly supportsNormals: boolean;
  19277. /**
  19278. * Gets a boolean indicating if this manager supports morphing of tangents
  19279. */
  19280. readonly supportsTangents: boolean;
  19281. /**
  19282. * Gets the number of targets stored in this manager
  19283. */
  19284. readonly numTargets: number;
  19285. /**
  19286. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19287. */
  19288. readonly numInfluencers: number;
  19289. /**
  19290. * Gets the list of influences (one per target)
  19291. */
  19292. readonly influences: Float32Array;
  19293. /**
  19294. * Gets the active target at specified index. An active target is a target with an influence > 0
  19295. * @param index defines the index to check
  19296. * @returns the requested target
  19297. */
  19298. getActiveTarget(index: number): MorphTarget;
  19299. /**
  19300. * Gets the target at specified index
  19301. * @param index defines the index to check
  19302. * @returns the requested target
  19303. */
  19304. getTarget(index: number): MorphTarget;
  19305. /**
  19306. * Add a new target to this manager
  19307. * @param target defines the target to add
  19308. */
  19309. addTarget(target: MorphTarget): void;
  19310. /**
  19311. * Removes a target from the manager
  19312. * @param target defines the target to remove
  19313. */
  19314. removeTarget(target: MorphTarget): void;
  19315. /**
  19316. * Serializes the current manager into a Serialization object
  19317. * @returns the serialized object
  19318. */
  19319. serialize(): any;
  19320. private _syncActiveTargets;
  19321. /**
  19322. * Syncrhonize the targets with all the meshes using this morph target manager
  19323. */
  19324. synchronize(): void;
  19325. /**
  19326. * Creates a new MorphTargetManager from serialized data
  19327. * @param serializationObject defines the serialized data
  19328. * @param scene defines the hosting scene
  19329. * @returns the new MorphTargetManager
  19330. */
  19331. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19332. }
  19333. }
  19334. declare module "babylonjs/Meshes/groundMesh" {
  19335. import { Scene } from "babylonjs/scene";
  19336. import { Vector3 } from "babylonjs/Maths/math";
  19337. import { Mesh } from "babylonjs/Meshes/mesh";
  19338. /**
  19339. * Mesh representing the gorund
  19340. */
  19341. export class GroundMesh extends Mesh {
  19342. /** If octree should be generated */
  19343. generateOctree: boolean;
  19344. private _heightQuads;
  19345. /** @hidden */
  19346. _subdivisionsX: number;
  19347. /** @hidden */
  19348. _subdivisionsY: number;
  19349. /** @hidden */
  19350. _width: number;
  19351. /** @hidden */
  19352. _height: number;
  19353. /** @hidden */
  19354. _minX: number;
  19355. /** @hidden */
  19356. _maxX: number;
  19357. /** @hidden */
  19358. _minZ: number;
  19359. /** @hidden */
  19360. _maxZ: number;
  19361. constructor(name: string, scene: Scene);
  19362. /**
  19363. * "GroundMesh"
  19364. * @returns "GroundMesh"
  19365. */
  19366. getClassName(): string;
  19367. /**
  19368. * The minimum of x and y subdivisions
  19369. */
  19370. readonly subdivisions: number;
  19371. /**
  19372. * X subdivisions
  19373. */
  19374. readonly subdivisionsX: number;
  19375. /**
  19376. * Y subdivisions
  19377. */
  19378. readonly subdivisionsY: number;
  19379. /**
  19380. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19381. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19382. * @param chunksCount the number of subdivisions for x and y
  19383. * @param octreeBlocksSize (Default: 32)
  19384. */
  19385. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19386. /**
  19387. * Returns a height (y) value in the Worl system :
  19388. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19389. * @param x x coordinate
  19390. * @param z z coordinate
  19391. * @returns the ground y position if (x, z) are outside the ground surface.
  19392. */
  19393. getHeightAtCoordinates(x: number, z: number): number;
  19394. /**
  19395. * Returns a normalized vector (Vector3) orthogonal to the ground
  19396. * at the ground coordinates (x, z) expressed in the World system.
  19397. * @param x x coordinate
  19398. * @param z z coordinate
  19399. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19400. */
  19401. getNormalAtCoordinates(x: number, z: number): Vector3;
  19402. /**
  19403. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19404. * at the ground coordinates (x, z) expressed in the World system.
  19405. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19406. * @param x x coordinate
  19407. * @param z z coordinate
  19408. * @param ref vector to store the result
  19409. * @returns the GroundMesh.
  19410. */
  19411. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19412. /**
  19413. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19414. * if the ground has been updated.
  19415. * This can be used in the render loop.
  19416. * @returns the GroundMesh.
  19417. */
  19418. updateCoordinateHeights(): GroundMesh;
  19419. private _getFacetAt;
  19420. private _initHeightQuads;
  19421. private _computeHeightQuads;
  19422. /**
  19423. * Serializes this ground mesh
  19424. * @param serializationObject object to write serialization to
  19425. */
  19426. serialize(serializationObject: any): void;
  19427. /**
  19428. * Parses a serialized ground mesh
  19429. * @param parsedMesh the serialized mesh
  19430. * @param scene the scene to create the ground mesh in
  19431. * @returns the created ground mesh
  19432. */
  19433. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19434. }
  19435. }
  19436. declare module "babylonjs/Physics/physicsJoint" {
  19437. import { Vector3 } from "babylonjs/Maths/math";
  19438. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19439. /**
  19440. * Interface for Physics-Joint data
  19441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19442. */
  19443. export interface PhysicsJointData {
  19444. /**
  19445. * The main pivot of the joint
  19446. */
  19447. mainPivot?: Vector3;
  19448. /**
  19449. * The connected pivot of the joint
  19450. */
  19451. connectedPivot?: Vector3;
  19452. /**
  19453. * The main axis of the joint
  19454. */
  19455. mainAxis?: Vector3;
  19456. /**
  19457. * The connected axis of the joint
  19458. */
  19459. connectedAxis?: Vector3;
  19460. /**
  19461. * The collision of the joint
  19462. */
  19463. collision?: boolean;
  19464. /**
  19465. * Native Oimo/Cannon/Energy data
  19466. */
  19467. nativeParams?: any;
  19468. }
  19469. /**
  19470. * This is a holder class for the physics joint created by the physics plugin
  19471. * It holds a set of functions to control the underlying joint
  19472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19473. */
  19474. export class PhysicsJoint {
  19475. /**
  19476. * The type of the physics joint
  19477. */
  19478. type: number;
  19479. /**
  19480. * The data for the physics joint
  19481. */
  19482. jointData: PhysicsJointData;
  19483. private _physicsJoint;
  19484. protected _physicsPlugin: IPhysicsEnginePlugin;
  19485. /**
  19486. * Initializes the physics joint
  19487. * @param type The type of the physics joint
  19488. * @param jointData The data for the physics joint
  19489. */
  19490. constructor(
  19491. /**
  19492. * The type of the physics joint
  19493. */
  19494. type: number,
  19495. /**
  19496. * The data for the physics joint
  19497. */
  19498. jointData: PhysicsJointData);
  19499. /**
  19500. * Gets the physics joint
  19501. */
  19502. /**
  19503. * Sets the physics joint
  19504. */
  19505. physicsJoint: any;
  19506. /**
  19507. * Sets the physics plugin
  19508. */
  19509. physicsPlugin: IPhysicsEnginePlugin;
  19510. /**
  19511. * Execute a function that is physics-plugin specific.
  19512. * @param {Function} func the function that will be executed.
  19513. * It accepts two parameters: the physics world and the physics joint
  19514. */
  19515. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19516. /**
  19517. * Distance-Joint type
  19518. */
  19519. static DistanceJoint: number;
  19520. /**
  19521. * Hinge-Joint type
  19522. */
  19523. static HingeJoint: number;
  19524. /**
  19525. * Ball-and-Socket joint type
  19526. */
  19527. static BallAndSocketJoint: number;
  19528. /**
  19529. * Wheel-Joint type
  19530. */
  19531. static WheelJoint: number;
  19532. /**
  19533. * Slider-Joint type
  19534. */
  19535. static SliderJoint: number;
  19536. /**
  19537. * Prismatic-Joint type
  19538. */
  19539. static PrismaticJoint: number;
  19540. /**
  19541. * Universal-Joint type
  19542. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19543. */
  19544. static UniversalJoint: number;
  19545. /**
  19546. * Hinge-Joint 2 type
  19547. */
  19548. static Hinge2Joint: number;
  19549. /**
  19550. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19551. */
  19552. static PointToPointJoint: number;
  19553. /**
  19554. * Spring-Joint type
  19555. */
  19556. static SpringJoint: number;
  19557. /**
  19558. * Lock-Joint type
  19559. */
  19560. static LockJoint: number;
  19561. }
  19562. /**
  19563. * A class representing a physics distance joint
  19564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19565. */
  19566. export class DistanceJoint extends PhysicsJoint {
  19567. /**
  19568. *
  19569. * @param jointData The data for the Distance-Joint
  19570. */
  19571. constructor(jointData: DistanceJointData);
  19572. /**
  19573. * Update the predefined distance.
  19574. * @param maxDistance The maximum preferred distance
  19575. * @param minDistance The minimum preferred distance
  19576. */
  19577. updateDistance(maxDistance: number, minDistance?: number): void;
  19578. }
  19579. /**
  19580. * Represents a Motor-Enabled Joint
  19581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19582. */
  19583. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19584. /**
  19585. * Initializes the Motor-Enabled Joint
  19586. * @param type The type of the joint
  19587. * @param jointData The physica joint data for the joint
  19588. */
  19589. constructor(type: number, jointData: PhysicsJointData);
  19590. /**
  19591. * Set the motor values.
  19592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19593. * @param force the force to apply
  19594. * @param maxForce max force for this motor.
  19595. */
  19596. setMotor(force?: number, maxForce?: number): void;
  19597. /**
  19598. * Set the motor's limits.
  19599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19600. * @param upperLimit The upper limit of the motor
  19601. * @param lowerLimit The lower limit of the motor
  19602. */
  19603. setLimit(upperLimit: number, lowerLimit?: number): void;
  19604. }
  19605. /**
  19606. * This class represents a single physics Hinge-Joint
  19607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19608. */
  19609. export class HingeJoint extends MotorEnabledJoint {
  19610. /**
  19611. * Initializes the Hinge-Joint
  19612. * @param jointData The joint data for the Hinge-Joint
  19613. */
  19614. constructor(jointData: PhysicsJointData);
  19615. /**
  19616. * Set the motor values.
  19617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19618. * @param {number} force the force to apply
  19619. * @param {number} maxForce max force for this motor.
  19620. */
  19621. setMotor(force?: number, maxForce?: number): void;
  19622. /**
  19623. * Set the motor's limits.
  19624. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19625. * @param upperLimit The upper limit of the motor
  19626. * @param lowerLimit The lower limit of the motor
  19627. */
  19628. setLimit(upperLimit: number, lowerLimit?: number): void;
  19629. }
  19630. /**
  19631. * This class represents a dual hinge physics joint (same as wheel joint)
  19632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19633. */
  19634. export class Hinge2Joint extends MotorEnabledJoint {
  19635. /**
  19636. * Initializes the Hinge2-Joint
  19637. * @param jointData The joint data for the Hinge2-Joint
  19638. */
  19639. constructor(jointData: PhysicsJointData);
  19640. /**
  19641. * Set the motor values.
  19642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19643. * @param {number} targetSpeed the speed the motor is to reach
  19644. * @param {number} maxForce max force for this motor.
  19645. * @param {motorIndex} the motor's index, 0 or 1.
  19646. */
  19647. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19648. /**
  19649. * Set the motor limits.
  19650. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19651. * @param {number} upperLimit the upper limit
  19652. * @param {number} lowerLimit lower limit
  19653. * @param {motorIndex} the motor's index, 0 or 1.
  19654. */
  19655. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19656. }
  19657. /**
  19658. * Interface for a motor enabled joint
  19659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19660. */
  19661. export interface IMotorEnabledJoint {
  19662. /**
  19663. * Physics joint
  19664. */
  19665. physicsJoint: any;
  19666. /**
  19667. * Sets the motor of the motor-enabled joint
  19668. * @param force The force of the motor
  19669. * @param maxForce The maximum force of the motor
  19670. * @param motorIndex The index of the motor
  19671. */
  19672. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19673. /**
  19674. * Sets the limit of the motor
  19675. * @param upperLimit The upper limit of the motor
  19676. * @param lowerLimit The lower limit of the motor
  19677. * @param motorIndex The index of the motor
  19678. */
  19679. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19680. }
  19681. /**
  19682. * Joint data for a Distance-Joint
  19683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19684. */
  19685. export interface DistanceJointData extends PhysicsJointData {
  19686. /**
  19687. * Max distance the 2 joint objects can be apart
  19688. */
  19689. maxDistance: number;
  19690. }
  19691. /**
  19692. * Joint data from a spring joint
  19693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19694. */
  19695. export interface SpringJointData extends PhysicsJointData {
  19696. /**
  19697. * Length of the spring
  19698. */
  19699. length: number;
  19700. /**
  19701. * Stiffness of the spring
  19702. */
  19703. stiffness: number;
  19704. /**
  19705. * Damping of the spring
  19706. */
  19707. damping: number;
  19708. /** this callback will be called when applying the force to the impostors. */
  19709. forceApplicationCallback: () => void;
  19710. }
  19711. }
  19712. declare module "babylonjs/Physics/IPhysicsEngine" {
  19713. import { Nullable } from "babylonjs/types";
  19714. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19716. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19717. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19718. /**
  19719. * Interface used to describe a physics joint
  19720. */
  19721. export interface PhysicsImpostorJoint {
  19722. /** Defines the main impostor to which the joint is linked */
  19723. mainImpostor: PhysicsImpostor;
  19724. /** Defines the impostor that is connected to the main impostor using this joint */
  19725. connectedImpostor: PhysicsImpostor;
  19726. /** Defines the joint itself */
  19727. joint: PhysicsJoint;
  19728. }
  19729. /** @hidden */
  19730. export interface IPhysicsEnginePlugin {
  19731. world: any;
  19732. name: string;
  19733. setGravity(gravity: Vector3): void;
  19734. setTimeStep(timeStep: number): void;
  19735. getTimeStep(): number;
  19736. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19737. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19738. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19739. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19740. removePhysicsBody(impostor: PhysicsImpostor): void;
  19741. generateJoint(joint: PhysicsImpostorJoint): void;
  19742. removeJoint(joint: PhysicsImpostorJoint): void;
  19743. isSupported(): boolean;
  19744. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19745. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19746. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19747. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19748. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19749. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19750. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19751. getBodyMass(impostor: PhysicsImpostor): number;
  19752. getBodyFriction(impostor: PhysicsImpostor): number;
  19753. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19754. getBodyRestitution(impostor: PhysicsImpostor): number;
  19755. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19756. sleepBody(impostor: PhysicsImpostor): void;
  19757. wakeUpBody(impostor: PhysicsImpostor): void;
  19758. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19759. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19760. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19761. getRadius(impostor: PhysicsImpostor): number;
  19762. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19763. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19764. dispose(): void;
  19765. }
  19766. /**
  19767. * Interface used to define a physics engine
  19768. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19769. */
  19770. export interface IPhysicsEngine {
  19771. /**
  19772. * Gets the gravity vector used by the simulation
  19773. */
  19774. gravity: Vector3;
  19775. /**
  19776. * Sets the gravity vector used by the simulation
  19777. * @param gravity defines the gravity vector to use
  19778. */
  19779. setGravity(gravity: Vector3): void;
  19780. /**
  19781. * Set the time step of the physics engine.
  19782. * Default is 1/60.
  19783. * To slow it down, enter 1/600 for example.
  19784. * To speed it up, 1/30
  19785. * @param newTimeStep the new timestep to apply to this world.
  19786. */
  19787. setTimeStep(newTimeStep: number): void;
  19788. /**
  19789. * Get the time step of the physics engine.
  19790. * @returns the current time step
  19791. */
  19792. getTimeStep(): number;
  19793. /**
  19794. * Release all resources
  19795. */
  19796. dispose(): void;
  19797. /**
  19798. * Gets the name of the current physics plugin
  19799. * @returns the name of the plugin
  19800. */
  19801. getPhysicsPluginName(): string;
  19802. /**
  19803. * Adding a new impostor for the impostor tracking.
  19804. * This will be done by the impostor itself.
  19805. * @param impostor the impostor to add
  19806. */
  19807. addImpostor(impostor: PhysicsImpostor): void;
  19808. /**
  19809. * Remove an impostor from the engine.
  19810. * This impostor and its mesh will not longer be updated by the physics engine.
  19811. * @param impostor the impostor to remove
  19812. */
  19813. removeImpostor(impostor: PhysicsImpostor): void;
  19814. /**
  19815. * Add a joint to the physics engine
  19816. * @param mainImpostor defines the main impostor to which the joint is added.
  19817. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19818. * @param joint defines the joint that will connect both impostors.
  19819. */
  19820. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19821. /**
  19822. * Removes a joint from the simulation
  19823. * @param mainImpostor defines the impostor used with the joint
  19824. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19825. * @param joint defines the joint to remove
  19826. */
  19827. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19828. /**
  19829. * Gets the current plugin used to run the simulation
  19830. * @returns current plugin
  19831. */
  19832. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19833. /**
  19834. * Gets the list of physic impostors
  19835. * @returns an array of PhysicsImpostor
  19836. */
  19837. getImpostors(): Array<PhysicsImpostor>;
  19838. /**
  19839. * Gets the impostor for a physics enabled object
  19840. * @param object defines the object impersonated by the impostor
  19841. * @returns the PhysicsImpostor or null if not found
  19842. */
  19843. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19844. /**
  19845. * Gets the impostor for a physics body object
  19846. * @param body defines physics body used by the impostor
  19847. * @returns the PhysicsImpostor or null if not found
  19848. */
  19849. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19850. /**
  19851. * Called by the scene. No need to call it.
  19852. * @param delta defines the timespam between frames
  19853. */
  19854. _step(delta: number): void;
  19855. }
  19856. }
  19857. declare module "babylonjs/Physics/physicsImpostor" {
  19858. import { Nullable, IndicesArray } from "babylonjs/types";
  19859. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19860. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19862. import { Scene } from "babylonjs/scene";
  19863. import { Bone } from "babylonjs/Bones/bone";
  19864. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19865. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19866. /**
  19867. * The interface for the physics imposter parameters
  19868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19869. */
  19870. export interface PhysicsImpostorParameters {
  19871. /**
  19872. * The mass of the physics imposter
  19873. */
  19874. mass: number;
  19875. /**
  19876. * The friction of the physics imposter
  19877. */
  19878. friction?: number;
  19879. /**
  19880. * The coefficient of restitution of the physics imposter
  19881. */
  19882. restitution?: number;
  19883. /**
  19884. * The native options of the physics imposter
  19885. */
  19886. nativeOptions?: any;
  19887. /**
  19888. * Specifies if the parent should be ignored
  19889. */
  19890. ignoreParent?: boolean;
  19891. /**
  19892. * Specifies if bi-directional transformations should be disabled
  19893. */
  19894. disableBidirectionalTransformation?: boolean;
  19895. }
  19896. /**
  19897. * Interface for a physics-enabled object
  19898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19899. */
  19900. export interface IPhysicsEnabledObject {
  19901. /**
  19902. * The position of the physics-enabled object
  19903. */
  19904. position: Vector3;
  19905. /**
  19906. * The rotation of the physics-enabled object
  19907. */
  19908. rotationQuaternion: Nullable<Quaternion>;
  19909. /**
  19910. * The scale of the physics-enabled object
  19911. */
  19912. scaling: Vector3;
  19913. /**
  19914. * The rotation of the physics-enabled object
  19915. */
  19916. rotation?: Vector3;
  19917. /**
  19918. * The parent of the physics-enabled object
  19919. */
  19920. parent?: any;
  19921. /**
  19922. * The bounding info of the physics-enabled object
  19923. * @returns The bounding info of the physics-enabled object
  19924. */
  19925. getBoundingInfo(): BoundingInfo;
  19926. /**
  19927. * Computes the world matrix
  19928. * @param force Specifies if the world matrix should be computed by force
  19929. * @returns A world matrix
  19930. */
  19931. computeWorldMatrix(force: boolean): Matrix;
  19932. /**
  19933. * Gets the world matrix
  19934. * @returns A world matrix
  19935. */
  19936. getWorldMatrix?(): Matrix;
  19937. /**
  19938. * Gets the child meshes
  19939. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19940. * @returns An array of abstract meshes
  19941. */
  19942. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19943. /**
  19944. * Gets the vertex data
  19945. * @param kind The type of vertex data
  19946. * @returns A nullable array of numbers, or a float32 array
  19947. */
  19948. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19949. /**
  19950. * Gets the indices from the mesh
  19951. * @returns A nullable array of index arrays
  19952. */
  19953. getIndices?(): Nullable<IndicesArray>;
  19954. /**
  19955. * Gets the scene from the mesh
  19956. * @returns the indices array or null
  19957. */
  19958. getScene?(): Scene;
  19959. /**
  19960. * Gets the absolute position from the mesh
  19961. * @returns the absolute position
  19962. */
  19963. getAbsolutePosition(): Vector3;
  19964. /**
  19965. * Gets the absolute pivot point from the mesh
  19966. * @returns the absolute pivot point
  19967. */
  19968. getAbsolutePivotPoint(): Vector3;
  19969. /**
  19970. * Rotates the mesh
  19971. * @param axis The axis of rotation
  19972. * @param amount The amount of rotation
  19973. * @param space The space of the rotation
  19974. * @returns The rotation transform node
  19975. */
  19976. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19977. /**
  19978. * Translates the mesh
  19979. * @param axis The axis of translation
  19980. * @param distance The distance of translation
  19981. * @param space The space of the translation
  19982. * @returns The transform node
  19983. */
  19984. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19985. /**
  19986. * Sets the absolute position of the mesh
  19987. * @param absolutePosition The absolute position of the mesh
  19988. * @returns The transform node
  19989. */
  19990. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19991. /**
  19992. * Gets the class name of the mesh
  19993. * @returns The class name
  19994. */
  19995. getClassName(): string;
  19996. }
  19997. /**
  19998. * Represents a physics imposter
  19999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20000. */
  20001. export class PhysicsImpostor {
  20002. /**
  20003. * The physics-enabled object used as the physics imposter
  20004. */
  20005. object: IPhysicsEnabledObject;
  20006. /**
  20007. * The type of the physics imposter
  20008. */
  20009. type: number;
  20010. private _options;
  20011. private _scene?;
  20012. /**
  20013. * The default object size of the imposter
  20014. */
  20015. static DEFAULT_OBJECT_SIZE: Vector3;
  20016. /**
  20017. * The identity quaternion of the imposter
  20018. */
  20019. static IDENTITY_QUATERNION: Quaternion;
  20020. /** @hidden */
  20021. _pluginData: any;
  20022. private _physicsEngine;
  20023. private _physicsBody;
  20024. private _bodyUpdateRequired;
  20025. private _onBeforePhysicsStepCallbacks;
  20026. private _onAfterPhysicsStepCallbacks;
  20027. /** @hidden */
  20028. _onPhysicsCollideCallbacks: Array<{
  20029. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20030. otherImpostors: Array<PhysicsImpostor>;
  20031. }>;
  20032. private _deltaPosition;
  20033. private _deltaRotation;
  20034. private _deltaRotationConjugated;
  20035. private _parent;
  20036. private _isDisposed;
  20037. private static _tmpVecs;
  20038. private static _tmpQuat;
  20039. /**
  20040. * Specifies if the physics imposter is disposed
  20041. */
  20042. readonly isDisposed: boolean;
  20043. /**
  20044. * Gets the mass of the physics imposter
  20045. */
  20046. mass: number;
  20047. /**
  20048. * Gets the coefficient of friction
  20049. */
  20050. /**
  20051. * Sets the coefficient of friction
  20052. */
  20053. friction: number;
  20054. /**
  20055. * Gets the coefficient of restitution
  20056. */
  20057. /**
  20058. * Sets the coefficient of restitution
  20059. */
  20060. restitution: number;
  20061. /**
  20062. * The unique id of the physics imposter
  20063. * set by the physics engine when adding this impostor to the array
  20064. */
  20065. uniqueId: number;
  20066. private _joints;
  20067. /**
  20068. * Initializes the physics imposter
  20069. * @param object The physics-enabled object used as the physics imposter
  20070. * @param type The type of the physics imposter
  20071. * @param _options The options for the physics imposter
  20072. * @param _scene The Babylon scene
  20073. */
  20074. constructor(
  20075. /**
  20076. * The physics-enabled object used as the physics imposter
  20077. */
  20078. object: IPhysicsEnabledObject,
  20079. /**
  20080. * The type of the physics imposter
  20081. */
  20082. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20083. /**
  20084. * This function will completly initialize this impostor.
  20085. * It will create a new body - but only if this mesh has no parent.
  20086. * If it has, this impostor will not be used other than to define the impostor
  20087. * of the child mesh.
  20088. * @hidden
  20089. */
  20090. _init(): void;
  20091. private _getPhysicsParent;
  20092. /**
  20093. * Should a new body be generated.
  20094. * @returns boolean specifying if body initialization is required
  20095. */
  20096. isBodyInitRequired(): boolean;
  20097. /**
  20098. * Sets the updated scaling
  20099. * @param updated Specifies if the scaling is updated
  20100. */
  20101. setScalingUpdated(): void;
  20102. /**
  20103. * Force a regeneration of this or the parent's impostor's body.
  20104. * Use under cautious - This will remove all joints already implemented.
  20105. */
  20106. forceUpdate(): void;
  20107. /**
  20108. * Gets the body that holds this impostor. Either its own, or its parent.
  20109. */
  20110. /**
  20111. * Set the physics body. Used mainly by the physics engine/plugin
  20112. */
  20113. physicsBody: any;
  20114. /**
  20115. * Get the parent of the physics imposter
  20116. * @returns Physics imposter or null
  20117. */
  20118. /**
  20119. * Sets the parent of the physics imposter
  20120. */
  20121. parent: Nullable<PhysicsImpostor>;
  20122. /**
  20123. * Resets the update flags
  20124. */
  20125. resetUpdateFlags(): void;
  20126. /**
  20127. * Gets the object extend size
  20128. * @returns the object extend size
  20129. */
  20130. getObjectExtendSize(): Vector3;
  20131. /**
  20132. * Gets the object center
  20133. * @returns The object center
  20134. */
  20135. getObjectCenter(): Vector3;
  20136. /**
  20137. * Get a specific parametes from the options parameter
  20138. * @param paramName The object parameter name
  20139. * @returns The object parameter
  20140. */
  20141. getParam(paramName: string): any;
  20142. /**
  20143. * Sets a specific parameter in the options given to the physics plugin
  20144. * @param paramName The parameter name
  20145. * @param value The value of the parameter
  20146. */
  20147. setParam(paramName: string, value: number): void;
  20148. /**
  20149. * Specifically change the body's mass option. Won't recreate the physics body object
  20150. * @param mass The mass of the physics imposter
  20151. */
  20152. setMass(mass: number): void;
  20153. /**
  20154. * Gets the linear velocity
  20155. * @returns linear velocity or null
  20156. */
  20157. getLinearVelocity(): Nullable<Vector3>;
  20158. /**
  20159. * Sets the linear velocity
  20160. * @param velocity linear velocity or null
  20161. */
  20162. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20163. /**
  20164. * Gets the angular velocity
  20165. * @returns angular velocity or null
  20166. */
  20167. getAngularVelocity(): Nullable<Vector3>;
  20168. /**
  20169. * Sets the angular velocity
  20170. * @param velocity The velocity or null
  20171. */
  20172. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20173. /**
  20174. * Execute a function with the physics plugin native code
  20175. * Provide a function the will have two variables - the world object and the physics body object
  20176. * @param func The function to execute with the physics plugin native code
  20177. */
  20178. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20179. /**
  20180. * Register a function that will be executed before the physics world is stepping forward
  20181. * @param func The function to execute before the physics world is stepped forward
  20182. */
  20183. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20184. /**
  20185. * Unregister a function that will be executed before the physics world is stepping forward
  20186. * @param func The function to execute before the physics world is stepped forward
  20187. */
  20188. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20189. /**
  20190. * Register a function that will be executed after the physics step
  20191. * @param func The function to execute after physics step
  20192. */
  20193. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20194. /**
  20195. * Unregisters a function that will be executed after the physics step
  20196. * @param func The function to execute after physics step
  20197. */
  20198. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20199. /**
  20200. * register a function that will be executed when this impostor collides against a different body
  20201. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20202. * @param func Callback that is executed on collision
  20203. */
  20204. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20205. /**
  20206. * Unregisters the physics imposter on contact
  20207. * @param collideAgainst The physics object to collide against
  20208. * @param func Callback to execute on collision
  20209. */
  20210. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20211. private _tmpQuat;
  20212. private _tmpQuat2;
  20213. /**
  20214. * Get the parent rotation
  20215. * @returns The parent rotation
  20216. */
  20217. getParentsRotation(): Quaternion;
  20218. /**
  20219. * this function is executed by the physics engine.
  20220. */
  20221. beforeStep: () => void;
  20222. /**
  20223. * this function is executed by the physics engine
  20224. */
  20225. afterStep: () => void;
  20226. /**
  20227. * Legacy collision detection event support
  20228. */
  20229. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20230. /**
  20231. * event and body object due to cannon's event-based architecture.
  20232. */
  20233. onCollide: (e: {
  20234. body: any;
  20235. }) => void;
  20236. /**
  20237. * Apply a force
  20238. * @param force The force to apply
  20239. * @param contactPoint The contact point for the force
  20240. * @returns The physics imposter
  20241. */
  20242. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20243. /**
  20244. * Apply an impulse
  20245. * @param force The impulse force
  20246. * @param contactPoint The contact point for the impulse force
  20247. * @returns The physics imposter
  20248. */
  20249. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20250. /**
  20251. * A help function to create a joint
  20252. * @param otherImpostor A physics imposter used to create a joint
  20253. * @param jointType The type of joint
  20254. * @param jointData The data for the joint
  20255. * @returns The physics imposter
  20256. */
  20257. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20258. /**
  20259. * Add a joint to this impostor with a different impostor
  20260. * @param otherImpostor A physics imposter used to add a joint
  20261. * @param joint The joint to add
  20262. * @returns The physics imposter
  20263. */
  20264. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20265. /**
  20266. * Will keep this body still, in a sleep mode.
  20267. * @returns the physics imposter
  20268. */
  20269. sleep(): PhysicsImpostor;
  20270. /**
  20271. * Wake the body up.
  20272. * @returns The physics imposter
  20273. */
  20274. wakeUp(): PhysicsImpostor;
  20275. /**
  20276. * Clones the physics imposter
  20277. * @param newObject The physics imposter clones to this physics-enabled object
  20278. * @returns A nullable physics imposter
  20279. */
  20280. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20281. /**
  20282. * Disposes the physics imposter
  20283. */
  20284. dispose(): void;
  20285. /**
  20286. * Sets the delta position
  20287. * @param position The delta position amount
  20288. */
  20289. setDeltaPosition(position: Vector3): void;
  20290. /**
  20291. * Sets the delta rotation
  20292. * @param rotation The delta rotation amount
  20293. */
  20294. setDeltaRotation(rotation: Quaternion): void;
  20295. /**
  20296. * Gets the box size of the physics imposter and stores the result in the input parameter
  20297. * @param result Stores the box size
  20298. * @returns The physics imposter
  20299. */
  20300. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20301. /**
  20302. * Gets the radius of the physics imposter
  20303. * @returns Radius of the physics imposter
  20304. */
  20305. getRadius(): number;
  20306. /**
  20307. * Sync a bone with this impostor
  20308. * @param bone The bone to sync to the impostor.
  20309. * @param boneMesh The mesh that the bone is influencing.
  20310. * @param jointPivot The pivot of the joint / bone in local space.
  20311. * @param distToJoint Optional distance from the impostor to the joint.
  20312. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20313. */
  20314. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20315. /**
  20316. * Sync impostor to a bone
  20317. * @param bone The bone that the impostor will be synced to.
  20318. * @param boneMesh The mesh that the bone is influencing.
  20319. * @param jointPivot The pivot of the joint / bone in local space.
  20320. * @param distToJoint Optional distance from the impostor to the joint.
  20321. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20322. * @param boneAxis Optional vector3 axis the bone is aligned with
  20323. */
  20324. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20325. /**
  20326. * No-Imposter type
  20327. */
  20328. static NoImpostor: number;
  20329. /**
  20330. * Sphere-Imposter type
  20331. */
  20332. static SphereImpostor: number;
  20333. /**
  20334. * Box-Imposter type
  20335. */
  20336. static BoxImpostor: number;
  20337. /**
  20338. * Plane-Imposter type
  20339. */
  20340. static PlaneImpostor: number;
  20341. /**
  20342. * Mesh-imposter type
  20343. */
  20344. static MeshImpostor: number;
  20345. /**
  20346. * Cylinder-Imposter type
  20347. */
  20348. static CylinderImpostor: number;
  20349. /**
  20350. * Particle-Imposter type
  20351. */
  20352. static ParticleImpostor: number;
  20353. /**
  20354. * Heightmap-Imposter type
  20355. */
  20356. static HeightmapImpostor: number;
  20357. }
  20358. }
  20359. declare module "babylonjs/Meshes/mesh" {
  20360. import { Observable } from "babylonjs/Misc/observable";
  20361. import { IAnimatable } from "babylonjs/Misc/tools";
  20362. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20363. import { Camera } from "babylonjs/Cameras/camera";
  20364. import { Scene } from "babylonjs/scene";
  20365. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20366. import { Engine } from "babylonjs/Engines/engine";
  20367. import { Node } from "babylonjs/node";
  20368. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20369. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20370. import { Buffer } from "babylonjs/Meshes/buffer";
  20371. import { Geometry } from "babylonjs/Meshes/geometry";
  20372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20374. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20375. import { Effect } from "babylonjs/Materials/effect";
  20376. import { Material } from "babylonjs/Materials/material";
  20377. import { Skeleton } from "babylonjs/Bones/skeleton";
  20378. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20379. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20380. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20381. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20382. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20383. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20384. /**
  20385. * Class used to represent a specific level of detail of a mesh
  20386. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20387. */
  20388. export class MeshLODLevel {
  20389. /** Defines the distance where this level should star being displayed */
  20390. distance: number;
  20391. /** Defines the mesh to use to render this level */
  20392. mesh: Nullable<Mesh>;
  20393. /**
  20394. * Creates a new LOD level
  20395. * @param distance defines the distance where this level should star being displayed
  20396. * @param mesh defines the mesh to use to render this level
  20397. */
  20398. constructor(
  20399. /** Defines the distance where this level should star being displayed */
  20400. distance: number,
  20401. /** Defines the mesh to use to render this level */
  20402. mesh: Nullable<Mesh>);
  20403. }
  20404. /**
  20405. * @hidden
  20406. **/
  20407. export class _CreationDataStorage {
  20408. closePath?: boolean;
  20409. closeArray?: boolean;
  20410. idx: number[];
  20411. dashSize: number;
  20412. gapSize: number;
  20413. path3D: Path3D;
  20414. pathArray: Vector3[][];
  20415. arc: number;
  20416. radius: number;
  20417. cap: number;
  20418. tessellation: number;
  20419. }
  20420. /**
  20421. * @hidden
  20422. **/
  20423. class _InstanceDataStorage {
  20424. visibleInstances: any;
  20425. renderIdForInstances: number[];
  20426. batchCache: _InstancesBatch;
  20427. instancesBufferSize: number;
  20428. instancesBuffer: Nullable<Buffer>;
  20429. instancesData: Float32Array;
  20430. overridenInstanceCount: number;
  20431. }
  20432. /**
  20433. * @hidden
  20434. **/
  20435. export class _InstancesBatch {
  20436. mustReturn: boolean;
  20437. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20438. renderSelf: boolean[];
  20439. }
  20440. /**
  20441. * Class used to represent renderable models
  20442. */
  20443. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20444. /**
  20445. * Mesh side orientation : usually the external or front surface
  20446. */
  20447. static readonly FRONTSIDE: number;
  20448. /**
  20449. * Mesh side orientation : usually the internal or back surface
  20450. */
  20451. static readonly BACKSIDE: number;
  20452. /**
  20453. * Mesh side orientation : both internal and external or front and back surfaces
  20454. */
  20455. static readonly DOUBLESIDE: number;
  20456. /**
  20457. * Mesh side orientation : by default, `FRONTSIDE`
  20458. */
  20459. static readonly DEFAULTSIDE: number;
  20460. /**
  20461. * Mesh cap setting : no cap
  20462. */
  20463. static readonly NO_CAP: number;
  20464. /**
  20465. * Mesh cap setting : one cap at the beginning of the mesh
  20466. */
  20467. static readonly CAP_START: number;
  20468. /**
  20469. * Mesh cap setting : one cap at the end of the mesh
  20470. */
  20471. static readonly CAP_END: number;
  20472. /**
  20473. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20474. */
  20475. static readonly CAP_ALL: number;
  20476. /**
  20477. * Gets the default side orientation.
  20478. * @param orientation the orientation to value to attempt to get
  20479. * @returns the default orientation
  20480. * @hidden
  20481. */
  20482. static _GetDefaultSideOrientation(orientation?: number): number;
  20483. private _onBeforeRenderObservable;
  20484. private _onBeforeBindObservable;
  20485. private _onAfterRenderObservable;
  20486. private _onBeforeDrawObservable;
  20487. /**
  20488. * An event triggered before rendering the mesh
  20489. */
  20490. readonly onBeforeRenderObservable: Observable<Mesh>;
  20491. /**
  20492. * An event triggered before binding the mesh
  20493. */
  20494. readonly onBeforeBindObservable: Observable<Mesh>;
  20495. /**
  20496. * An event triggered after rendering the mesh
  20497. */
  20498. readonly onAfterRenderObservable: Observable<Mesh>;
  20499. /**
  20500. * An event triggered before drawing the mesh
  20501. */
  20502. readonly onBeforeDrawObservable: Observable<Mesh>;
  20503. private _onBeforeDrawObserver;
  20504. /**
  20505. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20506. */
  20507. onBeforeDraw: () => void;
  20508. /**
  20509. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20510. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20511. */
  20512. delayLoadState: number;
  20513. /**
  20514. * Gets the list of instances created from this mesh
  20515. * it is not supposed to be modified manually.
  20516. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20517. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20518. */
  20519. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20520. /**
  20521. * Gets the file containing delay loading data for this mesh
  20522. */
  20523. delayLoadingFile: string;
  20524. /** @hidden */
  20525. _binaryInfo: any;
  20526. private _LODLevels;
  20527. /**
  20528. * User defined function used to change how LOD level selection is done
  20529. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20530. */
  20531. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20532. private _morphTargetManager;
  20533. /**
  20534. * Gets or sets the morph target manager
  20535. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20536. */
  20537. morphTargetManager: Nullable<MorphTargetManager>;
  20538. /** @hidden */
  20539. _creationDataStorage: Nullable<_CreationDataStorage>;
  20540. /** @hidden */
  20541. _geometry: Nullable<Geometry>;
  20542. /** @hidden */
  20543. _delayInfo: Array<string>;
  20544. /** @hidden */
  20545. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20546. /** @hidden */
  20547. _instanceDataStorage: _InstanceDataStorage;
  20548. private _effectiveMaterial;
  20549. /** @hidden */
  20550. _shouldGenerateFlatShading: boolean;
  20551. private _preActivateId;
  20552. /** @hidden */
  20553. _originalBuilderSideOrientation: number;
  20554. /**
  20555. * Use this property to change the original side orientation defined at construction time
  20556. */
  20557. overrideMaterialSideOrientation: Nullable<number>;
  20558. private _areNormalsFrozen;
  20559. private _sourcePositions;
  20560. private _sourceNormals;
  20561. private _source;
  20562. private meshMap;
  20563. /**
  20564. * Gets the source mesh (the one used to clone this one from)
  20565. */
  20566. readonly source: Nullable<Mesh>;
  20567. /**
  20568. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20569. */
  20570. isUnIndexed: boolean;
  20571. /**
  20572. * @constructor
  20573. * @param name The value used by scene.getMeshByName() to do a lookup.
  20574. * @param scene The scene to add this mesh to.
  20575. * @param parent The parent of this mesh, if it has one
  20576. * @param source An optional Mesh from which geometry is shared, cloned.
  20577. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20578. * When false, achieved by calling a clone(), also passing False.
  20579. * This will make creation of children, recursive.
  20580. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20581. */
  20582. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20583. /**
  20584. * Gets the class name
  20585. * @returns the string "Mesh".
  20586. */
  20587. getClassName(): string;
  20588. /** @hidden */
  20589. readonly _isMesh: boolean;
  20590. /**
  20591. * Returns a description of this mesh
  20592. * @param fullDetails define if full details about this mesh must be used
  20593. * @returns a descriptive string representing this mesh
  20594. */
  20595. toString(fullDetails?: boolean): string;
  20596. /** @hidden */
  20597. _unBindEffect(): void;
  20598. /**
  20599. * Gets a boolean indicating if this mesh has LOD
  20600. */
  20601. readonly hasLODLevels: boolean;
  20602. /**
  20603. * Gets the list of MeshLODLevel associated with the current mesh
  20604. * @returns an array of MeshLODLevel
  20605. */
  20606. getLODLevels(): MeshLODLevel[];
  20607. private _sortLODLevels;
  20608. /**
  20609. * Add a mesh as LOD level triggered at the given distance.
  20610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20611. * @param distance The distance from the center of the object to show this level
  20612. * @param mesh The mesh to be added as LOD level (can be null)
  20613. * @return This mesh (for chaining)
  20614. */
  20615. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20616. /**
  20617. * Returns the LOD level mesh at the passed distance or null if not found.
  20618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20619. * @param distance The distance from the center of the object to show this level
  20620. * @returns a Mesh or `null`
  20621. */
  20622. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20623. /**
  20624. * Remove a mesh from the LOD array
  20625. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20626. * @param mesh defines the mesh to be removed
  20627. * @return This mesh (for chaining)
  20628. */
  20629. removeLODLevel(mesh: Mesh): Mesh;
  20630. /**
  20631. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20632. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20633. * @param camera defines the camera to use to compute distance
  20634. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20635. * @return This mesh (for chaining)
  20636. */
  20637. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20638. /**
  20639. * Gets the mesh internal Geometry object
  20640. */
  20641. readonly geometry: Nullable<Geometry>;
  20642. /**
  20643. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20644. * @returns the total number of vertices
  20645. */
  20646. getTotalVertices(): number;
  20647. /**
  20648. * Returns the content of an associated vertex buffer
  20649. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20650. * - VertexBuffer.PositionKind
  20651. * - VertexBuffer.UVKind
  20652. * - VertexBuffer.UV2Kind
  20653. * - VertexBuffer.UV3Kind
  20654. * - VertexBuffer.UV4Kind
  20655. * - VertexBuffer.UV5Kind
  20656. * - VertexBuffer.UV6Kind
  20657. * - VertexBuffer.ColorKind
  20658. * - VertexBuffer.MatricesIndicesKind
  20659. * - VertexBuffer.MatricesIndicesExtraKind
  20660. * - VertexBuffer.MatricesWeightsKind
  20661. * - VertexBuffer.MatricesWeightsExtraKind
  20662. * @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
  20663. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20664. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20665. */
  20666. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20667. /**
  20668. * Returns the mesh VertexBuffer object from the requested `kind`
  20669. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20670. * - VertexBuffer.PositionKind
  20671. * - VertexBuffer.UVKind
  20672. * - VertexBuffer.UV2Kind
  20673. * - VertexBuffer.UV3Kind
  20674. * - VertexBuffer.UV4Kind
  20675. * - VertexBuffer.UV5Kind
  20676. * - VertexBuffer.UV6Kind
  20677. * - VertexBuffer.ColorKind
  20678. * - VertexBuffer.MatricesIndicesKind
  20679. * - VertexBuffer.MatricesIndicesExtraKind
  20680. * - VertexBuffer.MatricesWeightsKind
  20681. * - VertexBuffer.MatricesWeightsExtraKind
  20682. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20683. */
  20684. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20685. /**
  20686. * Tests if a specific vertex buffer is associated with this mesh
  20687. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20688. * - VertexBuffer.PositionKind
  20689. * - VertexBuffer.UVKind
  20690. * - VertexBuffer.UV2Kind
  20691. * - VertexBuffer.UV3Kind
  20692. * - VertexBuffer.UV4Kind
  20693. * - VertexBuffer.UV5Kind
  20694. * - VertexBuffer.UV6Kind
  20695. * - VertexBuffer.ColorKind
  20696. * - VertexBuffer.MatricesIndicesKind
  20697. * - VertexBuffer.MatricesIndicesExtraKind
  20698. * - VertexBuffer.MatricesWeightsKind
  20699. * - VertexBuffer.MatricesWeightsExtraKind
  20700. * @returns a boolean
  20701. */
  20702. isVerticesDataPresent(kind: string): boolean;
  20703. /**
  20704. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20705. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20706. * - VertexBuffer.PositionKind
  20707. * - VertexBuffer.UVKind
  20708. * - VertexBuffer.UV2Kind
  20709. * - VertexBuffer.UV3Kind
  20710. * - VertexBuffer.UV4Kind
  20711. * - VertexBuffer.UV5Kind
  20712. * - VertexBuffer.UV6Kind
  20713. * - VertexBuffer.ColorKind
  20714. * - VertexBuffer.MatricesIndicesKind
  20715. * - VertexBuffer.MatricesIndicesExtraKind
  20716. * - VertexBuffer.MatricesWeightsKind
  20717. * - VertexBuffer.MatricesWeightsExtraKind
  20718. * @returns a boolean
  20719. */
  20720. isVertexBufferUpdatable(kind: string): boolean;
  20721. /**
  20722. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20723. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20724. * - VertexBuffer.PositionKind
  20725. * - VertexBuffer.UVKind
  20726. * - VertexBuffer.UV2Kind
  20727. * - VertexBuffer.UV3Kind
  20728. * - VertexBuffer.UV4Kind
  20729. * - VertexBuffer.UV5Kind
  20730. * - VertexBuffer.UV6Kind
  20731. * - VertexBuffer.ColorKind
  20732. * - VertexBuffer.MatricesIndicesKind
  20733. * - VertexBuffer.MatricesIndicesExtraKind
  20734. * - VertexBuffer.MatricesWeightsKind
  20735. * - VertexBuffer.MatricesWeightsExtraKind
  20736. * @returns an array of strings
  20737. */
  20738. getVerticesDataKinds(): string[];
  20739. /**
  20740. * Returns a positive integer : the total number of indices in this mesh geometry.
  20741. * @returns the numner of indices or zero if the mesh has no geometry.
  20742. */
  20743. getTotalIndices(): number;
  20744. /**
  20745. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20746. * @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.
  20747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20748. * @returns the indices array or an empty array if the mesh has no geometry
  20749. */
  20750. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20751. readonly isBlocked: boolean;
  20752. /**
  20753. * Determine if the current mesh is ready to be rendered
  20754. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20755. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20756. * @returns true if all associated assets are ready (material, textures, shaders)
  20757. */
  20758. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20759. /**
  20760. * 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.
  20761. */
  20762. readonly areNormalsFrozen: boolean;
  20763. /**
  20764. * 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.
  20765. * @returns the current mesh
  20766. */
  20767. freezeNormals(): Mesh;
  20768. /**
  20769. * 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
  20770. * @returns the current mesh
  20771. */
  20772. unfreezeNormals(): Mesh;
  20773. /**
  20774. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20775. */
  20776. overridenInstanceCount: number;
  20777. /** @hidden */
  20778. _preActivate(): Mesh;
  20779. /** @hidden */
  20780. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20781. /** @hidden */
  20782. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20783. /**
  20784. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20785. * This means the mesh underlying bounding box and sphere are recomputed.
  20786. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20787. * @returns the current mesh
  20788. */
  20789. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20790. /** @hidden */
  20791. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20792. /**
  20793. * This function will subdivide the mesh into multiple submeshes
  20794. * @param count defines the expected number of submeshes
  20795. */
  20796. subdivide(count: number): void;
  20797. /**
  20798. * Copy a FloatArray into a specific associated vertex buffer
  20799. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20800. * - VertexBuffer.PositionKind
  20801. * - VertexBuffer.UVKind
  20802. * - VertexBuffer.UV2Kind
  20803. * - VertexBuffer.UV3Kind
  20804. * - VertexBuffer.UV4Kind
  20805. * - VertexBuffer.UV5Kind
  20806. * - VertexBuffer.UV6Kind
  20807. * - VertexBuffer.ColorKind
  20808. * - VertexBuffer.MatricesIndicesKind
  20809. * - VertexBuffer.MatricesIndicesExtraKind
  20810. * - VertexBuffer.MatricesWeightsKind
  20811. * - VertexBuffer.MatricesWeightsExtraKind
  20812. * @param data defines the data source
  20813. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20814. * @param stride defines the data stride size (can be null)
  20815. * @returns the current mesh
  20816. */
  20817. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20818. /**
  20819. * Flags an associated vertex buffer as updatable
  20820. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20821. * - VertexBuffer.PositionKind
  20822. * - VertexBuffer.UVKind
  20823. * - VertexBuffer.UV2Kind
  20824. * - VertexBuffer.UV3Kind
  20825. * - VertexBuffer.UV4Kind
  20826. * - VertexBuffer.UV5Kind
  20827. * - VertexBuffer.UV6Kind
  20828. * - VertexBuffer.ColorKind
  20829. * - VertexBuffer.MatricesIndicesKind
  20830. * - VertexBuffer.MatricesIndicesExtraKind
  20831. * - VertexBuffer.MatricesWeightsKind
  20832. * - VertexBuffer.MatricesWeightsExtraKind
  20833. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20834. */
  20835. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20836. /**
  20837. * Sets the mesh global Vertex Buffer
  20838. * @param buffer defines the buffer to use
  20839. * @returns the current mesh
  20840. */
  20841. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20842. /**
  20843. * Update a specific associated vertex buffer
  20844. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20845. * - VertexBuffer.PositionKind
  20846. * - VertexBuffer.UVKind
  20847. * - VertexBuffer.UV2Kind
  20848. * - VertexBuffer.UV3Kind
  20849. * - VertexBuffer.UV4Kind
  20850. * - VertexBuffer.UV5Kind
  20851. * - VertexBuffer.UV6Kind
  20852. * - VertexBuffer.ColorKind
  20853. * - VertexBuffer.MatricesIndicesKind
  20854. * - VertexBuffer.MatricesIndicesExtraKind
  20855. * - VertexBuffer.MatricesWeightsKind
  20856. * - VertexBuffer.MatricesWeightsExtraKind
  20857. * @param data defines the data source
  20858. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20859. * @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)
  20860. * @returns the current mesh
  20861. */
  20862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20863. /**
  20864. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20865. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20866. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20867. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20868. * @returns the current mesh
  20869. */
  20870. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20871. /**
  20872. * Creates a un-shared specific occurence of the geometry for the mesh.
  20873. * @returns the current mesh
  20874. */
  20875. makeGeometryUnique(): Mesh;
  20876. /**
  20877. * Set the index buffer of this mesh
  20878. * @param indices defines the source data
  20879. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20880. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20881. * @returns the current mesh
  20882. */
  20883. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20884. /**
  20885. * Update the current index buffer
  20886. * @param indices defines the source data
  20887. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20888. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20889. * @returns the current mesh
  20890. */
  20891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20892. /**
  20893. * Invert the geometry to move from a right handed system to a left handed one.
  20894. * @returns the current mesh
  20895. */
  20896. toLeftHanded(): Mesh;
  20897. /** @hidden */
  20898. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20899. /** @hidden */
  20900. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20901. /**
  20902. * Registers for this mesh a javascript function called just before the rendering process
  20903. * @param func defines the function to call before rendering this mesh
  20904. * @returns the current mesh
  20905. */
  20906. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20907. /**
  20908. * Disposes a previously registered javascript function called before the rendering
  20909. * @param func defines the function to remove
  20910. * @returns the current mesh
  20911. */
  20912. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20913. /**
  20914. * Registers for this mesh a javascript function called just after the rendering is complete
  20915. * @param func defines the function to call after rendering this mesh
  20916. * @returns the current mesh
  20917. */
  20918. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20919. /**
  20920. * Disposes a previously registered javascript function called after the rendering.
  20921. * @param func defines the function to remove
  20922. * @returns the current mesh
  20923. */
  20924. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20925. /** @hidden */
  20926. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20927. /** @hidden */
  20928. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20929. /** @hidden */
  20930. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20931. /**
  20932. * 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
  20933. * @param subMesh defines the subMesh to render
  20934. * @param enableAlphaMode defines if alpha mode can be changed
  20935. * @returns the current mesh
  20936. */
  20937. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20938. private _onBeforeDraw;
  20939. /**
  20940. * Renormalize the mesh and patch it up if there are no weights
  20941. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20942. * However in the case of zero weights then we set just a single influence to 1.
  20943. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20944. */
  20945. cleanMatrixWeights(): void;
  20946. private normalizeSkinFourWeights;
  20947. private normalizeSkinWeightsAndExtra;
  20948. /**
  20949. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20950. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20951. * the user know there was an issue with importing the mesh
  20952. * @returns a validation object with skinned, valid and report string
  20953. */
  20954. validateSkinning(): {
  20955. skinned: boolean;
  20956. valid: boolean;
  20957. report: string;
  20958. };
  20959. /** @hidden */
  20960. _checkDelayState(): Mesh;
  20961. private _queueLoad;
  20962. /**
  20963. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20964. * A mesh is in the frustum if its bounding box intersects the frustum
  20965. * @param frustumPlanes defines the frustum to test
  20966. * @returns true if the mesh is in the frustum planes
  20967. */
  20968. isInFrustum(frustumPlanes: Plane[]): boolean;
  20969. /**
  20970. * Sets the mesh material by the material or multiMaterial `id` property
  20971. * @param id is a string identifying the material or the multiMaterial
  20972. * @returns the current mesh
  20973. */
  20974. setMaterialByID(id: string): Mesh;
  20975. /**
  20976. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20977. * @returns an array of IAnimatable
  20978. */
  20979. getAnimatables(): IAnimatable[];
  20980. /**
  20981. * Modifies the mesh geometry according to the passed transformation matrix.
  20982. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20983. * The mesh normals are modified using the same transformation.
  20984. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20985. * @param transform defines the transform matrix to use
  20986. * @see http://doc.babylonjs.com/resources/baking_transformations
  20987. * @returns the current mesh
  20988. */
  20989. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20990. /**
  20991. * Modifies the mesh geometry according to its own current World Matrix.
  20992. * The mesh World Matrix is then reset.
  20993. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20994. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20995. * @see http://doc.babylonjs.com/resources/baking_transformations
  20996. * @returns the current mesh
  20997. */
  20998. bakeCurrentTransformIntoVertices(): Mesh;
  20999. /** @hidden */
  21000. readonly _positions: Nullable<Vector3[]>;
  21001. /** @hidden */
  21002. _resetPointsArrayCache(): Mesh;
  21003. /** @hidden */
  21004. _generatePointsArray(): boolean;
  21005. /**
  21006. * Returns a new Mesh object generated from the current mesh properties.
  21007. * This method must not get confused with createInstance()
  21008. * @param name is a string, the name given to the new mesh
  21009. * @param newParent can be any Node object (default `null`)
  21010. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21011. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21012. * @returns a new mesh
  21013. */
  21014. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21015. /**
  21016. * Releases resources associated with this mesh.
  21017. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21018. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21019. */
  21020. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21021. /**
  21022. * Modifies the mesh geometry according to a displacement map.
  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 url is a string, the URL from the image file is to be downloaded.
  21026. * @param minHeight is the lower limit of the displacement.
  21027. * @param maxHeight is the upper limit of the displacement.
  21028. * @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.
  21029. * @param uvOffset is an optional vector2 used to offset UV.
  21030. * @param uvScale is an optional vector2 used to scale UV.
  21031. * @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.
  21032. * @returns the Mesh.
  21033. */
  21034. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21035. /**
  21036. * Modifies the mesh geometry according to a displacementMap buffer.
  21037. * 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.
  21038. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21039. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21040. * @param heightMapWidth is the width of the buffer image.
  21041. * @param heightMapHeight is the height of the buffer image.
  21042. * @param minHeight is the lower limit of the displacement.
  21043. * @param maxHeight is the upper limit of the displacement.
  21044. * @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.
  21045. * @param uvOffset is an optional vector2 used to offset UV.
  21046. * @param uvScale is an optional vector2 used to scale UV.
  21047. * @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.
  21048. * @returns the Mesh.
  21049. */
  21050. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21051. /**
  21052. * Modify the mesh to get a flat shading rendering.
  21053. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21054. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21055. * @returns current mesh
  21056. */
  21057. convertToFlatShadedMesh(): Mesh;
  21058. /**
  21059. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21060. * In other words, more vertices, no more indices and a single bigger VBO.
  21061. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21062. * @returns current mesh
  21063. */
  21064. convertToUnIndexedMesh(): Mesh;
  21065. /**
  21066. * Inverses facet orientations.
  21067. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21068. * @param flipNormals will also inverts the normals
  21069. * @returns current mesh
  21070. */
  21071. flipFaces(flipNormals?: boolean): Mesh;
  21072. /** @hidden */
  21073. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21074. /** @hidden */
  21075. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21076. /**
  21077. * Creates a new InstancedMesh object from the mesh model.
  21078. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21079. * @param name defines the name of the new instance
  21080. * @returns a new InstancedMesh
  21081. */
  21082. createInstance(name: string): InstancedMesh;
  21083. /**
  21084. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21085. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21086. * @returns the current mesh
  21087. */
  21088. synchronizeInstances(): Mesh;
  21089. /**
  21090. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21091. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21092. * This should be used together with the simplification to avoid disappearing triangles.
  21093. * @param successCallback an optional success callback to be called after the optimization finished.
  21094. * @returns the current mesh
  21095. */
  21096. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21097. /**
  21098. * Serialize current mesh
  21099. * @param serializationObject defines the object which will receive the serialization data
  21100. */
  21101. serialize(serializationObject: any): void;
  21102. /** @hidden */
  21103. _syncGeometryWithMorphTargetManager(): void;
  21104. /** @hidden */
  21105. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21106. /**
  21107. * Returns a new Mesh object parsed from the source provided.
  21108. * @param parsedMesh is the source
  21109. * @param scene defines the hosting scene
  21110. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21111. * @returns a new Mesh
  21112. */
  21113. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21114. /**
  21115. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21116. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21117. * @param name defines the name of the mesh to create
  21118. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21119. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21120. * @param closePath creates a seam between the first and the last points of each path of the path array
  21121. * @param offset is taken in account only if the `pathArray` is containing a single path
  21122. * @param scene defines the hosting scene
  21123. * @param updatable defines if the mesh must be flagged as updatable
  21124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21125. * @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)
  21126. * @returns a new Mesh
  21127. */
  21128. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21129. /**
  21130. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21131. * @param name defines the name of the mesh to create
  21132. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21133. * @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
  21134. * @param scene defines the hosting scene
  21135. * @param updatable defines if the mesh must be flagged as updatable
  21136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21137. * @returns a new Mesh
  21138. */
  21139. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21140. /**
  21141. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21142. * @param name defines the name of the mesh to create
  21143. * @param size sets the size (float) of each box side (default 1)
  21144. * @param scene defines the hosting scene
  21145. * @param updatable defines if the mesh must be flagged as updatable
  21146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21147. * @returns a new Mesh
  21148. */
  21149. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21150. /**
  21151. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21152. * @param name defines the name of the mesh to create
  21153. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21154. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21161. /**
  21162. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  21165. * @param diameterTop set the top cap diameter (floats, default 1)
  21166. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21167. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21168. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21169. * @param scene defines the hosting scene
  21170. * @param updatable defines if the mesh must be flagged as updatable
  21171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21172. * @returns a new Mesh
  21173. */
  21174. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21175. /**
  21176. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21177. * @param name defines the name of the mesh to create
  21178. * @param diameter sets the diameter size (float) of the torus (default 1)
  21179. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21180. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21181. * @param scene defines the hosting scene
  21182. * @param updatable defines if the mesh must be flagged as updatable
  21183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21184. * @returns a new Mesh
  21185. */
  21186. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21187. /**
  21188. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21189. * @param name defines the name of the mesh to create
  21190. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21191. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21192. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21193. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21194. * @param p the number of windings on X axis (positive integers, default 2)
  21195. * @param q the number of windings on Y axis (positive integers, default 3)
  21196. * @param scene defines the hosting scene
  21197. * @param updatable defines if the mesh must be flagged as updatable
  21198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21199. * @returns a new Mesh
  21200. */
  21201. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21202. /**
  21203. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21204. * @param name defines the name of the mesh to create
  21205. * @param points is an array successive Vector3
  21206. * @param scene defines the hosting scene
  21207. * @param updatable defines if the mesh must be flagged as updatable
  21208. * @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).
  21209. * @returns a new Mesh
  21210. */
  21211. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21212. /**
  21213. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21214. * @param name defines the name of the mesh to create
  21215. * @param points is an array successive Vector3
  21216. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21217. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21218. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21219. * @param scene defines the hosting scene
  21220. * @param updatable defines if the mesh must be flagged as updatable
  21221. * @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)
  21222. * @returns a new Mesh
  21223. */
  21224. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21225. /**
  21226. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21227. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21228. * 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.
  21229. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21230. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21231. * Remember you can only change the shape positions, not their number when updating a polygon.
  21232. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21233. * @param name defines the name of the mesh to create
  21234. * @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
  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 CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21243. /**
  21244. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21245. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21246. * @param name defines the name of the mesh to create
  21247. * @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
  21248. * @param depth defines the height of extrusion
  21249. * @param scene defines the hosting scene
  21250. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21251. * @param updatable defines if the mesh must be flagged as updatable
  21252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21253. * @param earcutInjection can be used to inject your own earcut reference
  21254. * @returns a new Mesh
  21255. */
  21256. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21257. /**
  21258. * Creates an extruded shape mesh.
  21259. * 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
  21260. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21261. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21262. * @param name defines the name of the mesh to create
  21263. * @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
  21264. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21265. * @param scale is the value to scale the shape
  21266. * @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
  21267. * @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
  21268. * @param scene defines the hosting scene
  21269. * @param updatable defines if the mesh must be flagged as updatable
  21270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21271. * @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)
  21272. * @returns a new Mesh
  21273. */
  21274. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21275. /**
  21276. * Creates an custom extruded shape mesh.
  21277. * The custom extrusion is a parametric shape.
  21278. * It has no predefined shape. Its final shape will depend on the input parameters.
  21279. * Please consider using the same method from the MeshBuilder class instead
  21280. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21281. * @param name defines the name of the mesh to create
  21282. * @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
  21283. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21284. * @param scaleFunction is a custom Javascript function called on each path point
  21285. * @param rotationFunction is a custom Javascript function called on each path point
  21286. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21287. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21288. * @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
  21289. * @param scene defines the hosting scene
  21290. * @param updatable defines if the mesh must be flagged as updatable
  21291. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21292. * @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)
  21293. * @returns a new Mesh
  21294. */
  21295. 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;
  21296. /**
  21297. * Creates lathe mesh.
  21298. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21299. * Please consider using the same method from the MeshBuilder class instead
  21300. * @param name defines the name of the mesh to create
  21301. * @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
  21302. * @param radius is the radius value of the lathe
  21303. * @param tessellation is the side number of the lathe.
  21304. * @param scene defines the hosting scene
  21305. * @param updatable defines if the mesh must be flagged as updatable
  21306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21307. * @returns a new Mesh
  21308. */
  21309. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21310. /**
  21311. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21312. * @param name defines the name of the mesh to create
  21313. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21314. * @param scene defines the hosting scene
  21315. * @param updatable defines if the mesh must be flagged as updatable
  21316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21317. * @returns a new Mesh
  21318. */
  21319. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21320. /**
  21321. * Creates a ground mesh.
  21322. * Please consider using the same method from the MeshBuilder class instead
  21323. * @param name defines the name of the mesh to create
  21324. * @param width set the width of the ground
  21325. * @param height set the height of the ground
  21326. * @param subdivisions sets the number of subdivisions per side
  21327. * @param scene defines the hosting scene
  21328. * @param updatable defines if the mesh must be flagged as updatable
  21329. * @returns a new Mesh
  21330. */
  21331. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21332. /**
  21333. * Creates a tiled ground mesh.
  21334. * Please consider using the same method from the MeshBuilder class instead
  21335. * @param name defines the name of the mesh to create
  21336. * @param xmin set the ground minimum X coordinate
  21337. * @param zmin set the ground minimum Y coordinate
  21338. * @param xmax set the ground maximum X coordinate
  21339. * @param zmax set the ground maximum Z coordinate
  21340. * @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
  21341. * @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
  21342. * @param scene defines the hosting scene
  21343. * @param updatable defines if the mesh must be flagged as updatable
  21344. * @returns a new Mesh
  21345. */
  21346. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21347. w: number;
  21348. h: number;
  21349. }, precision: {
  21350. w: number;
  21351. h: number;
  21352. }, scene: Scene, updatable?: boolean): Mesh;
  21353. /**
  21354. * Creates a ground mesh from a height map.
  21355. * Please consider using the same method from the MeshBuilder class instead
  21356. * @see http://doc.babylonjs.com/babylon101/height_map
  21357. * @param name defines the name of the mesh to create
  21358. * @param url sets the URL of the height map image resource
  21359. * @param width set the ground width size
  21360. * @param height set the ground height size
  21361. * @param subdivisions sets the number of subdivision per side
  21362. * @param minHeight is the minimum altitude on the ground
  21363. * @param maxHeight is the maximum altitude on the ground
  21364. * @param scene defines the hosting scene
  21365. * @param updatable defines if the mesh must be flagged as updatable
  21366. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21367. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21368. * @returns a new Mesh
  21369. */
  21370. 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;
  21371. /**
  21372. * Creates a tube mesh.
  21373. * The tube is a parametric shape.
  21374. * It has no predefined shape. Its final shape will depend on the input parameters.
  21375. * Please consider using the same method from the MeshBuilder class instead
  21376. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21377. * @param name defines the name of the mesh to create
  21378. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21379. * @param radius sets the tube radius size
  21380. * @param tessellation is the number of sides on the tubular surface
  21381. * @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
  21382. * @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
  21383. * @param scene defines the hosting scene
  21384. * @param updatable defines if the mesh must be flagged as updatable
  21385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21386. * @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)
  21387. * @returns a new Mesh
  21388. */
  21389. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21390. (i: number, distance: number): number;
  21391. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21392. /**
  21393. * Creates a polyhedron mesh.
  21394. * Please consider using the same method from the MeshBuilder class instead.
  21395. * * 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
  21396. * * The parameter `size` (positive float, default 1) sets the polygon size
  21397. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21398. * * 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`
  21399. * * 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
  21400. * * 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)`)
  21401. * * 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
  21402. * * 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
  21403. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21404. * * If you create a double-sided mesh, you can choose what parts of 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
  21405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21406. * @param name defines the name of the mesh to create
  21407. * @param options defines the options used to create the mesh
  21408. * @param scene defines the hosting scene
  21409. * @returns a new Mesh
  21410. */
  21411. static CreatePolyhedron(name: string, options: {
  21412. type?: number;
  21413. size?: number;
  21414. sizeX?: number;
  21415. sizeY?: number;
  21416. sizeZ?: number;
  21417. custom?: any;
  21418. faceUV?: Vector4[];
  21419. faceColors?: Color4[];
  21420. updatable?: boolean;
  21421. sideOrientation?: number;
  21422. }, scene: Scene): Mesh;
  21423. /**
  21424. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21425. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21426. * * 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`)
  21427. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21428. * * 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
  21429. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21430. * * If you create a double-sided mesh, you can choose what parts of 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
  21431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21432. * @param name defines the name of the mesh
  21433. * @param options defines the options used to create the mesh
  21434. * @param scene defines the hosting scene
  21435. * @returns a new Mesh
  21436. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21437. */
  21438. static CreateIcoSphere(name: string, options: {
  21439. radius?: number;
  21440. flat?: boolean;
  21441. subdivisions?: number;
  21442. sideOrientation?: number;
  21443. updatable?: boolean;
  21444. }, scene: Scene): Mesh;
  21445. /**
  21446. * Creates a decal mesh.
  21447. * Please consider using the same method from the MeshBuilder class instead.
  21448. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21449. * @param name defines the name of the mesh
  21450. * @param sourceMesh defines the mesh receiving the decal
  21451. * @param position sets the position of the decal in world coordinates
  21452. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21453. * @param size sets the decal scaling
  21454. * @param angle sets the angle to rotate the decal
  21455. * @returns a new Mesh
  21456. */
  21457. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21458. /**
  21459. * Prepare internal position array for software CPU skinning
  21460. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21461. */
  21462. setPositionsForCPUSkinning(): Float32Array;
  21463. /**
  21464. * Prepare internal normal array for software CPU skinning
  21465. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21466. */
  21467. setNormalsForCPUSkinning(): Float32Array;
  21468. /**
  21469. * Updates the vertex buffer by applying transformation from the bones
  21470. * @param skeleton defines the skeleton to apply to current mesh
  21471. * @returns the current mesh
  21472. */
  21473. applySkeleton(skeleton: Skeleton): Mesh;
  21474. /**
  21475. * 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
  21476. * @param meshes defines the list of meshes to scan
  21477. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21478. */
  21479. static MinMax(meshes: AbstractMesh[]): {
  21480. min: Vector3;
  21481. max: Vector3;
  21482. };
  21483. /**
  21484. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21485. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21486. * @returns a vector3
  21487. */
  21488. static Center(meshesOrMinMaxVector: {
  21489. min: Vector3;
  21490. max: Vector3;
  21491. } | AbstractMesh[]): Vector3;
  21492. /**
  21493. * Merge the array of meshes into a single mesh for performance reasons.
  21494. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21495. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21496. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21497. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21498. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21499. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21500. * @returns a new mesh
  21501. */
  21502. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21503. /** @hidden */
  21504. addInstance(instance: InstancedMesh): void;
  21505. /** @hidden */
  21506. removeInstance(instance: InstancedMesh): void;
  21507. }
  21508. }
  21509. declare module "babylonjs/Materials/material" {
  21510. import { IAnimatable } from "babylonjs/Misc/tools";
  21511. import { SmartArray } from "babylonjs/Misc/smartArray";
  21512. import { Observable } from "babylonjs/Misc/observable";
  21513. import { Nullable } from "babylonjs/types";
  21514. import { Scene } from "babylonjs/scene";
  21515. import { Matrix } from "babylonjs/Maths/math";
  21516. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21518. import { Mesh } from "babylonjs/Meshes/mesh";
  21519. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21520. import { Effect } from "babylonjs/Materials/effect";
  21521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21524. import { Animation } from "babylonjs/Animations/animation";
  21525. /**
  21526. * Base class for the main features of a material in Babylon.js
  21527. */
  21528. export class Material implements IAnimatable {
  21529. /**
  21530. * Returns the triangle fill mode
  21531. */
  21532. static readonly TriangleFillMode: number;
  21533. /**
  21534. * Returns the wireframe mode
  21535. */
  21536. static readonly WireFrameFillMode: number;
  21537. /**
  21538. * Returns the point fill mode
  21539. */
  21540. static readonly PointFillMode: number;
  21541. /**
  21542. * Returns the point list draw mode
  21543. */
  21544. static readonly PointListDrawMode: number;
  21545. /**
  21546. * Returns the line list draw mode
  21547. */
  21548. static readonly LineListDrawMode: number;
  21549. /**
  21550. * Returns the line loop draw mode
  21551. */
  21552. static readonly LineLoopDrawMode: number;
  21553. /**
  21554. * Returns the line strip draw mode
  21555. */
  21556. static readonly LineStripDrawMode: number;
  21557. /**
  21558. * Returns the triangle strip draw mode
  21559. */
  21560. static readonly TriangleStripDrawMode: number;
  21561. /**
  21562. * Returns the triangle fan draw mode
  21563. */
  21564. static readonly TriangleFanDrawMode: number;
  21565. /**
  21566. * Stores the clock-wise side orientation
  21567. */
  21568. static readonly ClockWiseSideOrientation: number;
  21569. /**
  21570. * Stores the counter clock-wise side orientation
  21571. */
  21572. static readonly CounterClockWiseSideOrientation: number;
  21573. /**
  21574. * The dirty texture flag value
  21575. */
  21576. static readonly TextureDirtyFlag: number;
  21577. /**
  21578. * The dirty light flag value
  21579. */
  21580. static readonly LightDirtyFlag: number;
  21581. /**
  21582. * The dirty fresnel flag value
  21583. */
  21584. static readonly FresnelDirtyFlag: number;
  21585. /**
  21586. * The dirty attribute flag value
  21587. */
  21588. static readonly AttributesDirtyFlag: number;
  21589. /**
  21590. * The dirty misc flag value
  21591. */
  21592. static readonly MiscDirtyFlag: number;
  21593. /**
  21594. * The all dirty flag value
  21595. */
  21596. static readonly AllDirtyFlag: number;
  21597. /**
  21598. * The ID of the material
  21599. */
  21600. id: string;
  21601. /**
  21602. * Gets or sets the unique id of the material
  21603. */
  21604. uniqueId: number;
  21605. /**
  21606. * The name of the material
  21607. */
  21608. name: string;
  21609. /**
  21610. * Gets or sets user defined metadata
  21611. */
  21612. metadata: any;
  21613. /**
  21614. * For internal use only. Please do not use.
  21615. */
  21616. reservedDataStore: any;
  21617. /**
  21618. * Specifies if the ready state should be checked on each call
  21619. */
  21620. checkReadyOnEveryCall: boolean;
  21621. /**
  21622. * Specifies if the ready state should be checked once
  21623. */
  21624. checkReadyOnlyOnce: boolean;
  21625. /**
  21626. * The state of the material
  21627. */
  21628. state: string;
  21629. /**
  21630. * The alpha value of the material
  21631. */
  21632. protected _alpha: number;
  21633. /**
  21634. * Sets the alpha value of the material
  21635. */
  21636. /**
  21637. * Gets the alpha value of the material
  21638. */
  21639. alpha: number;
  21640. /**
  21641. * Specifies if back face culling is enabled
  21642. */
  21643. protected _backFaceCulling: boolean;
  21644. /**
  21645. * Sets the back-face culling state
  21646. */
  21647. /**
  21648. * Gets the back-face culling state
  21649. */
  21650. backFaceCulling: boolean;
  21651. /**
  21652. * Stores the value for side orientation
  21653. */
  21654. sideOrientation: number;
  21655. /**
  21656. * Callback triggered when the material is compiled
  21657. */
  21658. onCompiled: (effect: Effect) => void;
  21659. /**
  21660. * Callback triggered when an error occurs
  21661. */
  21662. onError: (effect: Effect, errors: string) => void;
  21663. /**
  21664. * Callback triggered to get the render target textures
  21665. */
  21666. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21667. /**
  21668. * Gets a boolean indicating that current material needs to register RTT
  21669. */
  21670. readonly hasRenderTargetTextures: boolean;
  21671. /**
  21672. * Specifies if the material should be serialized
  21673. */
  21674. doNotSerialize: boolean;
  21675. /**
  21676. * @hidden
  21677. */
  21678. _storeEffectOnSubMeshes: boolean;
  21679. /**
  21680. * Stores the animations for the material
  21681. */
  21682. animations: Array<Animation>;
  21683. /**
  21684. * An event triggered when the material is disposed
  21685. */
  21686. onDisposeObservable: Observable<Material>;
  21687. /**
  21688. * An observer which watches for dispose events
  21689. */
  21690. private _onDisposeObserver;
  21691. private _onUnBindObservable;
  21692. /**
  21693. * Called during a dispose event
  21694. */
  21695. onDispose: () => void;
  21696. private _onBindObservable;
  21697. /**
  21698. * An event triggered when the material is bound
  21699. */
  21700. readonly onBindObservable: Observable<AbstractMesh>;
  21701. /**
  21702. * An observer which watches for bind events
  21703. */
  21704. private _onBindObserver;
  21705. /**
  21706. * Called during a bind event
  21707. */
  21708. onBind: (Mesh: AbstractMesh) => void;
  21709. /**
  21710. * An event triggered when the material is unbound
  21711. */
  21712. readonly onUnBindObservable: Observable<Material>;
  21713. /**
  21714. * Stores the value of the alpha mode
  21715. */
  21716. private _alphaMode;
  21717. /**
  21718. * Sets the value of the alpha mode.
  21719. *
  21720. * | Value | Type | Description |
  21721. * | --- | --- | --- |
  21722. * | 0 | ALPHA_DISABLE | |
  21723. * | 1 | ALPHA_ADD | |
  21724. * | 2 | ALPHA_COMBINE | |
  21725. * | 3 | ALPHA_SUBTRACT | |
  21726. * | 4 | ALPHA_MULTIPLY | |
  21727. * | 5 | ALPHA_MAXIMIZED | |
  21728. * | 6 | ALPHA_ONEONE | |
  21729. * | 7 | ALPHA_PREMULTIPLIED | |
  21730. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21731. * | 9 | ALPHA_INTERPOLATE | |
  21732. * | 10 | ALPHA_SCREENMODE | |
  21733. *
  21734. */
  21735. /**
  21736. * Gets the value of the alpha mode
  21737. */
  21738. alphaMode: number;
  21739. /**
  21740. * Stores the state of the need depth pre-pass value
  21741. */
  21742. private _needDepthPrePass;
  21743. /**
  21744. * Sets the need depth pre-pass value
  21745. */
  21746. /**
  21747. * Gets the depth pre-pass value
  21748. */
  21749. needDepthPrePass: boolean;
  21750. /**
  21751. * Specifies if depth writing should be disabled
  21752. */
  21753. disableDepthWrite: boolean;
  21754. /**
  21755. * Specifies if depth writing should be forced
  21756. */
  21757. forceDepthWrite: boolean;
  21758. /**
  21759. * Specifies if there should be a separate pass for culling
  21760. */
  21761. separateCullingPass: boolean;
  21762. /**
  21763. * Stores the state specifing if fog should be enabled
  21764. */
  21765. private _fogEnabled;
  21766. /**
  21767. * Sets the state for enabling fog
  21768. */
  21769. /**
  21770. * Gets the value of the fog enabled state
  21771. */
  21772. fogEnabled: boolean;
  21773. /**
  21774. * Stores the size of points
  21775. */
  21776. pointSize: number;
  21777. /**
  21778. * Stores the z offset value
  21779. */
  21780. zOffset: number;
  21781. /**
  21782. * Gets a value specifying if wireframe mode is enabled
  21783. */
  21784. /**
  21785. * Sets the state of wireframe mode
  21786. */
  21787. wireframe: boolean;
  21788. /**
  21789. * Gets the value specifying if point clouds are enabled
  21790. */
  21791. /**
  21792. * Sets the state of point cloud mode
  21793. */
  21794. pointsCloud: boolean;
  21795. /**
  21796. * Gets the material fill mode
  21797. */
  21798. /**
  21799. * Sets the material fill mode
  21800. */
  21801. fillMode: number;
  21802. /**
  21803. * @hidden
  21804. * Stores the effects for the material
  21805. */
  21806. _effect: Nullable<Effect>;
  21807. /**
  21808. * @hidden
  21809. * Specifies if the material was previously ready
  21810. */
  21811. _wasPreviouslyReady: boolean;
  21812. /**
  21813. * Specifies if uniform buffers should be used
  21814. */
  21815. private _useUBO;
  21816. /**
  21817. * Stores a reference to the scene
  21818. */
  21819. private _scene;
  21820. /**
  21821. * Stores the fill mode state
  21822. */
  21823. private _fillMode;
  21824. /**
  21825. * Specifies if the depth write state should be cached
  21826. */
  21827. private _cachedDepthWriteState;
  21828. /**
  21829. * Stores the uniform buffer
  21830. */
  21831. protected _uniformBuffer: UniformBuffer;
  21832. /** @hidden */
  21833. _indexInSceneMaterialArray: number;
  21834. /** @hidden */
  21835. meshMap: Nullable<{
  21836. [id: string]: AbstractMesh | undefined;
  21837. }>;
  21838. /**
  21839. * Creates a material instance
  21840. * @param name defines the name of the material
  21841. * @param scene defines the scene to reference
  21842. * @param doNotAdd specifies if the material should be added to the scene
  21843. */
  21844. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21845. /**
  21846. * Returns a string representation of the current material
  21847. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21848. * @returns a string with material information
  21849. */
  21850. toString(fullDetails?: boolean): string;
  21851. /**
  21852. * Gets the class name of the material
  21853. * @returns a string with the class name of the material
  21854. */
  21855. getClassName(): string;
  21856. /**
  21857. * Specifies if updates for the material been locked
  21858. */
  21859. readonly isFrozen: boolean;
  21860. /**
  21861. * Locks updates for the material
  21862. */
  21863. freeze(): void;
  21864. /**
  21865. * Unlocks updates for the material
  21866. */
  21867. unfreeze(): void;
  21868. /**
  21869. * Specifies if the material is ready to be used
  21870. * @param mesh defines the mesh to check
  21871. * @param useInstances specifies if instances should be used
  21872. * @returns a boolean indicating if the material is ready to be used
  21873. */
  21874. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21875. /**
  21876. * Specifies that the submesh is ready to be used
  21877. * @param mesh defines the mesh to check
  21878. * @param subMesh defines which submesh to check
  21879. * @param useInstances specifies that instances should be used
  21880. * @returns a boolean indicating that the submesh is ready or not
  21881. */
  21882. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21883. /**
  21884. * Returns the material effect
  21885. * @returns the effect associated with the material
  21886. */
  21887. getEffect(): Nullable<Effect>;
  21888. /**
  21889. * Returns the current scene
  21890. * @returns a Scene
  21891. */
  21892. getScene(): Scene;
  21893. /**
  21894. * Specifies if the material will require alpha blending
  21895. * @returns a boolean specifying if alpha blending is needed
  21896. */
  21897. needAlphaBlending(): boolean;
  21898. /**
  21899. * Specifies if the mesh will require alpha blending
  21900. * @param mesh defines the mesh to check
  21901. * @returns a boolean specifying if alpha blending is needed for the mesh
  21902. */
  21903. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21904. /**
  21905. * Specifies if this material should be rendered in alpha test mode
  21906. * @returns a boolean specifying if an alpha test is needed.
  21907. */
  21908. needAlphaTesting(): boolean;
  21909. /**
  21910. * Gets the texture used for the alpha test
  21911. * @returns the texture to use for alpha testing
  21912. */
  21913. getAlphaTestTexture(): Nullable<BaseTexture>;
  21914. /**
  21915. * Marks the material to indicate that it needs to be re-calculated
  21916. */
  21917. markDirty(): void;
  21918. /** @hidden */
  21919. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21920. /**
  21921. * Binds the material to the mesh
  21922. * @param world defines the world transformation matrix
  21923. * @param mesh defines the mesh to bind the material to
  21924. */
  21925. bind(world: Matrix, mesh?: Mesh): void;
  21926. /**
  21927. * Binds the submesh to the material
  21928. * @param world defines the world transformation matrix
  21929. * @param mesh defines the mesh containing the submesh
  21930. * @param subMesh defines the submesh to bind the material to
  21931. */
  21932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21933. /**
  21934. * Binds the world matrix to the material
  21935. * @param world defines the world transformation matrix
  21936. */
  21937. bindOnlyWorldMatrix(world: Matrix): void;
  21938. /**
  21939. * Binds the scene's uniform buffer to the effect.
  21940. * @param effect defines the effect to bind to the scene uniform buffer
  21941. * @param sceneUbo defines the uniform buffer storing scene data
  21942. */
  21943. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21944. /**
  21945. * Binds the view matrix to the effect
  21946. * @param effect defines the effect to bind the view matrix to
  21947. */
  21948. bindView(effect: Effect): void;
  21949. /**
  21950. * Binds the view projection matrix to the effect
  21951. * @param effect defines the effect to bind the view projection matrix to
  21952. */
  21953. bindViewProjection(effect: Effect): void;
  21954. /**
  21955. * Specifies if material alpha testing should be turned on for the mesh
  21956. * @param mesh defines the mesh to check
  21957. */
  21958. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21959. /**
  21960. * Processes to execute after binding the material to a mesh
  21961. * @param mesh defines the rendered mesh
  21962. */
  21963. protected _afterBind(mesh?: Mesh): void;
  21964. /**
  21965. * Unbinds the material from the mesh
  21966. */
  21967. unbind(): void;
  21968. /**
  21969. * Gets the active textures from the material
  21970. * @returns an array of textures
  21971. */
  21972. getActiveTextures(): BaseTexture[];
  21973. /**
  21974. * Specifies if the material uses a texture
  21975. * @param texture defines the texture to check against the material
  21976. * @returns a boolean specifying if the material uses the texture
  21977. */
  21978. hasTexture(texture: BaseTexture): boolean;
  21979. /**
  21980. * Makes a duplicate of the material, and gives it a new name
  21981. * @param name defines the new name for the duplicated material
  21982. * @returns the cloned material
  21983. */
  21984. clone(name: string): Nullable<Material>;
  21985. /**
  21986. * Gets the meshes bound to the material
  21987. * @returns an array of meshes bound to the material
  21988. */
  21989. getBindedMeshes(): AbstractMesh[];
  21990. /**
  21991. * Force shader compilation
  21992. * @param mesh defines the mesh associated with this material
  21993. * @param onCompiled defines a function to execute once the material is compiled
  21994. * @param options defines the options to configure the compilation
  21995. */
  21996. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21997. clipPlane: boolean;
  21998. }>): void;
  21999. /**
  22000. * Force shader compilation
  22001. * @param mesh defines the mesh that will use this material
  22002. * @param options defines additional options for compiling the shaders
  22003. * @returns a promise that resolves when the compilation completes
  22004. */
  22005. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22006. clipPlane: boolean;
  22007. }>): Promise<void>;
  22008. private static readonly _ImageProcessingDirtyCallBack;
  22009. private static readonly _TextureDirtyCallBack;
  22010. private static readonly _FresnelDirtyCallBack;
  22011. private static readonly _MiscDirtyCallBack;
  22012. private static readonly _LightsDirtyCallBack;
  22013. private static readonly _AttributeDirtyCallBack;
  22014. private static _FresnelAndMiscDirtyCallBack;
  22015. private static _TextureAndMiscDirtyCallBack;
  22016. private static readonly _DirtyCallbackArray;
  22017. private static readonly _RunDirtyCallBacks;
  22018. /**
  22019. * Marks a define in the material to indicate that it needs to be re-computed
  22020. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22021. */
  22022. markAsDirty(flag: number): void;
  22023. /**
  22024. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22025. * @param func defines a function which checks material defines against the submeshes
  22026. */
  22027. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22028. /**
  22029. * Indicates that image processing needs to be re-calculated for all submeshes
  22030. */
  22031. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22032. /**
  22033. * Indicates that textures need to be re-calculated for all submeshes
  22034. */
  22035. protected _markAllSubMeshesAsTexturesDirty(): void;
  22036. /**
  22037. * Indicates that fresnel needs to be re-calculated for all submeshes
  22038. */
  22039. protected _markAllSubMeshesAsFresnelDirty(): void;
  22040. /**
  22041. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22042. */
  22043. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22044. /**
  22045. * Indicates that lights need to be re-calculated for all submeshes
  22046. */
  22047. protected _markAllSubMeshesAsLightsDirty(): void;
  22048. /**
  22049. * Indicates that attributes need to be re-calculated for all submeshes
  22050. */
  22051. protected _markAllSubMeshesAsAttributesDirty(): void;
  22052. /**
  22053. * Indicates that misc needs to be re-calculated for all submeshes
  22054. */
  22055. protected _markAllSubMeshesAsMiscDirty(): void;
  22056. /**
  22057. * Indicates that textures and misc need to be re-calculated for all submeshes
  22058. */
  22059. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22060. /**
  22061. * Disposes the material
  22062. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22063. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22064. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22065. */
  22066. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22067. /** @hidden */
  22068. private releaseVertexArrayObject;
  22069. /**
  22070. * Serializes this material
  22071. * @returns the serialized material object
  22072. */
  22073. serialize(): any;
  22074. /**
  22075. * Creates a material from parsed material data
  22076. * @param parsedMaterial defines parsed material data
  22077. * @param scene defines the hosting scene
  22078. * @param rootUrl defines the root URL to use to load textures
  22079. * @returns a new material
  22080. */
  22081. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22082. }
  22083. }
  22084. declare module "babylonjs/Meshes/subMesh" {
  22085. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22086. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22087. import { Engine } from "babylonjs/Engines/engine";
  22088. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22089. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22090. import { Effect } from "babylonjs/Materials/effect";
  22091. import { Collider } from "babylonjs/Collisions/collider";
  22092. import { Material } from "babylonjs/Materials/material";
  22093. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22095. import { Mesh } from "babylonjs/Meshes/mesh";
  22096. import { Ray } from "babylonjs/Culling/ray";
  22097. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22098. /**
  22099. * Base class for submeshes
  22100. */
  22101. export class BaseSubMesh {
  22102. /** @hidden */
  22103. _materialDefines: Nullable<MaterialDefines>;
  22104. /** @hidden */
  22105. _materialEffect: Nullable<Effect>;
  22106. /**
  22107. * Gets associated effect
  22108. */
  22109. readonly effect: Nullable<Effect>;
  22110. /**
  22111. * Sets associated effect (effect used to render this submesh)
  22112. * @param effect defines the effect to associate with
  22113. * @param defines defines the set of defines used to compile this effect
  22114. */
  22115. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22116. }
  22117. /**
  22118. * Defines a subdivision inside a mesh
  22119. */
  22120. export class SubMesh extends BaseSubMesh implements ICullable {
  22121. /** the material index to use */
  22122. materialIndex: number;
  22123. /** vertex index start */
  22124. verticesStart: number;
  22125. /** vertices count */
  22126. verticesCount: number;
  22127. /** index start */
  22128. indexStart: number;
  22129. /** indices count */
  22130. indexCount: number;
  22131. /** @hidden */
  22132. _linesIndexCount: number;
  22133. private _mesh;
  22134. private _renderingMesh;
  22135. private _boundingInfo;
  22136. private _linesIndexBuffer;
  22137. /** @hidden */
  22138. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22139. /** @hidden */
  22140. _trianglePlanes: Plane[];
  22141. /** @hidden */
  22142. _lastColliderTransformMatrix: Matrix;
  22143. /** @hidden */
  22144. _renderId: number;
  22145. /** @hidden */
  22146. _alphaIndex: number;
  22147. /** @hidden */
  22148. _distanceToCamera: number;
  22149. /** @hidden */
  22150. _id: number;
  22151. private _currentMaterial;
  22152. /**
  22153. * Add a new submesh to a mesh
  22154. * @param materialIndex defines the material index to use
  22155. * @param verticesStart defines vertex index start
  22156. * @param verticesCount defines vertices count
  22157. * @param indexStart defines index start
  22158. * @param indexCount defines indices count
  22159. * @param mesh defines the parent mesh
  22160. * @param renderingMesh defines an optional rendering mesh
  22161. * @param createBoundingBox defines if bounding box should be created for this submesh
  22162. * @returns the new submesh
  22163. */
  22164. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22165. /**
  22166. * Creates a new submesh
  22167. * @param materialIndex defines the material index to use
  22168. * @param verticesStart defines vertex index start
  22169. * @param verticesCount defines vertices count
  22170. * @param indexStart defines index start
  22171. * @param indexCount defines indices count
  22172. * @param mesh defines the parent mesh
  22173. * @param renderingMesh defines an optional rendering mesh
  22174. * @param createBoundingBox defines if bounding box should be created for this submesh
  22175. */
  22176. constructor(
  22177. /** the material index to use */
  22178. materialIndex: number,
  22179. /** vertex index start */
  22180. verticesStart: number,
  22181. /** vertices count */
  22182. verticesCount: number,
  22183. /** index start */
  22184. indexStart: number,
  22185. /** indices count */
  22186. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22187. /**
  22188. * Returns true if this submesh covers the entire parent mesh
  22189. * @ignorenaming
  22190. */
  22191. readonly IsGlobal: boolean;
  22192. /**
  22193. * Returns the submesh BoudingInfo object
  22194. * @returns current bounding info (or mesh's one if the submesh is global)
  22195. */
  22196. getBoundingInfo(): BoundingInfo;
  22197. /**
  22198. * Sets the submesh BoundingInfo
  22199. * @param boundingInfo defines the new bounding info to use
  22200. * @returns the SubMesh
  22201. */
  22202. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22203. /**
  22204. * Returns the mesh of the current submesh
  22205. * @return the parent mesh
  22206. */
  22207. getMesh(): AbstractMesh;
  22208. /**
  22209. * Returns the rendering mesh of the submesh
  22210. * @returns the rendering mesh (could be different from parent mesh)
  22211. */
  22212. getRenderingMesh(): Mesh;
  22213. /**
  22214. * Returns the submesh material
  22215. * @returns null or the current material
  22216. */
  22217. getMaterial(): Nullable<Material>;
  22218. /**
  22219. * Sets a new updated BoundingInfo object to the submesh
  22220. * @returns the SubMesh
  22221. */
  22222. refreshBoundingInfo(): SubMesh;
  22223. /** @hidden */
  22224. _checkCollision(collider: Collider): boolean;
  22225. /**
  22226. * Updates the submesh BoundingInfo
  22227. * @param world defines the world matrix to use to update the bounding info
  22228. * @returns the submesh
  22229. */
  22230. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22231. /**
  22232. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22233. * @param frustumPlanes defines the frustum planes
  22234. * @returns true if the submesh is intersecting with the frustum
  22235. */
  22236. isInFrustum(frustumPlanes: Plane[]): boolean;
  22237. /**
  22238. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22239. * @param frustumPlanes defines the frustum planes
  22240. * @returns true if the submesh is inside the frustum
  22241. */
  22242. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22243. /**
  22244. * Renders the submesh
  22245. * @param enableAlphaMode defines if alpha needs to be used
  22246. * @returns the submesh
  22247. */
  22248. render(enableAlphaMode: boolean): SubMesh;
  22249. /**
  22250. * @hidden
  22251. */
  22252. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22253. /**
  22254. * Checks if the submesh intersects with a ray
  22255. * @param ray defines the ray to test
  22256. * @returns true is the passed ray intersects the submesh bounding box
  22257. */
  22258. canIntersects(ray: Ray): boolean;
  22259. /**
  22260. * Intersects current submesh with a ray
  22261. * @param ray defines the ray to test
  22262. * @param positions defines mesh's positions array
  22263. * @param indices defines mesh's indices array
  22264. * @param fastCheck defines if only bounding info should be used
  22265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22266. * @returns intersection info or null if no intersection
  22267. */
  22268. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22269. /** @hidden */
  22270. private _intersectLines;
  22271. /** @hidden */
  22272. private _intersectTriangles;
  22273. /** @hidden */
  22274. _rebuild(): void;
  22275. /**
  22276. * Creates a new submesh from the passed mesh
  22277. * @param newMesh defines the new hosting mesh
  22278. * @param newRenderingMesh defines an optional rendering mesh
  22279. * @returns the new submesh
  22280. */
  22281. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22282. /**
  22283. * Release associated resources
  22284. */
  22285. dispose(): void;
  22286. /**
  22287. * Gets the class name
  22288. * @returns the string "SubMesh".
  22289. */
  22290. getClassName(): string;
  22291. /**
  22292. * Creates a new submesh from indices data
  22293. * @param materialIndex the index of the main mesh material
  22294. * @param startIndex the index where to start the copy in the mesh indices array
  22295. * @param indexCount the number of indices to copy then from the startIndex
  22296. * @param mesh the main mesh to create the submesh from
  22297. * @param renderingMesh the optional rendering mesh
  22298. * @returns a new submesh
  22299. */
  22300. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22301. }
  22302. }
  22303. declare module "babylonjs/Meshes/geometry" {
  22304. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22305. import { Scene } from "babylonjs/scene";
  22306. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22307. import { Engine } from "babylonjs/Engines/engine";
  22308. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22309. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22310. import { Effect } from "babylonjs/Materials/effect";
  22311. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22312. import { Mesh } from "babylonjs/Meshes/mesh";
  22313. /**
  22314. * Class used to store geometry data (vertex buffers + index buffer)
  22315. */
  22316. export class Geometry implements IGetSetVerticesData {
  22317. /**
  22318. * Gets or sets the ID of the geometry
  22319. */
  22320. id: string;
  22321. /**
  22322. * Gets or sets the unique ID of the geometry
  22323. */
  22324. uniqueId: number;
  22325. /**
  22326. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22327. */
  22328. delayLoadState: number;
  22329. /**
  22330. * Gets the file containing the data to load when running in delay load state
  22331. */
  22332. delayLoadingFile: Nullable<string>;
  22333. /**
  22334. * Callback called when the geometry is updated
  22335. */
  22336. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22337. private _scene;
  22338. private _engine;
  22339. private _meshes;
  22340. private _totalVertices;
  22341. /** @hidden */
  22342. _indices: IndicesArray;
  22343. /** @hidden */
  22344. _vertexBuffers: {
  22345. [key: string]: VertexBuffer;
  22346. };
  22347. private _isDisposed;
  22348. private _extend;
  22349. private _boundingBias;
  22350. /** @hidden */
  22351. _delayInfo: Array<string>;
  22352. private _indexBuffer;
  22353. private _indexBufferIsUpdatable;
  22354. /** @hidden */
  22355. _boundingInfo: Nullable<BoundingInfo>;
  22356. /** @hidden */
  22357. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22358. /** @hidden */
  22359. _softwareSkinningFrameId: number;
  22360. private _vertexArrayObjects;
  22361. private _updatable;
  22362. /** @hidden */
  22363. _positions: Nullable<Vector3[]>;
  22364. /**
  22365. * 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
  22366. */
  22367. /**
  22368. * 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
  22369. */
  22370. boundingBias: Vector2;
  22371. /**
  22372. * Static function used to attach a new empty geometry to a mesh
  22373. * @param mesh defines the mesh to attach the geometry to
  22374. * @returns the new Geometry
  22375. */
  22376. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22377. /**
  22378. * Creates a new geometry
  22379. * @param id defines the unique ID
  22380. * @param scene defines the hosting scene
  22381. * @param vertexData defines the VertexData used to get geometry data
  22382. * @param updatable defines if geometry must be updatable (false by default)
  22383. * @param mesh defines the mesh that will be associated with the geometry
  22384. */
  22385. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22386. /**
  22387. * Gets the current extend of the geometry
  22388. */
  22389. readonly extend: {
  22390. minimum: Vector3;
  22391. maximum: Vector3;
  22392. };
  22393. /**
  22394. * Gets the hosting scene
  22395. * @returns the hosting Scene
  22396. */
  22397. getScene(): Scene;
  22398. /**
  22399. * Gets the hosting engine
  22400. * @returns the hosting Engine
  22401. */
  22402. getEngine(): Engine;
  22403. /**
  22404. * Defines if the geometry is ready to use
  22405. * @returns true if the geometry is ready to be used
  22406. */
  22407. isReady(): boolean;
  22408. /**
  22409. * Gets a value indicating that the geometry should not be serialized
  22410. */
  22411. readonly doNotSerialize: boolean;
  22412. /** @hidden */
  22413. _rebuild(): void;
  22414. /**
  22415. * Affects all geometry data in one call
  22416. * @param vertexData defines the geometry data
  22417. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22418. */
  22419. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22420. /**
  22421. * Set specific vertex data
  22422. * @param kind defines the data kind (Position, normal, etc...)
  22423. * @param data defines the vertex data to use
  22424. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22425. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22426. */
  22427. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22428. /**
  22429. * Removes a specific vertex data
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. */
  22432. removeVerticesData(kind: string): void;
  22433. /**
  22434. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22435. * @param buffer defines the vertex buffer to use
  22436. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22437. */
  22438. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22439. /**
  22440. * Update a specific vertex buffer
  22441. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22442. * It will do nothing if the buffer is not updatable
  22443. * @param kind defines the data kind (Position, normal, etc...)
  22444. * @param data defines the data to use
  22445. * @param offset defines the offset in the target buffer where to store the data
  22446. * @param useBytes set to true if the offset is in bytes
  22447. */
  22448. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22449. /**
  22450. * Update a specific vertex buffer
  22451. * This function will create a new buffer if the current one is not updatable
  22452. * @param kind defines the data kind (Position, normal, etc...)
  22453. * @param data defines the data to use
  22454. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22455. */
  22456. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22457. private _updateBoundingInfo;
  22458. /** @hidden */
  22459. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22460. /**
  22461. * Gets total number of vertices
  22462. * @returns the total number of vertices
  22463. */
  22464. getTotalVertices(): number;
  22465. /**
  22466. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22469. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22470. * @returns a float array containing vertex data
  22471. */
  22472. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22473. /**
  22474. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22475. * @param kind defines the data kind (Position, normal, etc...)
  22476. * @returns true if the vertex buffer with the specified kind is updatable
  22477. */
  22478. isVertexBufferUpdatable(kind: string): boolean;
  22479. /**
  22480. * Gets a specific vertex buffer
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @returns a VertexBuffer
  22483. */
  22484. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22485. /**
  22486. * Returns all vertex buffers
  22487. * @return an object holding all vertex buffers indexed by kind
  22488. */
  22489. getVertexBuffers(): Nullable<{
  22490. [key: string]: VertexBuffer;
  22491. }>;
  22492. /**
  22493. * Gets a boolean indicating if specific vertex buffer is present
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @returns true if data is present
  22496. */
  22497. isVerticesDataPresent(kind: string): boolean;
  22498. /**
  22499. * Gets a list of all attached data kinds (Position, normal, etc...)
  22500. * @returns a list of string containing all kinds
  22501. */
  22502. getVerticesDataKinds(): string[];
  22503. /**
  22504. * Update index buffer
  22505. * @param indices defines the indices to store in the index buffer
  22506. * @param offset defines the offset in the target buffer where to store the data
  22507. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22508. */
  22509. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22510. /**
  22511. * Creates a new index buffer
  22512. * @param indices defines the indices to store in the index buffer
  22513. * @param totalVertices defines the total number of vertices (could be null)
  22514. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22515. */
  22516. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22517. /**
  22518. * Return the total number of indices
  22519. * @returns the total number of indices
  22520. */
  22521. getTotalIndices(): number;
  22522. /**
  22523. * Gets the index buffer array
  22524. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22525. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22526. * @returns the index buffer array
  22527. */
  22528. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22529. /**
  22530. * Gets the index buffer
  22531. * @return the index buffer
  22532. */
  22533. getIndexBuffer(): Nullable<WebGLBuffer>;
  22534. /** @hidden */
  22535. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22536. /**
  22537. * Release the associated resources for a specific mesh
  22538. * @param mesh defines the source mesh
  22539. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22540. */
  22541. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22542. /**
  22543. * Apply current geometry to a given mesh
  22544. * @param mesh defines the mesh to apply geometry to
  22545. */
  22546. applyToMesh(mesh: Mesh): void;
  22547. private _updateExtend;
  22548. private _applyToMesh;
  22549. private notifyUpdate;
  22550. /**
  22551. * Load the geometry if it was flagged as delay loaded
  22552. * @param scene defines the hosting scene
  22553. * @param onLoaded defines a callback called when the geometry is loaded
  22554. */
  22555. load(scene: Scene, onLoaded?: () => void): void;
  22556. private _queueLoad;
  22557. /**
  22558. * Invert the geometry to move from a right handed system to a left handed one.
  22559. */
  22560. toLeftHanded(): void;
  22561. /** @hidden */
  22562. _resetPointsArrayCache(): void;
  22563. /** @hidden */
  22564. _generatePointsArray(): boolean;
  22565. /**
  22566. * Gets a value indicating if the geometry is disposed
  22567. * @returns true if the geometry was disposed
  22568. */
  22569. isDisposed(): boolean;
  22570. private _disposeVertexArrayObjects;
  22571. /**
  22572. * Free all associated resources
  22573. */
  22574. dispose(): void;
  22575. /**
  22576. * Clone the current geometry into a new geometry
  22577. * @param id defines the unique ID of the new geometry
  22578. * @returns a new geometry object
  22579. */
  22580. copy(id: string): Geometry;
  22581. /**
  22582. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22583. * @return a JSON representation of the current geometry data (without the vertices data)
  22584. */
  22585. serialize(): any;
  22586. private toNumberArray;
  22587. /**
  22588. * Serialize all vertices data into a JSON oject
  22589. * @returns a JSON representation of the current geometry data
  22590. */
  22591. serializeVerticeData(): any;
  22592. /**
  22593. * Extracts a clone of a mesh geometry
  22594. * @param mesh defines the source mesh
  22595. * @param id defines the unique ID of the new geometry object
  22596. * @returns the new geometry object
  22597. */
  22598. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22599. /**
  22600. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22601. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22602. * Be aware Math.random() could cause collisions, but:
  22603. * "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"
  22604. * @returns a string containing a new GUID
  22605. */
  22606. static RandomId(): string;
  22607. /** @hidden */
  22608. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22609. private static _CleanMatricesWeights;
  22610. /**
  22611. * Create a new geometry from persisted data (Using .babylon file format)
  22612. * @param parsedVertexData defines the persisted data
  22613. * @param scene defines the hosting scene
  22614. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22615. * @returns the new geometry object
  22616. */
  22617. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22618. }
  22619. }
  22620. declare module "babylonjs/Meshes/mesh.vertexData" {
  22621. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22622. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22623. import { Geometry } from "babylonjs/Meshes/geometry";
  22624. import { Mesh } from "babylonjs/Meshes/mesh";
  22625. /**
  22626. * Define an interface for all classes that will get and set the data on vertices
  22627. */
  22628. export interface IGetSetVerticesData {
  22629. /**
  22630. * Gets a boolean indicating if specific vertex data is present
  22631. * @param kind defines the vertex data kind to use
  22632. * @returns true is data kind is present
  22633. */
  22634. isVerticesDataPresent(kind: string): boolean;
  22635. /**
  22636. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22637. * @param kind defines the data kind (Position, normal, etc...)
  22638. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22639. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22640. * @returns a float array containing vertex data
  22641. */
  22642. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22643. /**
  22644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22645. * @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.
  22646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22647. * @returns the indices array or an empty array if the mesh has no geometry
  22648. */
  22649. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22650. /**
  22651. * Set specific vertex data
  22652. * @param kind defines the data kind (Position, normal, etc...)
  22653. * @param data defines the vertex data to use
  22654. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22655. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22656. */
  22657. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22658. /**
  22659. * Update a specific associated vertex buffer
  22660. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22661. * - VertexBuffer.PositionKind
  22662. * - VertexBuffer.UVKind
  22663. * - VertexBuffer.UV2Kind
  22664. * - VertexBuffer.UV3Kind
  22665. * - VertexBuffer.UV4Kind
  22666. * - VertexBuffer.UV5Kind
  22667. * - VertexBuffer.UV6Kind
  22668. * - VertexBuffer.ColorKind
  22669. * - VertexBuffer.MatricesIndicesKind
  22670. * - VertexBuffer.MatricesIndicesExtraKind
  22671. * - VertexBuffer.MatricesWeightsKind
  22672. * - VertexBuffer.MatricesWeightsExtraKind
  22673. * @param data defines the data source
  22674. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22675. * @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)
  22676. */
  22677. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22678. /**
  22679. * Creates a new index buffer
  22680. * @param indices defines the indices to store in the index buffer
  22681. * @param totalVertices defines the total number of vertices (could be null)
  22682. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22683. */
  22684. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22685. }
  22686. /**
  22687. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22688. */
  22689. export class VertexData {
  22690. /**
  22691. * Mesh side orientation : usually the external or front surface
  22692. */
  22693. static readonly FRONTSIDE: number;
  22694. /**
  22695. * Mesh side orientation : usually the internal or back surface
  22696. */
  22697. static readonly BACKSIDE: number;
  22698. /**
  22699. * Mesh side orientation : both internal and external or front and back surfaces
  22700. */
  22701. static readonly DOUBLESIDE: number;
  22702. /**
  22703. * Mesh side orientation : by default, `FRONTSIDE`
  22704. */
  22705. static readonly DEFAULTSIDE: number;
  22706. /**
  22707. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22708. */
  22709. positions: Nullable<FloatArray>;
  22710. /**
  22711. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22712. */
  22713. normals: Nullable<FloatArray>;
  22714. /**
  22715. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22716. */
  22717. tangents: Nullable<FloatArray>;
  22718. /**
  22719. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22720. */
  22721. uvs: Nullable<FloatArray>;
  22722. /**
  22723. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22724. */
  22725. uvs2: Nullable<FloatArray>;
  22726. /**
  22727. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22728. */
  22729. uvs3: Nullable<FloatArray>;
  22730. /**
  22731. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22732. */
  22733. uvs4: Nullable<FloatArray>;
  22734. /**
  22735. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22736. */
  22737. uvs5: Nullable<FloatArray>;
  22738. /**
  22739. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22740. */
  22741. uvs6: Nullable<FloatArray>;
  22742. /**
  22743. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22744. */
  22745. colors: Nullable<FloatArray>;
  22746. /**
  22747. * 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).
  22748. */
  22749. matricesIndices: Nullable<FloatArray>;
  22750. /**
  22751. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22752. */
  22753. matricesWeights: Nullable<FloatArray>;
  22754. /**
  22755. * An array extending the number of possible indices
  22756. */
  22757. matricesIndicesExtra: Nullable<FloatArray>;
  22758. /**
  22759. * An array extending the number of possible weights when the number of indices is extended
  22760. */
  22761. matricesWeightsExtra: Nullable<FloatArray>;
  22762. /**
  22763. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22764. */
  22765. indices: Nullable<IndicesArray>;
  22766. /**
  22767. * Uses the passed data array to set the set the values for the specified kind of data
  22768. * @param data a linear array of floating numbers
  22769. * @param kind the type of data that is being set, eg positions, colors etc
  22770. */
  22771. set(data: FloatArray, kind: string): void;
  22772. /**
  22773. * Associates the vertexData to the passed Mesh.
  22774. * Sets it as updatable or not (default `false`)
  22775. * @param mesh the mesh the vertexData is applied to
  22776. * @param updatable when used and having the value true allows new data to update the vertexData
  22777. * @returns the VertexData
  22778. */
  22779. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22780. /**
  22781. * Associates the vertexData to the passed Geometry.
  22782. * Sets it as updatable or not (default `false`)
  22783. * @param geometry the geometry the vertexData is applied to
  22784. * @param updatable when used and having the value true allows new data to update the vertexData
  22785. * @returns VertexData
  22786. */
  22787. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22788. /**
  22789. * Updates the associated mesh
  22790. * @param mesh the mesh to be updated
  22791. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22792. * @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
  22793. * @returns VertexData
  22794. */
  22795. updateMesh(mesh: Mesh): VertexData;
  22796. /**
  22797. * Updates the associated geometry
  22798. * @param geometry the geometry to be updated
  22799. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22800. * @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
  22801. * @returns VertexData.
  22802. */
  22803. updateGeometry(geometry: Geometry): VertexData;
  22804. private _applyTo;
  22805. private _update;
  22806. /**
  22807. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22808. * @param matrix the transforming matrix
  22809. * @returns the VertexData
  22810. */
  22811. transform(matrix: Matrix): VertexData;
  22812. /**
  22813. * Merges the passed VertexData into the current one
  22814. * @param other the VertexData to be merged into the current one
  22815. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22816. * @returns the modified VertexData
  22817. */
  22818. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22819. private _mergeElement;
  22820. private _validate;
  22821. /**
  22822. * Serializes the VertexData
  22823. * @returns a serialized object
  22824. */
  22825. serialize(): any;
  22826. /**
  22827. * Extracts the vertexData from a mesh
  22828. * @param mesh the mesh from which to extract the VertexData
  22829. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22830. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22831. * @returns the object VertexData associated to the passed mesh
  22832. */
  22833. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22834. /**
  22835. * Extracts the vertexData from the geometry
  22836. * @param geometry the geometry from which to extract the VertexData
  22837. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22838. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22839. * @returns the object VertexData associated to the passed mesh
  22840. */
  22841. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22842. private static _ExtractFrom;
  22843. /**
  22844. * Creates the VertexData for a Ribbon
  22845. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22846. * * pathArray array of paths, each of which an array of successive Vector3
  22847. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22848. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22849. * * 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
  22850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22851. * * 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)
  22852. * * 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)
  22853. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22854. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22855. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22856. * @returns the VertexData of the ribbon
  22857. */
  22858. static CreateRibbon(options: {
  22859. pathArray: Vector3[][];
  22860. closeArray?: boolean;
  22861. closePath?: boolean;
  22862. offset?: number;
  22863. sideOrientation?: number;
  22864. frontUVs?: Vector4;
  22865. backUVs?: Vector4;
  22866. invertUV?: boolean;
  22867. uvs?: Vector2[];
  22868. colors?: Color4[];
  22869. }): VertexData;
  22870. /**
  22871. * Creates the VertexData for a box
  22872. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22873. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22874. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22875. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22876. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22877. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22878. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22880. * * 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)
  22881. * * 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)
  22882. * @returns the VertexData of the box
  22883. */
  22884. static CreateBox(options: {
  22885. size?: number;
  22886. width?: number;
  22887. height?: number;
  22888. depth?: number;
  22889. faceUV?: Vector4[];
  22890. faceColors?: Color4[];
  22891. sideOrientation?: number;
  22892. frontUVs?: Vector4;
  22893. backUVs?: Vector4;
  22894. }): VertexData;
  22895. /**
  22896. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22898. * * segments sets the number of horizontal strips optional, default 32
  22899. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22900. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22901. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22902. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22903. * * 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
  22904. * * 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
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * 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)
  22907. * * 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)
  22908. * @returns the VertexData of the ellipsoid
  22909. */
  22910. static CreateSphere(options: {
  22911. segments?: number;
  22912. diameter?: number;
  22913. diameterX?: number;
  22914. diameterY?: number;
  22915. diameterZ?: number;
  22916. arc?: number;
  22917. slice?: number;
  22918. sideOrientation?: number;
  22919. frontUVs?: Vector4;
  22920. backUVs?: Vector4;
  22921. }): VertexData;
  22922. /**
  22923. * Creates the VertexData for a cylinder, cone or prism
  22924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22925. * * height sets the height (y direction) of the cylinder, optional, default 2
  22926. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22927. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22928. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22929. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22930. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22931. * * 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
  22932. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22933. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22934. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22935. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22936. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22937. * * 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)
  22938. * * 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)
  22939. * @returns the VertexData of the cylinder, cone or prism
  22940. */
  22941. static CreateCylinder(options: {
  22942. height?: number;
  22943. diameterTop?: number;
  22944. diameterBottom?: number;
  22945. diameter?: number;
  22946. tessellation?: number;
  22947. subdivisions?: number;
  22948. arc?: number;
  22949. faceColors?: Color4[];
  22950. faceUV?: Vector4[];
  22951. hasRings?: boolean;
  22952. enclose?: boolean;
  22953. sideOrientation?: number;
  22954. frontUVs?: Vector4;
  22955. backUVs?: Vector4;
  22956. }): VertexData;
  22957. /**
  22958. * Creates the VertexData for a torus
  22959. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22960. * * diameter the diameter of the torus, optional default 1
  22961. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22962. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22964. * * 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)
  22965. * * 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)
  22966. * @returns the VertexData of the torus
  22967. */
  22968. static CreateTorus(options: {
  22969. diameter?: number;
  22970. thickness?: number;
  22971. tessellation?: number;
  22972. sideOrientation?: number;
  22973. frontUVs?: Vector4;
  22974. backUVs?: Vector4;
  22975. }): VertexData;
  22976. /**
  22977. * Creates the VertexData of the LineSystem
  22978. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22979. * - lines an array of lines, each line being an array of successive Vector3
  22980. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22981. * @returns the VertexData of the LineSystem
  22982. */
  22983. static CreateLineSystem(options: {
  22984. lines: Vector3[][];
  22985. colors?: Nullable<Color4[][]>;
  22986. }): VertexData;
  22987. /**
  22988. * Create the VertexData for a DashedLines
  22989. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22990. * - points an array successive Vector3
  22991. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22992. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22993. * - dashNb the intended total number of dashes, optional, default 200
  22994. * @returns the VertexData for the DashedLines
  22995. */
  22996. static CreateDashedLines(options: {
  22997. points: Vector3[];
  22998. dashSize?: number;
  22999. gapSize?: number;
  23000. dashNb?: number;
  23001. }): VertexData;
  23002. /**
  23003. * Creates the VertexData for a Ground
  23004. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23005. * - width the width (x direction) of the ground, optional, default 1
  23006. * - height the height (z direction) of the ground, optional, default 1
  23007. * - subdivisions the number of subdivisions per side, optional, default 1
  23008. * @returns the VertexData of the Ground
  23009. */
  23010. static CreateGround(options: {
  23011. width?: number;
  23012. height?: number;
  23013. subdivisions?: number;
  23014. subdivisionsX?: number;
  23015. subdivisionsY?: number;
  23016. }): VertexData;
  23017. /**
  23018. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23019. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23020. * * xmin the ground minimum X coordinate, optional, default -1
  23021. * * zmin the ground minimum Z coordinate, optional, default -1
  23022. * * xmax the ground maximum X coordinate, optional, default 1
  23023. * * zmax the ground maximum Z coordinate, optional, default 1
  23024. * * 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}
  23025. * * 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}
  23026. * @returns the VertexData of the TiledGround
  23027. */
  23028. static CreateTiledGround(options: {
  23029. xmin: number;
  23030. zmin: number;
  23031. xmax: number;
  23032. zmax: number;
  23033. subdivisions?: {
  23034. w: number;
  23035. h: number;
  23036. };
  23037. precision?: {
  23038. w: number;
  23039. h: number;
  23040. };
  23041. }): VertexData;
  23042. /**
  23043. * Creates the VertexData of the Ground designed from a heightmap
  23044. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23045. * * width the width (x direction) of the ground
  23046. * * height the height (z direction) of the ground
  23047. * * subdivisions the number of subdivisions per side
  23048. * * minHeight the minimum altitude on the ground, optional, default 0
  23049. * * maxHeight the maximum altitude on the ground, optional default 1
  23050. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23051. * * buffer the array holding the image color data
  23052. * * bufferWidth the width of image
  23053. * * bufferHeight the height of image
  23054. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23055. * @returns the VertexData of the Ground designed from a heightmap
  23056. */
  23057. static CreateGroundFromHeightMap(options: {
  23058. width: number;
  23059. height: number;
  23060. subdivisions: number;
  23061. minHeight: number;
  23062. maxHeight: number;
  23063. colorFilter: Color3;
  23064. buffer: Uint8Array;
  23065. bufferWidth: number;
  23066. bufferHeight: number;
  23067. alphaFilter: number;
  23068. }): VertexData;
  23069. /**
  23070. * Creates the VertexData for a Plane
  23071. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23072. * * size sets the width and height of the plane to the value of size, optional default 1
  23073. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23074. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23076. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23077. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23078. * @returns the VertexData of the box
  23079. */
  23080. static CreatePlane(options: {
  23081. size?: number;
  23082. width?: number;
  23083. height?: number;
  23084. sideOrientation?: number;
  23085. frontUVs?: Vector4;
  23086. backUVs?: Vector4;
  23087. }): VertexData;
  23088. /**
  23089. * Creates the VertexData of the Disc or regular Polygon
  23090. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23091. * * radius the radius of the disc, optional default 0.5
  23092. * * tessellation the number of polygon sides, optional, default 64
  23093. * * 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
  23094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23095. * * 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)
  23096. * * 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)
  23097. * @returns the VertexData of the box
  23098. */
  23099. static CreateDisc(options: {
  23100. radius?: number;
  23101. tessellation?: number;
  23102. arc?: number;
  23103. sideOrientation?: number;
  23104. frontUVs?: Vector4;
  23105. backUVs?: Vector4;
  23106. }): VertexData;
  23107. /**
  23108. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23109. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23110. * @param polygon a mesh built from polygonTriangulation.build()
  23111. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23112. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23113. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23114. * @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)
  23115. * @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)
  23116. * @returns the VertexData of the Polygon
  23117. */
  23118. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23119. /**
  23120. * Creates the VertexData of the IcoSphere
  23121. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23122. * * radius the radius of the IcoSphere, optional default 1
  23123. * * radiusX allows stretching in the x direction, optional, default radius
  23124. * * radiusY allows stretching in the y direction, optional, default radius
  23125. * * radiusZ allows stretching in the z direction, optional, default radius
  23126. * * flat when true creates a flat shaded mesh, optional, default true
  23127. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23129. * * 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)
  23130. * * 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)
  23131. * @returns the VertexData of the IcoSphere
  23132. */
  23133. static CreateIcoSphere(options: {
  23134. radius?: number;
  23135. radiusX?: number;
  23136. radiusY?: number;
  23137. radiusZ?: number;
  23138. flat?: boolean;
  23139. subdivisions?: number;
  23140. sideOrientation?: number;
  23141. frontUVs?: Vector4;
  23142. backUVs?: Vector4;
  23143. }): VertexData;
  23144. /**
  23145. * Creates the VertexData for a Polyhedron
  23146. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23147. * * type provided types are:
  23148. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23149. * * 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)
  23150. * * size the size of the IcoSphere, optional default 1
  23151. * * sizeX allows stretching in the x direction, optional, default size
  23152. * * sizeY allows stretching in the y direction, optional, default size
  23153. * * sizeZ allows stretching in the z direction, optional, default size
  23154. * * 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
  23155. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23156. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23157. * * flat when true creates a flat shaded mesh, optional, default true
  23158. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23160. * * 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)
  23161. * * 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)
  23162. * @returns the VertexData of the Polyhedron
  23163. */
  23164. static CreatePolyhedron(options: {
  23165. type?: number;
  23166. size?: number;
  23167. sizeX?: number;
  23168. sizeY?: number;
  23169. sizeZ?: number;
  23170. custom?: any;
  23171. faceUV?: Vector4[];
  23172. faceColors?: Color4[];
  23173. flat?: boolean;
  23174. sideOrientation?: number;
  23175. frontUVs?: Vector4;
  23176. backUVs?: Vector4;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData for a TorusKnot
  23180. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23181. * * radius the radius of the torus knot, optional, default 2
  23182. * * tube the thickness of the tube, optional, default 0.5
  23183. * * radialSegments the number of sides on each tube segments, optional, default 32
  23184. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23185. * * p the number of windings around the z axis, optional, default 2
  23186. * * q the number of windings around the x axis, optional, default 3
  23187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23188. * * 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)
  23189. * * 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)
  23190. * @returns the VertexData of the Torus Knot
  23191. */
  23192. static CreateTorusKnot(options: {
  23193. radius?: number;
  23194. tube?: number;
  23195. radialSegments?: number;
  23196. tubularSegments?: number;
  23197. p?: number;
  23198. q?: number;
  23199. sideOrientation?: number;
  23200. frontUVs?: Vector4;
  23201. backUVs?: Vector4;
  23202. }): VertexData;
  23203. /**
  23204. * Compute normals for given positions and indices
  23205. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23206. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23207. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23208. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23209. * * facetNormals : optional array of facet normals (vector3)
  23210. * * facetPositions : optional array of facet positions (vector3)
  23211. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23212. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23213. * * bInfo : optional bounding info, required for facetPartitioning computation
  23214. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23215. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23216. * * useRightHandedSystem: optional boolean to for right handed system computation
  23217. * * depthSort : optional boolean to enable the facet depth sort computation
  23218. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23219. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23220. */
  23221. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23222. facetNormals?: any;
  23223. facetPositions?: any;
  23224. facetPartitioning?: any;
  23225. ratio?: number;
  23226. bInfo?: any;
  23227. bbSize?: Vector3;
  23228. subDiv?: any;
  23229. useRightHandedSystem?: boolean;
  23230. depthSort?: boolean;
  23231. distanceTo?: Vector3;
  23232. depthSortedFacets?: any;
  23233. }): void;
  23234. /** @hidden */
  23235. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23236. /**
  23237. * Applies VertexData created from the imported parameters to the geometry
  23238. * @param parsedVertexData the parsed data from an imported file
  23239. * @param geometry the geometry to apply the VertexData to
  23240. */
  23241. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23242. }
  23243. }
  23244. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23245. import { Nullable } from "babylonjs/types";
  23246. import { Scene } from "babylonjs/scene";
  23247. import { Vector4 } from "babylonjs/Maths/math";
  23248. import { Mesh } from "babylonjs/Meshes/mesh";
  23249. /**
  23250. * Class containing static functions to help procedurally build meshes
  23251. */
  23252. export class DiscBuilder {
  23253. /**
  23254. * Creates a plane polygonal mesh. By default, this is a disc
  23255. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23256. * * 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
  23257. * * 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
  23258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23259. * * If you create a double-sided mesh, you can choose what parts of 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
  23260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23261. * @param name defines the name of the mesh
  23262. * @param options defines the options used to create the mesh
  23263. * @param scene defines the hosting scene
  23264. * @returns the plane polygonal mesh
  23265. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23266. */
  23267. static CreateDisc(name: string, options: {
  23268. radius?: number;
  23269. tessellation?: number;
  23270. arc?: number;
  23271. updatable?: boolean;
  23272. sideOrientation?: number;
  23273. frontUVs?: Vector4;
  23274. backUVs?: Vector4;
  23275. }, scene?: Nullable<Scene>): Mesh;
  23276. }
  23277. }
  23278. declare module "babylonjs/Particles/solidParticleSystem" {
  23279. import { Vector3 } from "babylonjs/Maths/math";
  23280. import { Mesh } from "babylonjs/Meshes/mesh";
  23281. import { Scene, IDisposable } from "babylonjs/scene";
  23282. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23283. /**
  23284. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23285. *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.
  23286. * The SPS is also a particle system. It provides some methods to manage the particles.
  23287. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23288. *
  23289. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23290. */
  23291. export class SolidParticleSystem implements IDisposable {
  23292. /**
  23293. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23294. * Example : var p = SPS.particles[i];
  23295. */
  23296. particles: SolidParticle[];
  23297. /**
  23298. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23299. */
  23300. nbParticles: number;
  23301. /**
  23302. * If the particles must ever face the camera (default false). Useful for planar particles.
  23303. */
  23304. billboard: boolean;
  23305. /**
  23306. * Recompute normals when adding a shape
  23307. */
  23308. recomputeNormals: boolean;
  23309. /**
  23310. * This a counter ofr your own usage. It's not set by any SPS functions.
  23311. */
  23312. counter: number;
  23313. /**
  23314. * The SPS name. This name is also given to the underlying mesh.
  23315. */
  23316. name: string;
  23317. /**
  23318. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23319. */
  23320. mesh: Mesh;
  23321. /**
  23322. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23323. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23324. */
  23325. vars: any;
  23326. /**
  23327. * This array is populated when the SPS is set as 'pickable'.
  23328. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23329. * Each element of this array is an object `{idx: int, faceId: int}`.
  23330. * `idx` is the picked particle index in the `SPS.particles` array
  23331. * `faceId` is the picked face index counted within this particle.
  23332. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23333. */
  23334. pickedParticles: {
  23335. idx: number;
  23336. faceId: number;
  23337. }[];
  23338. /**
  23339. * This array is populated when `enableDepthSort` is set to true.
  23340. * Each element of this array is an instance of the class DepthSortedParticle.
  23341. */
  23342. depthSortedParticles: DepthSortedParticle[];
  23343. /**
  23344. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23345. * @hidden
  23346. */
  23347. _bSphereOnly: boolean;
  23348. /**
  23349. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23350. * @hidden
  23351. */
  23352. _bSphereRadiusFactor: number;
  23353. private _scene;
  23354. private _positions;
  23355. private _indices;
  23356. private _normals;
  23357. private _colors;
  23358. private _uvs;
  23359. private _indices32;
  23360. private _positions32;
  23361. private _normals32;
  23362. private _fixedNormal32;
  23363. private _colors32;
  23364. private _uvs32;
  23365. private _index;
  23366. private _updatable;
  23367. private _pickable;
  23368. private _isVisibilityBoxLocked;
  23369. private _alwaysVisible;
  23370. private _depthSort;
  23371. private _shapeCounter;
  23372. private _copy;
  23373. private _color;
  23374. private _computeParticleColor;
  23375. private _computeParticleTexture;
  23376. private _computeParticleRotation;
  23377. private _computeParticleVertex;
  23378. private _computeBoundingBox;
  23379. private _depthSortParticles;
  23380. private _camera;
  23381. private _mustUnrotateFixedNormals;
  23382. private _particlesIntersect;
  23383. private _needs32Bits;
  23384. /**
  23385. * Creates a SPS (Solid Particle System) object.
  23386. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23387. * @param scene (Scene) is the scene in which the SPS is added.
  23388. * @param options defines the options of the sps e.g.
  23389. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23390. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23391. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23392. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23393. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23394. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23395. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23396. */
  23397. constructor(name: string, scene: Scene, options?: {
  23398. updatable?: boolean;
  23399. isPickable?: boolean;
  23400. enableDepthSort?: boolean;
  23401. particleIntersection?: boolean;
  23402. boundingSphereOnly?: boolean;
  23403. bSphereRadiusFactor?: number;
  23404. });
  23405. /**
  23406. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23407. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23408. * @returns the created mesh
  23409. */
  23410. buildMesh(): Mesh;
  23411. /**
  23412. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23413. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23414. * Thus the particles generated from `digest()` have their property `position` set yet.
  23415. * @param mesh ( Mesh ) is the mesh to be digested
  23416. * @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
  23417. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23418. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23419. * @returns the current SPS
  23420. */
  23421. digest(mesh: Mesh, options?: {
  23422. facetNb?: number;
  23423. number?: number;
  23424. delta?: number;
  23425. }): SolidParticleSystem;
  23426. private _unrotateFixedNormals;
  23427. private _resetCopy;
  23428. private _meshBuilder;
  23429. private _posToShape;
  23430. private _uvsToShapeUV;
  23431. private _addParticle;
  23432. /**
  23433. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23434. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23435. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23436. * @param nb (positive integer) the number of particles to be created from this model
  23437. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23438. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23439. * @returns the number of shapes in the system
  23440. */
  23441. addShape(mesh: Mesh, nb: number, options?: {
  23442. positionFunction?: any;
  23443. vertexFunction?: any;
  23444. }): number;
  23445. private _rebuildParticle;
  23446. /**
  23447. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23448. * @returns the SPS.
  23449. */
  23450. rebuildMesh(): SolidParticleSystem;
  23451. /**
  23452. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23453. * This method calls `updateParticle()` for each particle of the SPS.
  23454. * For an animated SPS, it is usually called within the render loop.
  23455. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23456. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23457. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23458. * @returns the SPS.
  23459. */
  23460. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23461. /**
  23462. * Disposes the SPS.
  23463. */
  23464. dispose(): void;
  23465. /**
  23466. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23468. * @returns the SPS.
  23469. */
  23470. refreshVisibleSize(): SolidParticleSystem;
  23471. /**
  23472. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23473. * @param size the size (float) of the visibility box
  23474. * note : this doesn't lock the SPS mesh bounding box.
  23475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23476. */
  23477. setVisibilityBox(size: number): void;
  23478. /**
  23479. * Gets whether the SPS as always visible or not
  23480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23481. */
  23482. /**
  23483. * Sets the SPS as always visible or not
  23484. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23485. */
  23486. isAlwaysVisible: boolean;
  23487. /**
  23488. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23490. */
  23491. /**
  23492. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23493. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23494. */
  23495. isVisibilityBoxLocked: boolean;
  23496. /**
  23497. * Tells to `setParticles()` to compute the particle rotations or not.
  23498. * Default value : true. The SPS is faster when it's set to false.
  23499. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23500. */
  23501. /**
  23502. * Gets if `setParticles()` computes the particle rotations or not.
  23503. * Default value : true. The SPS is faster when it's set to false.
  23504. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23505. */
  23506. computeParticleRotation: boolean;
  23507. /**
  23508. * Tells to `setParticles()` to compute the particle colors or not.
  23509. * Default value : true. The SPS is faster when it's set to false.
  23510. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23511. */
  23512. /**
  23513. * Gets if `setParticles()` computes the particle colors or not.
  23514. * Default value : true. The SPS is faster when it's set to false.
  23515. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23516. */
  23517. computeParticleColor: boolean;
  23518. /**
  23519. * Gets if `setParticles()` computes the particle textures or not.
  23520. * Default value : true. The SPS is faster when it's set to false.
  23521. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23522. */
  23523. computeParticleTexture: boolean;
  23524. /**
  23525. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23526. * Default value : false. The SPS is faster when it's set to false.
  23527. * Note : the particle custom vertex positions aren't stored values.
  23528. */
  23529. /**
  23530. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23531. * Default value : false. The SPS is faster when it's set to false.
  23532. * Note : the particle custom vertex positions aren't stored values.
  23533. */
  23534. computeParticleVertex: boolean;
  23535. /**
  23536. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23537. */
  23538. /**
  23539. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23540. */
  23541. computeBoundingBox: boolean;
  23542. /**
  23543. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23544. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23545. * Default : `true`
  23546. */
  23547. /**
  23548. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23549. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23550. * Default : `true`
  23551. */
  23552. depthSortParticles: boolean;
  23553. /**
  23554. * This function does nothing. It may be overwritten to set all the particle first values.
  23555. * The SPS doesn't call this function, you may have to call it by your own.
  23556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23557. */
  23558. initParticles(): void;
  23559. /**
  23560. * This function does nothing. It may be overwritten to recycle a particle.
  23561. * The SPS doesn't call this function, you may have to call it by your own.
  23562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23563. * @param particle The particle to recycle
  23564. * @returns the recycled particle
  23565. */
  23566. recycleParticle(particle: SolidParticle): SolidParticle;
  23567. /**
  23568. * Updates a particle : this function should be overwritten by the user.
  23569. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23570. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23571. * @example : just set a particle position or velocity and recycle conditions
  23572. * @param particle The particle to update
  23573. * @returns the updated particle
  23574. */
  23575. updateParticle(particle: SolidParticle): SolidParticle;
  23576. /**
  23577. * Updates a vertex of a particle : it can be overwritten by the user.
  23578. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23579. * @param particle the current particle
  23580. * @param vertex the current index of the current particle
  23581. * @param pt the index of the current vertex in the particle shape
  23582. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23583. * @example : just set a vertex particle position
  23584. * @returns the updated vertex
  23585. */
  23586. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23587. /**
  23588. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23589. * This does nothing and may be overwritten by the user.
  23590. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23592. * @param update the boolean update value actually passed to setParticles()
  23593. */
  23594. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23595. /**
  23596. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23597. * This will be passed three parameters.
  23598. * This does nothing and may be overwritten by the user.
  23599. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23600. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23601. * @param update the boolean update value actually passed to setParticles()
  23602. */
  23603. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23604. }
  23605. }
  23606. declare module "babylonjs/Particles/solidParticle" {
  23607. import { Nullable } from "babylonjs/types";
  23608. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23609. import { Mesh } from "babylonjs/Meshes/mesh";
  23610. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23611. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23612. /**
  23613. * Represents one particle of a solid particle system.
  23614. */
  23615. export class SolidParticle {
  23616. /**
  23617. * particle global index
  23618. */
  23619. idx: number;
  23620. /**
  23621. * The color of the particle
  23622. */
  23623. color: Nullable<Color4>;
  23624. /**
  23625. * The world space position of the particle.
  23626. */
  23627. position: Vector3;
  23628. /**
  23629. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23630. */
  23631. rotation: Vector3;
  23632. /**
  23633. * The world space rotation quaternion of the particle.
  23634. */
  23635. rotationQuaternion: Nullable<Quaternion>;
  23636. /**
  23637. * The scaling of the particle.
  23638. */
  23639. scaling: Vector3;
  23640. /**
  23641. * The uvs of the particle.
  23642. */
  23643. uvs: Vector4;
  23644. /**
  23645. * The current speed of the particle.
  23646. */
  23647. velocity: Vector3;
  23648. /**
  23649. * The pivot point in the particle local space.
  23650. */
  23651. pivot: Vector3;
  23652. /**
  23653. * Must the particle be translated from its pivot point in its local space ?
  23654. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23655. * Default : false
  23656. */
  23657. translateFromPivot: boolean;
  23658. /**
  23659. * Is the particle active or not ?
  23660. */
  23661. alive: boolean;
  23662. /**
  23663. * Is the particle visible or not ?
  23664. */
  23665. isVisible: boolean;
  23666. /**
  23667. * Index of this particle in the global "positions" array (Internal use)
  23668. * @hidden
  23669. */
  23670. _pos: number;
  23671. /**
  23672. * @hidden Index of this particle in the global "indices" array (Internal use)
  23673. */
  23674. _ind: number;
  23675. /**
  23676. * @hidden ModelShape of this particle (Internal use)
  23677. */
  23678. _model: ModelShape;
  23679. /**
  23680. * ModelShape id of this particle
  23681. */
  23682. shapeId: number;
  23683. /**
  23684. * Index of the particle in its shape id (Internal use)
  23685. */
  23686. idxInShape: number;
  23687. /**
  23688. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23689. */
  23690. _modelBoundingInfo: BoundingInfo;
  23691. /**
  23692. * @hidden Particle BoundingInfo object (Internal use)
  23693. */
  23694. _boundingInfo: BoundingInfo;
  23695. /**
  23696. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23697. */
  23698. _sps: SolidParticleSystem;
  23699. /**
  23700. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23701. */
  23702. _stillInvisible: boolean;
  23703. /**
  23704. * @hidden Last computed particle rotation matrix
  23705. */
  23706. _rotationMatrix: number[];
  23707. /**
  23708. * Parent particle Id, if any.
  23709. * Default null.
  23710. */
  23711. parentId: Nullable<number>;
  23712. /**
  23713. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23714. * The possible values are :
  23715. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23716. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23717. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23718. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23719. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23720. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23721. * */
  23722. cullingStrategy: number;
  23723. /**
  23724. * @hidden Internal global position in the SPS.
  23725. */
  23726. _globalPosition: Vector3;
  23727. /**
  23728. * Creates a Solid Particle object.
  23729. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23730. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23731. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23732. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23733. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23734. * @param shapeId (integer) is the model shape identifier in the SPS.
  23735. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23736. * @param sps defines the sps it is associated to
  23737. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23738. */
  23739. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23740. /**
  23741. * Legacy support, changed scale to scaling
  23742. */
  23743. /**
  23744. * Legacy support, changed scale to scaling
  23745. */
  23746. scale: Vector3;
  23747. /**
  23748. * Legacy support, changed quaternion to rotationQuaternion
  23749. */
  23750. /**
  23751. * Legacy support, changed quaternion to rotationQuaternion
  23752. */
  23753. quaternion: Nullable<Quaternion>;
  23754. /**
  23755. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23756. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23757. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23758. * @returns true if it intersects
  23759. */
  23760. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23761. /**
  23762. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23763. * A particle is in the frustum if its bounding box intersects the frustum
  23764. * @param frustumPlanes defines the frustum to test
  23765. * @returns true if the particle is in the frustum planes
  23766. */
  23767. isInFrustum(frustumPlanes: Plane[]): boolean;
  23768. /**
  23769. * get the rotation matrix of the particle
  23770. * @hidden
  23771. */
  23772. getRotationMatrix(m: Matrix): void;
  23773. }
  23774. /**
  23775. * Represents the shape of the model used by one particle of a solid particle system.
  23776. * SPS internal tool, don't use it manually.
  23777. */
  23778. export class ModelShape {
  23779. /**
  23780. * The shape id
  23781. * @hidden
  23782. */
  23783. shapeID: number;
  23784. /**
  23785. * flat array of model positions (internal use)
  23786. * @hidden
  23787. */
  23788. _shape: Vector3[];
  23789. /**
  23790. * flat array of model UVs (internal use)
  23791. * @hidden
  23792. */
  23793. _shapeUV: number[];
  23794. /**
  23795. * length of the shape in the model indices array (internal use)
  23796. * @hidden
  23797. */
  23798. _indicesLength: number;
  23799. /**
  23800. * Custom position function (internal use)
  23801. * @hidden
  23802. */
  23803. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23804. /**
  23805. * Custom vertex function (internal use)
  23806. * @hidden
  23807. */
  23808. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23809. /**
  23810. * 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.
  23811. * SPS internal tool, don't use it manually.
  23812. * @hidden
  23813. */
  23814. 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>);
  23815. }
  23816. /**
  23817. * Represents a Depth Sorted Particle in the solid particle system.
  23818. */
  23819. export class DepthSortedParticle {
  23820. /**
  23821. * Index of the particle in the "indices" array
  23822. */
  23823. ind: number;
  23824. /**
  23825. * Length of the particle shape in the "indices" array
  23826. */
  23827. indicesLength: number;
  23828. /**
  23829. * Squared distance from the particle to the camera
  23830. */
  23831. sqDistance: number;
  23832. }
  23833. }
  23834. declare module "babylonjs/Meshes/abstractMesh" {
  23835. import { Observable } from "babylonjs/Misc/observable";
  23836. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23837. import { Camera } from "babylonjs/Cameras/camera";
  23838. import { Scene, IDisposable } from "babylonjs/scene";
  23839. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23840. import { Node } from "babylonjs/node";
  23841. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23842. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23843. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23845. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23846. import { Material } from "babylonjs/Materials/material";
  23847. import { Light } from "babylonjs/Lights/light";
  23848. import { Skeleton } from "babylonjs/Bones/skeleton";
  23849. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23850. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23852. import { Ray } from "babylonjs/Culling/ray";
  23853. import { Collider } from "babylonjs/Collisions/collider";
  23854. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23855. /**
  23856. * Class used to store all common mesh properties
  23857. */
  23858. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23859. /** No occlusion */
  23860. static OCCLUSION_TYPE_NONE: number;
  23861. /** Occlusion set to optimisitic */
  23862. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23863. /** Occlusion set to strict */
  23864. static OCCLUSION_TYPE_STRICT: number;
  23865. /** Use an accurante occlusion algorithm */
  23866. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23867. /** Use a conservative occlusion algorithm */
  23868. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23869. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23870. * Test order :
  23871. * Is the bounding sphere outside the frustum ?
  23872. * If not, are the bounding box vertices outside the frustum ?
  23873. * It not, then the cullable object is in the frustum.
  23874. */
  23875. static readonly CULLINGSTRATEGY_STANDARD: number;
  23876. /** Culling strategy : Bounding Sphere Only.
  23877. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23878. * It's also less accurate than the standard because some not visible objects can still be selected.
  23879. * Test : is the bounding sphere outside the frustum ?
  23880. * If not, then the cullable object is in the frustum.
  23881. */
  23882. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23883. /** Culling strategy : Optimistic Inclusion.
  23884. * This in an inclusion test first, then the standard exclusion test.
  23885. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23886. * 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.
  23887. * Anyway, it's as accurate as the standard strategy.
  23888. * Test :
  23889. * Is the cullable object bounding sphere center in the frustum ?
  23890. * If not, apply the default culling strategy.
  23891. */
  23892. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23893. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23894. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23895. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23896. * 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.
  23897. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23898. * Test :
  23899. * Is the cullable object bounding sphere center in the frustum ?
  23900. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23901. */
  23902. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23903. /**
  23904. * No billboard
  23905. */
  23906. static readonly BILLBOARDMODE_NONE: number;
  23907. /** Billboard on X axis */
  23908. static readonly BILLBOARDMODE_X: number;
  23909. /** Billboard on Y axis */
  23910. static readonly BILLBOARDMODE_Y: number;
  23911. /** Billboard on Z axis */
  23912. static readonly BILLBOARDMODE_Z: number;
  23913. /** Billboard on all axes */
  23914. static readonly BILLBOARDMODE_ALL: number;
  23915. private _facetData;
  23916. /**
  23917. * The culling strategy to use to check whether the mesh must be rendered or not.
  23918. * This value can be changed at any time and will be used on the next render mesh selection.
  23919. * The possible values are :
  23920. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23921. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23922. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23923. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23924. * Please read each static variable documentation to get details about the culling process.
  23925. * */
  23926. cullingStrategy: number;
  23927. /**
  23928. * Gets the number of facets in the mesh
  23929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23930. */
  23931. readonly facetNb: number;
  23932. /**
  23933. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23935. */
  23936. partitioningSubdivisions: number;
  23937. /**
  23938. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23939. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23941. */
  23942. partitioningBBoxRatio: number;
  23943. /**
  23944. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23945. * Works only for updatable meshes.
  23946. * Doesn't work with multi-materials
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23948. */
  23949. mustDepthSortFacets: boolean;
  23950. /**
  23951. * The location (Vector3) where the facet depth sort must be computed from.
  23952. * By default, the active camera position.
  23953. * Used only when facet depth sort is enabled
  23954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23955. */
  23956. facetDepthSortFrom: Vector3;
  23957. /**
  23958. * gets a boolean indicating if facetData is enabled
  23959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23960. */
  23961. readonly isFacetDataEnabled: boolean;
  23962. /** @hidden */
  23963. _updateNonUniformScalingState(value: boolean): boolean;
  23964. /**
  23965. * An event triggered when this mesh collides with another one
  23966. */
  23967. onCollideObservable: Observable<AbstractMesh>;
  23968. private _onCollideObserver;
  23969. /** Set a function to call when this mesh collides with another one */
  23970. onCollide: () => void;
  23971. /**
  23972. * An event triggered when the collision's position changes
  23973. */
  23974. onCollisionPositionChangeObservable: Observable<Vector3>;
  23975. private _onCollisionPositionChangeObserver;
  23976. /** Set a function to call when the collision's position changes */
  23977. onCollisionPositionChange: () => void;
  23978. /**
  23979. * An event triggered when material is changed
  23980. */
  23981. onMaterialChangedObservable: Observable<AbstractMesh>;
  23982. /**
  23983. * Gets or sets the orientation for POV movement & rotation
  23984. */
  23985. definedFacingForward: boolean;
  23986. /** @hidden */
  23987. _occlusionQuery: Nullable<WebGLQuery>;
  23988. private _visibility;
  23989. /**
  23990. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23991. */
  23992. /**
  23993. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23994. */
  23995. visibility: number;
  23996. /** Gets or sets the alpha index used to sort transparent meshes
  23997. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23998. */
  23999. alphaIndex: number;
  24000. /**
  24001. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24002. */
  24003. isVisible: boolean;
  24004. /**
  24005. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24006. */
  24007. isPickable: boolean;
  24008. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24009. showSubMeshesBoundingBox: boolean;
  24010. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24012. */
  24013. isBlocker: boolean;
  24014. /**
  24015. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24016. */
  24017. enablePointerMoveEvents: boolean;
  24018. /**
  24019. * Specifies the rendering group id for this mesh (0 by default)
  24020. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24021. */
  24022. renderingGroupId: number;
  24023. private _material;
  24024. /** Gets or sets current material */
  24025. material: Nullable<Material>;
  24026. private _receiveShadows;
  24027. /**
  24028. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24029. * @see http://doc.babylonjs.com/babylon101/shadows
  24030. */
  24031. receiveShadows: boolean;
  24032. /** Defines color to use when rendering outline */
  24033. outlineColor: Color3;
  24034. /** Define width to use when rendering outline */
  24035. outlineWidth: number;
  24036. /** Defines color to use when rendering overlay */
  24037. overlayColor: Color3;
  24038. /** Defines alpha to use when rendering overlay */
  24039. overlayAlpha: number;
  24040. private _hasVertexAlpha;
  24041. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24042. hasVertexAlpha: boolean;
  24043. private _useVertexColors;
  24044. /** 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) */
  24045. useVertexColors: boolean;
  24046. private _computeBonesUsingShaders;
  24047. /**
  24048. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24049. */
  24050. computeBonesUsingShaders: boolean;
  24051. private _numBoneInfluencers;
  24052. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24053. numBoneInfluencers: number;
  24054. private _applyFog;
  24055. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24056. applyFog: boolean;
  24057. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24058. useOctreeForRenderingSelection: boolean;
  24059. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24060. useOctreeForPicking: boolean;
  24061. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24062. useOctreeForCollisions: boolean;
  24063. private _layerMask;
  24064. /**
  24065. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24066. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24067. */
  24068. layerMask: number;
  24069. /**
  24070. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24071. */
  24072. alwaysSelectAsActiveMesh: boolean;
  24073. /**
  24074. * Gets or sets the current action manager
  24075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24076. */
  24077. actionManager: Nullable<AbstractActionManager>;
  24078. private _checkCollisions;
  24079. private _collisionMask;
  24080. private _collisionGroup;
  24081. /**
  24082. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24084. */
  24085. ellipsoid: Vector3;
  24086. /**
  24087. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24089. */
  24090. ellipsoidOffset: Vector3;
  24091. private _collider;
  24092. private _oldPositionForCollisions;
  24093. private _diffPositionForCollisions;
  24094. /**
  24095. * Gets or sets a collision mask used to mask collisions (default is -1).
  24096. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24097. */
  24098. collisionMask: number;
  24099. /**
  24100. * Gets or sets the current collision group mask (-1 by default).
  24101. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24102. */
  24103. collisionGroup: number;
  24104. /**
  24105. * Defines edge width used when edgesRenderer is enabled
  24106. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24107. */
  24108. edgesWidth: number;
  24109. /**
  24110. * Defines edge color used when edgesRenderer is enabled
  24111. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24112. */
  24113. edgesColor: Color4;
  24114. /** @hidden */
  24115. _edgesRenderer: Nullable<IEdgesRenderer>;
  24116. /** @hidden */
  24117. _masterMesh: Nullable<AbstractMesh>;
  24118. /** @hidden */
  24119. _boundingInfo: Nullable<BoundingInfo>;
  24120. /** @hidden */
  24121. _renderId: number;
  24122. /**
  24123. * Gets or sets the list of subMeshes
  24124. * @see http://doc.babylonjs.com/how_to/multi_materials
  24125. */
  24126. subMeshes: SubMesh[];
  24127. /** @hidden */
  24128. _intersectionsInProgress: AbstractMesh[];
  24129. /** @hidden */
  24130. _unIndexed: boolean;
  24131. /** @hidden */
  24132. _lightSources: Light[];
  24133. /** @hidden */
  24134. readonly _positions: Nullable<Vector3[]>;
  24135. /** @hidden */
  24136. _waitingActions: any;
  24137. /** @hidden */
  24138. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24139. private _skeleton;
  24140. /** @hidden */
  24141. _bonesTransformMatrices: Nullable<Float32Array>;
  24142. /**
  24143. * Gets or sets a skeleton to apply skining transformations
  24144. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24145. */
  24146. skeleton: Nullable<Skeleton>;
  24147. /**
  24148. * An event triggered when the mesh is rebuilt.
  24149. */
  24150. onRebuildObservable: Observable<AbstractMesh>;
  24151. /**
  24152. * Creates a new AbstractMesh
  24153. * @param name defines the name of the mesh
  24154. * @param scene defines the hosting scene
  24155. */
  24156. constructor(name: string, scene?: Nullable<Scene>);
  24157. /**
  24158. * Returns the string "AbstractMesh"
  24159. * @returns "AbstractMesh"
  24160. */
  24161. getClassName(): string;
  24162. /**
  24163. * Gets a string representation of the current mesh
  24164. * @param fullDetails defines a boolean indicating if full details must be included
  24165. * @returns a string representation of the current mesh
  24166. */
  24167. toString(fullDetails?: boolean): string;
  24168. /** @hidden */
  24169. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24170. /** @hidden */
  24171. _rebuild(): void;
  24172. /** @hidden */
  24173. _resyncLightSources(): void;
  24174. /** @hidden */
  24175. _resyncLighSource(light: Light): void;
  24176. /** @hidden */
  24177. _unBindEffect(): void;
  24178. /** @hidden */
  24179. _removeLightSource(light: Light): void;
  24180. private _markSubMeshesAsDirty;
  24181. /** @hidden */
  24182. _markSubMeshesAsLightDirty(): void;
  24183. /** @hidden */
  24184. _markSubMeshesAsAttributesDirty(): void;
  24185. /** @hidden */
  24186. _markSubMeshesAsMiscDirty(): void;
  24187. /**
  24188. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24189. */
  24190. scaling: Vector3;
  24191. /**
  24192. * Returns true if the mesh is blocked. Implemented by child classes
  24193. */
  24194. readonly isBlocked: boolean;
  24195. /**
  24196. * Returns the mesh itself by default. Implemented by child classes
  24197. * @param camera defines the camera to use to pick the right LOD level
  24198. * @returns the currentAbstractMesh
  24199. */
  24200. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24201. /**
  24202. * Returns 0 by default. Implemented by child classes
  24203. * @returns an integer
  24204. */
  24205. getTotalVertices(): number;
  24206. /**
  24207. * Returns a positive integer : the total number of indices in this mesh geometry.
  24208. * @returns the numner of indices or zero if the mesh has no geometry.
  24209. */
  24210. getTotalIndices(): number;
  24211. /**
  24212. * Returns null by default. Implemented by child classes
  24213. * @returns null
  24214. */
  24215. getIndices(): Nullable<IndicesArray>;
  24216. /**
  24217. * Returns the array of the requested vertex data kind. Implemented by child classes
  24218. * @param kind defines the vertex data kind to use
  24219. * @returns null
  24220. */
  24221. getVerticesData(kind: string): Nullable<FloatArray>;
  24222. /**
  24223. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24224. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24225. * Note that a new underlying VertexBuffer object is created each call.
  24226. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24227. * @param kind defines vertex data kind:
  24228. * * VertexBuffer.PositionKind
  24229. * * VertexBuffer.UVKind
  24230. * * VertexBuffer.UV2Kind
  24231. * * VertexBuffer.UV3Kind
  24232. * * VertexBuffer.UV4Kind
  24233. * * VertexBuffer.UV5Kind
  24234. * * VertexBuffer.UV6Kind
  24235. * * VertexBuffer.ColorKind
  24236. * * VertexBuffer.MatricesIndicesKind
  24237. * * VertexBuffer.MatricesIndicesExtraKind
  24238. * * VertexBuffer.MatricesWeightsKind
  24239. * * VertexBuffer.MatricesWeightsExtraKind
  24240. * @param data defines the data source
  24241. * @param updatable defines if the data must be flagged as updatable (or static)
  24242. * @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
  24243. * @returns the current mesh
  24244. */
  24245. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24246. /**
  24247. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24248. * If the mesh has no geometry, it is simply returned as it is.
  24249. * @param kind defines vertex data kind:
  24250. * * VertexBuffer.PositionKind
  24251. * * VertexBuffer.UVKind
  24252. * * VertexBuffer.UV2Kind
  24253. * * VertexBuffer.UV3Kind
  24254. * * VertexBuffer.UV4Kind
  24255. * * VertexBuffer.UV5Kind
  24256. * * VertexBuffer.UV6Kind
  24257. * * VertexBuffer.ColorKind
  24258. * * VertexBuffer.MatricesIndicesKind
  24259. * * VertexBuffer.MatricesIndicesExtraKind
  24260. * * VertexBuffer.MatricesWeightsKind
  24261. * * VertexBuffer.MatricesWeightsExtraKind
  24262. * @param data defines the data source
  24263. * @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
  24264. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24265. * @returns the current mesh
  24266. */
  24267. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24268. /**
  24269. * Sets the mesh indices,
  24270. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24271. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24272. * @param totalVertices Defines the total number of vertices
  24273. * @returns the current mesh
  24274. */
  24275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24276. /**
  24277. * Gets a boolean indicating if specific vertex data is present
  24278. * @param kind defines the vertex data kind to use
  24279. * @returns true is data kind is present
  24280. */
  24281. isVerticesDataPresent(kind: string): boolean;
  24282. /**
  24283. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24284. * @returns a BoundingInfo
  24285. */
  24286. getBoundingInfo(): BoundingInfo;
  24287. /**
  24288. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24289. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24290. * @returns the current mesh
  24291. */
  24292. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24293. /**
  24294. * Overwrite the current bounding info
  24295. * @param boundingInfo defines the new bounding info
  24296. * @returns the current mesh
  24297. */
  24298. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24299. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24300. readonly useBones: boolean;
  24301. /** @hidden */
  24302. _preActivate(): void;
  24303. /** @hidden */
  24304. _preActivateForIntermediateRendering(renderId: number): void;
  24305. /** @hidden */
  24306. _activate(renderId: number): void;
  24307. /**
  24308. * Gets the current world matrix
  24309. * @returns a Matrix
  24310. */
  24311. getWorldMatrix(): Matrix;
  24312. /** @hidden */
  24313. _getWorldMatrixDeterminant(): number;
  24314. /**
  24315. * Perform relative position change from the point of view of behind the front of the mesh.
  24316. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24317. * Supports definition of mesh facing forward or backward
  24318. * @param amountRight defines the distance on the right axis
  24319. * @param amountUp defines the distance on the up axis
  24320. * @param amountForward defines the distance on the forward axis
  24321. * @returns the current mesh
  24322. */
  24323. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24324. /**
  24325. * Calculate relative position change from the point of view of behind the front of the mesh.
  24326. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24327. * Supports definition of mesh facing forward or backward
  24328. * @param amountRight defines the distance on the right axis
  24329. * @param amountUp defines the distance on the up axis
  24330. * @param amountForward defines the distance on the forward axis
  24331. * @returns the new displacement vector
  24332. */
  24333. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24334. /**
  24335. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24336. * Supports definition of mesh facing forward or backward
  24337. * @param flipBack defines the flip
  24338. * @param twirlClockwise defines the twirl
  24339. * @param tiltRight defines the tilt
  24340. * @returns the current mesh
  24341. */
  24342. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24343. /**
  24344. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24345. * Supports definition of mesh facing forward or backward.
  24346. * @param flipBack defines the flip
  24347. * @param twirlClockwise defines the twirl
  24348. * @param tiltRight defines the tilt
  24349. * @returns the new rotation vector
  24350. */
  24351. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24352. /**
  24353. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24354. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24355. * @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
  24356. * @returns the new bounding vectors
  24357. */
  24358. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24359. min: Vector3;
  24360. max: Vector3;
  24361. };
  24362. /**
  24363. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24364. * This means the mesh underlying bounding box and sphere are recomputed.
  24365. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24366. * @returns the current mesh
  24367. */
  24368. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24369. /** @hidden */
  24370. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24371. /** @hidden */
  24372. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24373. /** @hidden */
  24374. _updateBoundingInfo(): AbstractMesh;
  24375. /** @hidden */
  24376. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24377. /** @hidden */
  24378. protected _afterComputeWorldMatrix(): void;
  24379. /**
  24380. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24381. * A mesh is in the frustum if its bounding box intersects the frustum
  24382. * @param frustumPlanes defines the frustum to test
  24383. * @returns true if the mesh is in the frustum planes
  24384. */
  24385. isInFrustum(frustumPlanes: Plane[]): boolean;
  24386. /**
  24387. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24388. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24389. * @param frustumPlanes defines the frustum to test
  24390. * @returns true if the mesh is completely in the frustum planes
  24391. */
  24392. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24393. /**
  24394. * True if the mesh intersects another mesh or a SolidParticle object
  24395. * @param mesh defines a target mesh or SolidParticle to test
  24396. * @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)
  24397. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24398. * @returns true if there is an intersection
  24399. */
  24400. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24401. /**
  24402. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24403. * @param point defines the point to test
  24404. * @returns true if there is an intersection
  24405. */
  24406. intersectsPoint(point: Vector3): boolean;
  24407. /**
  24408. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24410. */
  24411. checkCollisions: boolean;
  24412. /**
  24413. * Gets Collider object used to compute collisions (not physics)
  24414. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24415. */
  24416. readonly collider: Collider;
  24417. /**
  24418. * Move the mesh using collision engine
  24419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24420. * @param displacement defines the requested displacement vector
  24421. * @returns the current mesh
  24422. */
  24423. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24424. private _onCollisionPositionChange;
  24425. /** @hidden */
  24426. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24427. /** @hidden */
  24428. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24429. /** @hidden */
  24430. _checkCollision(collider: Collider): AbstractMesh;
  24431. /** @hidden */
  24432. _generatePointsArray(): boolean;
  24433. /**
  24434. * Checks if the passed Ray intersects with the mesh
  24435. * @param ray defines the ray to use
  24436. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24438. * @returns the picking info
  24439. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24440. */
  24441. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24442. /**
  24443. * Clones the current mesh
  24444. * @param name defines the mesh name
  24445. * @param newParent defines the new mesh parent
  24446. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24447. * @returns the new mesh
  24448. */
  24449. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24450. /**
  24451. * Disposes all the submeshes of the current meshnp
  24452. * @returns the current mesh
  24453. */
  24454. releaseSubMeshes(): AbstractMesh;
  24455. /**
  24456. * Releases resources associated with this abstract mesh.
  24457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24459. */
  24460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24461. /**
  24462. * Adds the passed mesh as a child to the current mesh
  24463. * @param mesh defines the child mesh
  24464. * @returns the current mesh
  24465. */
  24466. addChild(mesh: AbstractMesh): AbstractMesh;
  24467. /**
  24468. * Removes the passed mesh from the current mesh children list
  24469. * @param mesh defines the child mesh
  24470. * @returns the current mesh
  24471. */
  24472. removeChild(mesh: AbstractMesh): AbstractMesh;
  24473. /** @hidden */
  24474. private _initFacetData;
  24475. /**
  24476. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24477. * This method can be called within the render loop.
  24478. * 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
  24479. * @returns the current mesh
  24480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24481. */
  24482. updateFacetData(): AbstractMesh;
  24483. /**
  24484. * Returns the facetLocalNormals array.
  24485. * The normals are expressed in the mesh local spac
  24486. * @returns an array of Vector3
  24487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24488. */
  24489. getFacetLocalNormals(): Vector3[];
  24490. /**
  24491. * Returns the facetLocalPositions array.
  24492. * The facet positions are expressed in the mesh local space
  24493. * @returns an array of Vector3
  24494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24495. */
  24496. getFacetLocalPositions(): Vector3[];
  24497. /**
  24498. * Returns the facetLocalPartioning array
  24499. * @returns an array of array of numbers
  24500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24501. */
  24502. getFacetLocalPartitioning(): number[][];
  24503. /**
  24504. * Returns the i-th facet position in the world system.
  24505. * This method allocates a new Vector3 per call
  24506. * @param i defines the facet index
  24507. * @returns a new Vector3
  24508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24509. */
  24510. getFacetPosition(i: number): Vector3;
  24511. /**
  24512. * Sets the reference Vector3 with the i-th facet position in the world system
  24513. * @param i defines the facet index
  24514. * @param ref defines the target vector
  24515. * @returns the current mesh
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24517. */
  24518. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24519. /**
  24520. * Returns the i-th facet normal in the world system.
  24521. * This method allocates a new Vector3 per call
  24522. * @param i defines the facet index
  24523. * @returns a new Vector3
  24524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24525. */
  24526. getFacetNormal(i: number): Vector3;
  24527. /**
  24528. * Sets the reference Vector3 with the i-th facet normal in the world system
  24529. * @param i defines the facet index
  24530. * @param ref defines the target vector
  24531. * @returns the current mesh
  24532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24533. */
  24534. getFacetNormalToRef(i: number, ref: Vector3): this;
  24535. /**
  24536. * 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)
  24537. * @param x defines x coordinate
  24538. * @param y defines y coordinate
  24539. * @param z defines z coordinate
  24540. * @returns the array of facet indexes
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24542. */
  24543. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24544. /**
  24545. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24546. * @param projected sets as the (x,y,z) world projection on the facet
  24547. * @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
  24548. * @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
  24549. * @param x defines x coordinate
  24550. * @param y defines y coordinate
  24551. * @param z defines z coordinate
  24552. * @returns the face index if found (or null instead)
  24553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24554. */
  24555. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24556. /**
  24557. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24558. * @param projected sets as the (x,y,z) local projection on the facet
  24559. * @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
  24560. * @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
  24561. * @param x defines x coordinate
  24562. * @param y defines y coordinate
  24563. * @param z defines z coordinate
  24564. * @returns the face index if found (or null instead)
  24565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24566. */
  24567. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24568. /**
  24569. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24570. * @returns the parameters
  24571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24572. */
  24573. getFacetDataParameters(): any;
  24574. /**
  24575. * Disables the feature FacetData and frees the related memory
  24576. * @returns the current mesh
  24577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24578. */
  24579. disableFacetData(): AbstractMesh;
  24580. /**
  24581. * Updates the AbstractMesh indices array
  24582. * @param indices defines the data source
  24583. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24584. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24585. * @returns the current mesh
  24586. */
  24587. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24588. /**
  24589. * Creates new normals data for the mesh
  24590. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24591. * @returns the current mesh
  24592. */
  24593. createNormals(updatable: boolean): AbstractMesh;
  24594. /**
  24595. * Align the mesh with a normal
  24596. * @param normal defines the normal to use
  24597. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24598. * @returns the current mesh
  24599. */
  24600. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24601. /** @hidden */
  24602. _checkOcclusionQuery(): boolean;
  24603. }
  24604. }
  24605. declare module "babylonjs/Actions/actionEvent" {
  24606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24607. import { Nullable } from "babylonjs/types";
  24608. import { Sprite } from "babylonjs/Sprites/sprite";
  24609. import { Scene } from "babylonjs/scene";
  24610. import { Vector2 } from "babylonjs/Maths/math";
  24611. /**
  24612. * Interface used to define ActionEvent
  24613. */
  24614. export interface 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. /**
  24629. * ActionEvent is the event being sent when an action is triggered.
  24630. */
  24631. export class ActionEvent implements IActionEvent {
  24632. /** The mesh or sprite that triggered the action */
  24633. source: any;
  24634. /** The X mouse cursor position at the time of the event */
  24635. pointerX: number;
  24636. /** The Y mouse cursor position at the time of the event */
  24637. pointerY: number;
  24638. /** The mesh that is currently pointed at (can be null) */
  24639. meshUnderPointer: Nullable<AbstractMesh>;
  24640. /** the original (browser) event that triggered the ActionEvent */
  24641. sourceEvent?: any;
  24642. /** additional data for the event */
  24643. additionalData?: any;
  24644. /**
  24645. * Creates a new ActionEvent
  24646. * @param source The mesh or sprite that triggered the action
  24647. * @param pointerX The X mouse cursor position at the time of the event
  24648. * @param pointerY The Y mouse cursor position at the time of the event
  24649. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24650. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24651. * @param additionalData additional data for the event
  24652. */
  24653. constructor(
  24654. /** The mesh or sprite that triggered the action */
  24655. source: any,
  24656. /** The X mouse cursor position at the time of the event */
  24657. pointerX: number,
  24658. /** The Y mouse cursor position at the time of the event */
  24659. pointerY: number,
  24660. /** The mesh that is currently pointed at (can be null) */
  24661. meshUnderPointer: Nullable<AbstractMesh>,
  24662. /** the original (browser) event that triggered the ActionEvent */
  24663. sourceEvent?: any,
  24664. /** additional data for the event */
  24665. additionalData?: any);
  24666. /**
  24667. * Helper function to auto-create an ActionEvent from a source mesh.
  24668. * @param source The source mesh that triggered the event
  24669. * @param evt The original (browser) event
  24670. * @param additionalData additional data for the event
  24671. * @returns the new ActionEvent
  24672. */
  24673. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24674. /**
  24675. * Helper function to auto-create an ActionEvent from a source sprite
  24676. * @param source The source sprite that triggered the event
  24677. * @param scene Scene associated with the sprite
  24678. * @param evt The original (browser) event
  24679. * @param additionalData additional data for the event
  24680. * @returns the new ActionEvent
  24681. */
  24682. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24683. /**
  24684. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24685. * @param scene the scene where the event occurred
  24686. * @param evt The original (browser) event
  24687. * @returns the new ActionEvent
  24688. */
  24689. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24690. /**
  24691. * Helper function to auto-create an ActionEvent from a primitive
  24692. * @param prim defines the target primitive
  24693. * @param pointerPos defines the pointer position
  24694. * @param evt The original (browser) event
  24695. * @param additionalData additional data for the event
  24696. * @returns the new ActionEvent
  24697. */
  24698. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24699. }
  24700. }
  24701. declare module "babylonjs/Actions/abstractActionManager" {
  24702. import { IDisposable } from "babylonjs/scene";
  24703. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24704. import { IAction } from "babylonjs/Actions/action";
  24705. import { Nullable } from "babylonjs/types";
  24706. /**
  24707. * Abstract class used to decouple action Manager from scene and meshes.
  24708. * Do not instantiate.
  24709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24710. */
  24711. export abstract class AbstractActionManager implements IDisposable {
  24712. /** Gets the list of active triggers */
  24713. static Triggers: {
  24714. [key: string]: number;
  24715. };
  24716. /** Gets the cursor to use when hovering items */
  24717. hoverCursor: string;
  24718. /** Gets the list of actions */
  24719. actions: IAction[];
  24720. /**
  24721. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24722. */
  24723. isRecursive: boolean;
  24724. /**
  24725. * Releases all associated resources
  24726. */
  24727. abstract dispose(): void;
  24728. /**
  24729. * Does this action manager has pointer triggers
  24730. */
  24731. abstract readonly hasPointerTriggers: boolean;
  24732. /**
  24733. * Does this action manager has pick triggers
  24734. */
  24735. abstract readonly hasPickTriggers: boolean;
  24736. /**
  24737. * Process a specific trigger
  24738. * @param trigger defines the trigger to process
  24739. * @param evt defines the event details to be processed
  24740. */
  24741. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24742. /**
  24743. * Does this action manager handles actions of any of the given triggers
  24744. * @param triggers defines the triggers to be tested
  24745. * @return a boolean indicating whether one (or more) of the triggers is handled
  24746. */
  24747. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24748. /**
  24749. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24750. * speed.
  24751. * @param triggerA defines the trigger to be tested
  24752. * @param triggerB defines the trigger to be tested
  24753. * @return a boolean indicating whether one (or more) of the triggers is handled
  24754. */
  24755. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24756. /**
  24757. * Does this action manager handles actions of a given trigger
  24758. * @param trigger defines the trigger to be tested
  24759. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24760. * @return whether the trigger is handled
  24761. */
  24762. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24763. /**
  24764. * Serialize this manager to a JSON object
  24765. * @param name defines the property name to store this manager
  24766. * @returns a JSON representation of this manager
  24767. */
  24768. abstract serialize(name: string): any;
  24769. /**
  24770. * Registers an action to this action manager
  24771. * @param action defines the action to be registered
  24772. * @return the action amended (prepared) after registration
  24773. */
  24774. abstract registerAction(action: IAction): Nullable<IAction>;
  24775. /**
  24776. * Unregisters an action to this action manager
  24777. * @param action defines the action to be unregistered
  24778. * @return a boolean indicating whether the action has been unregistered
  24779. */
  24780. abstract unregisterAction(action: IAction): Boolean;
  24781. /**
  24782. * Does exist one action manager with at least one trigger
  24783. **/
  24784. static readonly HasTriggers: boolean;
  24785. /**
  24786. * Does exist one action manager with at least one pick trigger
  24787. **/
  24788. static readonly HasPickTriggers: boolean;
  24789. /**
  24790. * Does exist one action manager that handles actions of a given trigger
  24791. * @param trigger defines the trigger to be tested
  24792. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24793. **/
  24794. static HasSpecificTrigger(trigger: number): boolean;
  24795. }
  24796. }
  24797. declare module "babylonjs/node" {
  24798. import { Scene } from "babylonjs/scene";
  24799. import { Nullable } from "babylonjs/types";
  24800. import { Matrix } from "babylonjs/Maths/math";
  24801. import { Engine } from "babylonjs/Engines/engine";
  24802. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24803. import { Observable } from "babylonjs/Misc/observable";
  24804. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24805. import { Animatable } from "babylonjs/Animations/animatable";
  24806. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24807. import { Animation } from "babylonjs/Animations/animation";
  24808. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24810. /**
  24811. * Defines how a node can be built from a string name.
  24812. */
  24813. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24814. /**
  24815. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24816. */
  24817. export class Node implements IBehaviorAware<Node> {
  24818. /** @hidden */
  24819. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24820. private static _NodeConstructors;
  24821. /**
  24822. * Add a new node constructor
  24823. * @param type defines the type name of the node to construct
  24824. * @param constructorFunc defines the constructor function
  24825. */
  24826. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24827. /**
  24828. * Returns a node constructor based on type name
  24829. * @param type defines the type name
  24830. * @param name defines the new node name
  24831. * @param scene defines the hosting scene
  24832. * @param options defines optional options to transmit to constructors
  24833. * @returns the new constructor or null
  24834. */
  24835. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24836. /**
  24837. * Gets or sets the name of the node
  24838. */
  24839. name: string;
  24840. /**
  24841. * Gets or sets the id of the node
  24842. */
  24843. id: string;
  24844. /**
  24845. * Gets or sets the unique id of the node
  24846. */
  24847. uniqueId: number;
  24848. /**
  24849. * Gets or sets a string used to store user defined state for the node
  24850. */
  24851. state: string;
  24852. /**
  24853. * Gets or sets an object used to store user defined information for the node
  24854. */
  24855. metadata: any;
  24856. /**
  24857. * For internal use only. Please do not use.
  24858. */
  24859. reservedDataStore: any;
  24860. /**
  24861. * Gets or sets a boolean used to define if the node must be serialized
  24862. */
  24863. doNotSerialize: boolean;
  24864. /** @hidden */
  24865. _isDisposed: boolean;
  24866. /**
  24867. * Gets a list of Animations associated with the node
  24868. */
  24869. animations: import("babylonjs/Animations/animation").Animation[];
  24870. protected _ranges: {
  24871. [name: string]: Nullable<AnimationRange>;
  24872. };
  24873. /**
  24874. * Callback raised when the node is ready to be used
  24875. */
  24876. onReady: (node: Node) => void;
  24877. private _isEnabled;
  24878. private _isParentEnabled;
  24879. private _isReady;
  24880. /** @hidden */
  24881. _currentRenderId: number;
  24882. private _parentRenderId;
  24883. protected _childRenderId: number;
  24884. /** @hidden */
  24885. _waitingParentId: Nullable<string>;
  24886. /** @hidden */
  24887. _scene: Scene;
  24888. /** @hidden */
  24889. _cache: any;
  24890. private _parentNode;
  24891. private _children;
  24892. /** @hidden */
  24893. _worldMatrix: Matrix;
  24894. /** @hidden */
  24895. _worldMatrixDeterminant: number;
  24896. /** @hidden */
  24897. private _sceneRootNodesIndex;
  24898. /**
  24899. * Gets a boolean indicating if the node has been disposed
  24900. * @returns true if the node was disposed
  24901. */
  24902. isDisposed(): boolean;
  24903. /**
  24904. * Gets or sets the parent of the node
  24905. */
  24906. parent: Nullable<Node>;
  24907. private addToSceneRootNodes;
  24908. private removeFromSceneRootNodes;
  24909. private _animationPropertiesOverride;
  24910. /**
  24911. * Gets or sets the animation properties override
  24912. */
  24913. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24914. /**
  24915. * Gets a string idenfifying the name of the class
  24916. * @returns "Node" string
  24917. */
  24918. getClassName(): string;
  24919. /** @hidden */
  24920. readonly _isNode: boolean;
  24921. /**
  24922. * An event triggered when the mesh is disposed
  24923. */
  24924. onDisposeObservable: Observable<Node>;
  24925. private _onDisposeObserver;
  24926. /**
  24927. * Sets a callback that will be raised when the node will be disposed
  24928. */
  24929. onDispose: () => void;
  24930. /**
  24931. * Creates a new Node
  24932. * @param name the name and id to be given to this node
  24933. * @param scene the scene this node will be added to
  24934. * @param addToRootNodes the node will be added to scene.rootNodes
  24935. */
  24936. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24937. /**
  24938. * Gets the scene of the node
  24939. * @returns a scene
  24940. */
  24941. getScene(): Scene;
  24942. /**
  24943. * Gets the engine of the node
  24944. * @returns a Engine
  24945. */
  24946. getEngine(): Engine;
  24947. private _behaviors;
  24948. /**
  24949. * Attach a behavior to the node
  24950. * @see http://doc.babylonjs.com/features/behaviour
  24951. * @param behavior defines the behavior to attach
  24952. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24953. * @returns the current Node
  24954. */
  24955. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24956. /**
  24957. * Remove an attached behavior
  24958. * @see http://doc.babylonjs.com/features/behaviour
  24959. * @param behavior defines the behavior to attach
  24960. * @returns the current Node
  24961. */
  24962. removeBehavior(behavior: Behavior<Node>): Node;
  24963. /**
  24964. * Gets the list of attached behaviors
  24965. * @see http://doc.babylonjs.com/features/behaviour
  24966. */
  24967. readonly behaviors: Behavior<Node>[];
  24968. /**
  24969. * Gets an attached behavior by name
  24970. * @param name defines the name of the behavior to look for
  24971. * @see http://doc.babylonjs.com/features/behaviour
  24972. * @returns null if behavior was not found else the requested behavior
  24973. */
  24974. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24975. /**
  24976. * Returns the latest update of the World matrix
  24977. * @returns a Matrix
  24978. */
  24979. getWorldMatrix(): Matrix;
  24980. /** @hidden */
  24981. _getWorldMatrixDeterminant(): number;
  24982. /**
  24983. * Returns directly the latest state of the mesh World matrix.
  24984. * A Matrix is returned.
  24985. */
  24986. readonly worldMatrixFromCache: Matrix;
  24987. /** @hidden */
  24988. _initCache(): void;
  24989. /** @hidden */
  24990. updateCache(force?: boolean): void;
  24991. /** @hidden */
  24992. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24993. /** @hidden */
  24994. _updateCache(ignoreParentClass?: boolean): void;
  24995. /** @hidden */
  24996. _isSynchronized(): boolean;
  24997. /** @hidden */
  24998. _markSyncedWithParent(): void;
  24999. /** @hidden */
  25000. isSynchronizedWithParent(): boolean;
  25001. /** @hidden */
  25002. isSynchronized(): boolean;
  25003. /**
  25004. * Is this node ready to be used/rendered
  25005. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25006. * @return true if the node is ready
  25007. */
  25008. isReady(completeCheck?: boolean): boolean;
  25009. /**
  25010. * Is this node enabled?
  25011. * 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
  25012. * @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
  25013. * @return whether this node (and its parent) is enabled
  25014. */
  25015. isEnabled(checkAncestors?: boolean): boolean;
  25016. /** @hidden */
  25017. protected _syncParentEnabledState(): void;
  25018. /**
  25019. * Set the enabled state of this node
  25020. * @param value defines the new enabled state
  25021. */
  25022. setEnabled(value: boolean): void;
  25023. /**
  25024. * Is this node a descendant of the given node?
  25025. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25026. * @param ancestor defines the parent node to inspect
  25027. * @returns a boolean indicating if this node is a descendant of the given node
  25028. */
  25029. isDescendantOf(ancestor: Node): boolean;
  25030. /** @hidden */
  25031. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25032. /**
  25033. * Will return all nodes that have this node as ascendant
  25034. * @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
  25035. * @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
  25036. * @return all children nodes of all types
  25037. */
  25038. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25039. /**
  25040. * Get all child-meshes of this node
  25041. * @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)
  25042. * @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
  25043. * @returns an array of AbstractMesh
  25044. */
  25045. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25046. /**
  25047. * Get all direct children of this node
  25048. * @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
  25049. * @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)
  25050. * @returns an array of Node
  25051. */
  25052. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25053. /** @hidden */
  25054. _setReady(state: boolean): void;
  25055. /**
  25056. * Get an animation by name
  25057. * @param name defines the name of the animation to look for
  25058. * @returns null if not found else the requested animation
  25059. */
  25060. getAnimationByName(name: string): Nullable<Animation>;
  25061. /**
  25062. * Creates an animation range for this node
  25063. * @param name defines the name of the range
  25064. * @param from defines the starting key
  25065. * @param to defines the end key
  25066. */
  25067. createAnimationRange(name: string, from: number, to: number): void;
  25068. /**
  25069. * Delete a specific animation range
  25070. * @param name defines the name of the range to delete
  25071. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25072. */
  25073. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25074. /**
  25075. * Get an animation range by name
  25076. * @param name defines the name of the animation range to look for
  25077. * @returns null if not found else the requested animation range
  25078. */
  25079. getAnimationRange(name: string): Nullable<AnimationRange>;
  25080. /**
  25081. * Gets the list of all animation ranges defined on this node
  25082. * @returns an array
  25083. */
  25084. getAnimationRanges(): Nullable<AnimationRange>[];
  25085. /**
  25086. * Will start the animation sequence
  25087. * @param name defines the range frames for animation sequence
  25088. * @param loop defines if the animation should loop (false by default)
  25089. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25090. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25091. * @returns the object created for this animation. If range does not exist, it will return null
  25092. */
  25093. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25094. /**
  25095. * Serialize animation ranges into a JSON compatible object
  25096. * @returns serialization object
  25097. */
  25098. serializeAnimationRanges(): any;
  25099. /**
  25100. * Computes the world matrix of the node
  25101. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25102. * @returns the world matrix
  25103. */
  25104. computeWorldMatrix(force?: boolean): Matrix;
  25105. /**
  25106. * Releases resources associated with this node.
  25107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25109. */
  25110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25111. /**
  25112. * Parse animation range data from a serialization object and store them into a given node
  25113. * @param node defines where to store the animation ranges
  25114. * @param parsedNode defines the serialization object to read data from
  25115. * @param scene defines the hosting scene
  25116. */
  25117. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25118. }
  25119. }
  25120. declare module "babylonjs/Animations/animation" {
  25121. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25122. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25123. import { Nullable } from "babylonjs/types";
  25124. import { Scene } from "babylonjs/scene";
  25125. import { IAnimatable } from "babylonjs/Misc/tools";
  25126. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25127. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25128. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25129. import { Node } from "babylonjs/node";
  25130. import { Animatable } from "babylonjs/Animations/animatable";
  25131. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25132. /**
  25133. * Class used to store any kind of animation
  25134. */
  25135. export class Animation {
  25136. /**Name of the animation */
  25137. name: string;
  25138. /**Property to animate */
  25139. targetProperty: string;
  25140. /**The frames per second of the animation */
  25141. framePerSecond: number;
  25142. /**The data type of the animation */
  25143. dataType: number;
  25144. /**The loop mode of the animation */
  25145. loopMode?: number | undefined;
  25146. /**Specifies if blending should be enabled */
  25147. enableBlending?: boolean | undefined;
  25148. /**
  25149. * Use matrix interpolation instead of using direct key value when animating matrices
  25150. */
  25151. static AllowMatricesInterpolation: boolean;
  25152. /**
  25153. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25154. */
  25155. static AllowMatrixDecomposeForInterpolation: boolean;
  25156. /**
  25157. * Stores the key frames of the animation
  25158. */
  25159. private _keys;
  25160. /**
  25161. * Stores the easing function of the animation
  25162. */
  25163. private _easingFunction;
  25164. /**
  25165. * @hidden Internal use only
  25166. */
  25167. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25168. /**
  25169. * The set of event that will be linked to this animation
  25170. */
  25171. private _events;
  25172. /**
  25173. * Stores an array of target property paths
  25174. */
  25175. targetPropertyPath: string[];
  25176. /**
  25177. * Stores the blending speed of the animation
  25178. */
  25179. blendingSpeed: number;
  25180. /**
  25181. * Stores the animation ranges for the animation
  25182. */
  25183. private _ranges;
  25184. /**
  25185. * @hidden Internal use
  25186. */
  25187. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25188. /**
  25189. * Sets up an animation
  25190. * @param property The property to animate
  25191. * @param animationType The animation type to apply
  25192. * @param framePerSecond The frames per second of the animation
  25193. * @param easingFunction The easing function used in the animation
  25194. * @returns The created animation
  25195. */
  25196. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25197. /**
  25198. * Create and start an animation on a node
  25199. * @param name defines the name of the global animation that will be run on all nodes
  25200. * @param node defines the root node where the animation will take place
  25201. * @param targetProperty defines property to animate
  25202. * @param framePerSecond defines the number of frame per second yo use
  25203. * @param totalFrame defines the number of frames in total
  25204. * @param from defines the initial value
  25205. * @param to defines the final value
  25206. * @param loopMode defines which loop mode you want to use (off by default)
  25207. * @param easingFunction defines the easing function to use (linear by default)
  25208. * @param onAnimationEnd defines the callback to call when animation end
  25209. * @returns the animatable created for this animation
  25210. */
  25211. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25212. /**
  25213. * Create and start an animation on a node and its descendants
  25214. * @param name defines the name of the global animation that will be run on all nodes
  25215. * @param node defines the root node where the animation will take place
  25216. * @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
  25217. * @param targetProperty defines property to animate
  25218. * @param framePerSecond defines the number of frame per second to use
  25219. * @param totalFrame defines the number of frames in total
  25220. * @param from defines the initial value
  25221. * @param to defines the final value
  25222. * @param loopMode defines which loop mode you want to use (off by default)
  25223. * @param easingFunction defines the easing function to use (linear by default)
  25224. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25225. * @returns the list of animatables created for all nodes
  25226. * @example https://www.babylonjs-playground.com/#MH0VLI
  25227. */
  25228. 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[]>;
  25229. /**
  25230. * Creates a new animation, merges it with the existing animations and starts it
  25231. * @param name Name of the animation
  25232. * @param node Node which contains the scene that begins the animations
  25233. * @param targetProperty Specifies which property to animate
  25234. * @param framePerSecond The frames per second of the animation
  25235. * @param totalFrame The total number of frames
  25236. * @param from The frame at the beginning of the animation
  25237. * @param to The frame at the end of the animation
  25238. * @param loopMode Specifies the loop mode of the animation
  25239. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25240. * @param onAnimationEnd Callback to run once the animation is complete
  25241. * @returns Nullable animation
  25242. */
  25243. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25244. /**
  25245. * Transition property of an host to the target Value
  25246. * @param property The property to transition
  25247. * @param targetValue The target Value of the property
  25248. * @param host The object where the property to animate belongs
  25249. * @param scene Scene used to run the animation
  25250. * @param frameRate Framerate (in frame/s) to use
  25251. * @param transition The transition type we want to use
  25252. * @param duration The duration of the animation, in milliseconds
  25253. * @param onAnimationEnd Callback trigger at the end of the animation
  25254. * @returns Nullable animation
  25255. */
  25256. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25257. /**
  25258. * Return the array of runtime animations currently using this animation
  25259. */
  25260. readonly runtimeAnimations: RuntimeAnimation[];
  25261. /**
  25262. * Specifies if any of the runtime animations are currently running
  25263. */
  25264. readonly hasRunningRuntimeAnimations: boolean;
  25265. /**
  25266. * Initializes the animation
  25267. * @param name Name of the animation
  25268. * @param targetProperty Property to animate
  25269. * @param framePerSecond The frames per second of the animation
  25270. * @param dataType The data type of the animation
  25271. * @param loopMode The loop mode of the animation
  25272. * @param enableBlending Specifies if blending should be enabled
  25273. */
  25274. constructor(
  25275. /**Name of the animation */
  25276. name: string,
  25277. /**Property to animate */
  25278. targetProperty: string,
  25279. /**The frames per second of the animation */
  25280. framePerSecond: number,
  25281. /**The data type of the animation */
  25282. dataType: number,
  25283. /**The loop mode of the animation */
  25284. loopMode?: number | undefined,
  25285. /**Specifies if blending should be enabled */
  25286. enableBlending?: boolean | undefined);
  25287. /**
  25288. * Converts the animation to a string
  25289. * @param fullDetails support for multiple levels of logging within scene loading
  25290. * @returns String form of the animation
  25291. */
  25292. toString(fullDetails?: boolean): string;
  25293. /**
  25294. * Add an event to this animation
  25295. * @param event Event to add
  25296. */
  25297. addEvent(event: AnimationEvent): void;
  25298. /**
  25299. * Remove all events found at the given frame
  25300. * @param frame The frame to remove events from
  25301. */
  25302. removeEvents(frame: number): void;
  25303. /**
  25304. * Retrieves all the events from the animation
  25305. * @returns Events from the animation
  25306. */
  25307. getEvents(): AnimationEvent[];
  25308. /**
  25309. * Creates an animation range
  25310. * @param name Name of the animation range
  25311. * @param from Starting frame of the animation range
  25312. * @param to Ending frame of the animation
  25313. */
  25314. createRange(name: string, from: number, to: number): void;
  25315. /**
  25316. * Deletes an animation range by name
  25317. * @param name Name of the animation range to delete
  25318. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25319. */
  25320. deleteRange(name: string, deleteFrames?: boolean): void;
  25321. /**
  25322. * Gets the animation range by name, or null if not defined
  25323. * @param name Name of the animation range
  25324. * @returns Nullable animation range
  25325. */
  25326. getRange(name: string): Nullable<AnimationRange>;
  25327. /**
  25328. * Gets the key frames from the animation
  25329. * @returns The key frames of the animation
  25330. */
  25331. getKeys(): Array<IAnimationKey>;
  25332. /**
  25333. * Gets the highest frame rate of the animation
  25334. * @returns Highest frame rate of the animation
  25335. */
  25336. getHighestFrame(): number;
  25337. /**
  25338. * Gets the easing function of the animation
  25339. * @returns Easing function of the animation
  25340. */
  25341. getEasingFunction(): IEasingFunction;
  25342. /**
  25343. * Sets the easing function of the animation
  25344. * @param easingFunction A custom mathematical formula for animation
  25345. */
  25346. setEasingFunction(easingFunction: EasingFunction): void;
  25347. /**
  25348. * Interpolates a scalar linearly
  25349. * @param startValue Start value of the animation curve
  25350. * @param endValue End value of the animation curve
  25351. * @param gradient Scalar amount to interpolate
  25352. * @returns Interpolated scalar value
  25353. */
  25354. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25355. /**
  25356. * Interpolates a scalar cubically
  25357. * @param startValue Start value of the animation curve
  25358. * @param outTangent End tangent of the animation
  25359. * @param endValue End value of the animation curve
  25360. * @param inTangent Start tangent of the animation curve
  25361. * @param gradient Scalar amount to interpolate
  25362. * @returns Interpolated scalar value
  25363. */
  25364. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25365. /**
  25366. * Interpolates a quaternion using a spherical linear interpolation
  25367. * @param startValue Start value of the animation curve
  25368. * @param endValue End value of the animation curve
  25369. * @param gradient Scalar amount to interpolate
  25370. * @returns Interpolated quaternion value
  25371. */
  25372. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25373. /**
  25374. * Interpolates a quaternion cubically
  25375. * @param startValue Start value of the animation curve
  25376. * @param outTangent End tangent of the animation curve
  25377. * @param endValue End value of the animation curve
  25378. * @param inTangent Start tangent of the animation curve
  25379. * @param gradient Scalar amount to interpolate
  25380. * @returns Interpolated quaternion value
  25381. */
  25382. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25383. /**
  25384. * Interpolates a Vector3 linearl
  25385. * @param startValue Start value of the animation curve
  25386. * @param endValue End value of the animation curve
  25387. * @param gradient Scalar amount to interpolate
  25388. * @returns Interpolated scalar value
  25389. */
  25390. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25391. /**
  25392. * Interpolates a Vector3 cubically
  25393. * @param startValue Start value of the animation curve
  25394. * @param outTangent End tangent of the animation
  25395. * @param endValue End value of the animation curve
  25396. * @param inTangent Start tangent of the animation curve
  25397. * @param gradient Scalar amount to interpolate
  25398. * @returns InterpolatedVector3 value
  25399. */
  25400. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25401. /**
  25402. * Interpolates a Vector2 linearly
  25403. * @param startValue Start value of the animation curve
  25404. * @param endValue End value of the animation curve
  25405. * @param gradient Scalar amount to interpolate
  25406. * @returns Interpolated Vector2 value
  25407. */
  25408. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25409. /**
  25410. * Interpolates a Vector2 cubically
  25411. * @param startValue Start value of the animation curve
  25412. * @param outTangent End tangent of the animation
  25413. * @param endValue End value of the animation curve
  25414. * @param inTangent Start tangent of the animation curve
  25415. * @param gradient Scalar amount to interpolate
  25416. * @returns Interpolated Vector2 value
  25417. */
  25418. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25419. /**
  25420. * Interpolates a size linearly
  25421. * @param startValue Start value of the animation curve
  25422. * @param endValue End value of the animation curve
  25423. * @param gradient Scalar amount to interpolate
  25424. * @returns Interpolated Size value
  25425. */
  25426. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25427. /**
  25428. * Interpolates a Color3 linearly
  25429. * @param startValue Start value of the animation curve
  25430. * @param endValue End value of the animation curve
  25431. * @param gradient Scalar amount to interpolate
  25432. * @returns Interpolated Color3 value
  25433. */
  25434. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25435. /**
  25436. * @hidden Internal use only
  25437. */
  25438. _getKeyValue(value: any): any;
  25439. /**
  25440. * @hidden Internal use only
  25441. */
  25442. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25443. /**
  25444. * Defines the function to use to interpolate matrices
  25445. * @param startValue defines the start matrix
  25446. * @param endValue defines the end matrix
  25447. * @param gradient defines the gradient between both matrices
  25448. * @param result defines an optional target matrix where to store the interpolation
  25449. * @returns the interpolated matrix
  25450. */
  25451. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25452. /**
  25453. * Makes a copy of the animation
  25454. * @returns Cloned animation
  25455. */
  25456. clone(): Animation;
  25457. /**
  25458. * Sets the key frames of the animation
  25459. * @param values The animation key frames to set
  25460. */
  25461. setKeys(values: Array<IAnimationKey>): void;
  25462. /**
  25463. * Serializes the animation to an object
  25464. * @returns Serialized object
  25465. */
  25466. serialize(): any;
  25467. /**
  25468. * Float animation type
  25469. */
  25470. private static _ANIMATIONTYPE_FLOAT;
  25471. /**
  25472. * Vector3 animation type
  25473. */
  25474. private static _ANIMATIONTYPE_VECTOR3;
  25475. /**
  25476. * Quaternion animation type
  25477. */
  25478. private static _ANIMATIONTYPE_QUATERNION;
  25479. /**
  25480. * Matrix animation type
  25481. */
  25482. private static _ANIMATIONTYPE_MATRIX;
  25483. /**
  25484. * Color3 animation type
  25485. */
  25486. private static _ANIMATIONTYPE_COLOR3;
  25487. /**
  25488. * Vector2 animation type
  25489. */
  25490. private static _ANIMATIONTYPE_VECTOR2;
  25491. /**
  25492. * Size animation type
  25493. */
  25494. private static _ANIMATIONTYPE_SIZE;
  25495. /**
  25496. * Relative Loop Mode
  25497. */
  25498. private static _ANIMATIONLOOPMODE_RELATIVE;
  25499. /**
  25500. * Cycle Loop Mode
  25501. */
  25502. private static _ANIMATIONLOOPMODE_CYCLE;
  25503. /**
  25504. * Constant Loop Mode
  25505. */
  25506. private static _ANIMATIONLOOPMODE_CONSTANT;
  25507. /**
  25508. * Get the float animation type
  25509. */
  25510. static readonly ANIMATIONTYPE_FLOAT: number;
  25511. /**
  25512. * Get the Vector3 animation type
  25513. */
  25514. static readonly ANIMATIONTYPE_VECTOR3: number;
  25515. /**
  25516. * Get the Vector2 animation type
  25517. */
  25518. static readonly ANIMATIONTYPE_VECTOR2: number;
  25519. /**
  25520. * Get the Size animation type
  25521. */
  25522. static readonly ANIMATIONTYPE_SIZE: number;
  25523. /**
  25524. * Get the Quaternion animation type
  25525. */
  25526. static readonly ANIMATIONTYPE_QUATERNION: number;
  25527. /**
  25528. * Get the Matrix animation type
  25529. */
  25530. static readonly ANIMATIONTYPE_MATRIX: number;
  25531. /**
  25532. * Get the Color3 animation type
  25533. */
  25534. static readonly ANIMATIONTYPE_COLOR3: number;
  25535. /**
  25536. * Get the Relative Loop Mode
  25537. */
  25538. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25539. /**
  25540. * Get the Cycle Loop Mode
  25541. */
  25542. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25543. /**
  25544. * Get the Constant Loop Mode
  25545. */
  25546. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25547. /** @hidden */
  25548. static _UniversalLerp(left: any, right: any, amount: number): any;
  25549. /**
  25550. * Parses an animation object and creates an animation
  25551. * @param parsedAnimation Parsed animation object
  25552. * @returns Animation object
  25553. */
  25554. static Parse(parsedAnimation: any): Animation;
  25555. /**
  25556. * Appends the serialized animations from the source animations
  25557. * @param source Source containing the animations
  25558. * @param destination Target to store the animations
  25559. */
  25560. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25561. }
  25562. }
  25563. declare module "babylonjs/Materials/Textures/baseTexture" {
  25564. import { Observable } from "babylonjs/Misc/observable";
  25565. import { IAnimatable } from "babylonjs/Misc/tools";
  25566. import { Nullable } from "babylonjs/types";
  25567. import { Scene } from "babylonjs/scene";
  25568. import { Matrix, ISize } from "babylonjs/Maths/math";
  25569. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25571. /**
  25572. * Base class of all the textures in babylon.
  25573. * It groups all the common properties the materials, post process, lights... might need
  25574. * in order to make a correct use of the texture.
  25575. */
  25576. export class BaseTexture implements IAnimatable {
  25577. /**
  25578. * Default anisotropic filtering level for the application.
  25579. * It is set to 4 as a good tradeoff between perf and quality.
  25580. */
  25581. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25582. /**
  25583. * Gets or sets the unique id of the texture
  25584. */
  25585. uniqueId: number;
  25586. /**
  25587. * Define the name of the texture.
  25588. */
  25589. name: string;
  25590. /**
  25591. * Gets or sets an object used to store user defined information.
  25592. */
  25593. metadata: any;
  25594. /**
  25595. * For internal use only. Please do not use.
  25596. */
  25597. reservedDataStore: any;
  25598. private _hasAlpha;
  25599. /**
  25600. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25601. */
  25602. hasAlpha: boolean;
  25603. /**
  25604. * Defines if the alpha value should be determined via the rgb values.
  25605. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25606. */
  25607. getAlphaFromRGB: boolean;
  25608. /**
  25609. * Intensity or strength of the texture.
  25610. * It is commonly used by materials to fine tune the intensity of the texture
  25611. */
  25612. level: number;
  25613. /**
  25614. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25615. * This is part of the texture as textures usually maps to one uv set.
  25616. */
  25617. coordinatesIndex: number;
  25618. private _coordinatesMode;
  25619. /**
  25620. * How a texture is mapped.
  25621. *
  25622. * | Value | Type | Description |
  25623. * | ----- | ----------------------------------- | ----------- |
  25624. * | 0 | EXPLICIT_MODE | |
  25625. * | 1 | SPHERICAL_MODE | |
  25626. * | 2 | PLANAR_MODE | |
  25627. * | 3 | CUBIC_MODE | |
  25628. * | 4 | PROJECTION_MODE | |
  25629. * | 5 | SKYBOX_MODE | |
  25630. * | 6 | INVCUBIC_MODE | |
  25631. * | 7 | EQUIRECTANGULAR_MODE | |
  25632. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25633. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25634. */
  25635. coordinatesMode: number;
  25636. /**
  25637. * | Value | Type | Description |
  25638. * | ----- | ------------------ | ----------- |
  25639. * | 0 | CLAMP_ADDRESSMODE | |
  25640. * | 1 | WRAP_ADDRESSMODE | |
  25641. * | 2 | MIRROR_ADDRESSMODE | |
  25642. */
  25643. wrapU: number;
  25644. /**
  25645. * | Value | Type | Description |
  25646. * | ----- | ------------------ | ----------- |
  25647. * | 0 | CLAMP_ADDRESSMODE | |
  25648. * | 1 | WRAP_ADDRESSMODE | |
  25649. * | 2 | MIRROR_ADDRESSMODE | |
  25650. */
  25651. wrapV: number;
  25652. /**
  25653. * | Value | Type | Description |
  25654. * | ----- | ------------------ | ----------- |
  25655. * | 0 | CLAMP_ADDRESSMODE | |
  25656. * | 1 | WRAP_ADDRESSMODE | |
  25657. * | 2 | MIRROR_ADDRESSMODE | |
  25658. */
  25659. wrapR: number;
  25660. /**
  25661. * With compliant hardware and browser (supporting anisotropic filtering)
  25662. * this defines the level of anisotropic filtering in the texture.
  25663. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25664. */
  25665. anisotropicFilteringLevel: number;
  25666. /**
  25667. * Define if the texture is a cube texture or if false a 2d texture.
  25668. */
  25669. isCube: boolean;
  25670. /**
  25671. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25672. */
  25673. is3D: boolean;
  25674. /**
  25675. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25676. * HDR texture are usually stored in linear space.
  25677. * This only impacts the PBR and Background materials
  25678. */
  25679. gammaSpace: boolean;
  25680. /**
  25681. * Gets whether or not the texture contains RGBD data.
  25682. */
  25683. readonly isRGBD: boolean;
  25684. /**
  25685. * Is Z inverted in the texture (useful in a cube texture).
  25686. */
  25687. invertZ: boolean;
  25688. /**
  25689. * Are mip maps generated for this texture or not.
  25690. */
  25691. readonly noMipmap: boolean;
  25692. /**
  25693. * @hidden
  25694. */
  25695. lodLevelInAlpha: boolean;
  25696. /**
  25697. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25698. */
  25699. lodGenerationOffset: number;
  25700. /**
  25701. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25702. */
  25703. lodGenerationScale: number;
  25704. /**
  25705. * Define if the texture is a render target.
  25706. */
  25707. isRenderTarget: boolean;
  25708. /**
  25709. * Define the unique id of the texture in the scene.
  25710. */
  25711. readonly uid: string;
  25712. /**
  25713. * Return a string representation of the texture.
  25714. * @returns the texture as a string
  25715. */
  25716. toString(): string;
  25717. /**
  25718. * Get the class name of the texture.
  25719. * @returns "BaseTexture"
  25720. */
  25721. getClassName(): string;
  25722. /**
  25723. * Define the list of animation attached to the texture.
  25724. */
  25725. animations: import("babylonjs/Animations/animation").Animation[];
  25726. /**
  25727. * An event triggered when the texture is disposed.
  25728. */
  25729. onDisposeObservable: Observable<BaseTexture>;
  25730. private _onDisposeObserver;
  25731. /**
  25732. * Callback triggered when the texture has been disposed.
  25733. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25734. */
  25735. onDispose: () => void;
  25736. /**
  25737. * Define the current state of the loading sequence when in delayed load mode.
  25738. */
  25739. delayLoadState: number;
  25740. private _scene;
  25741. /** @hidden */
  25742. _texture: Nullable<InternalTexture>;
  25743. private _uid;
  25744. /**
  25745. * Define if the texture is preventinga material to render or not.
  25746. * If not and the texture is not ready, the engine will use a default black texture instead.
  25747. */
  25748. readonly isBlocking: boolean;
  25749. /**
  25750. * Instantiates a new BaseTexture.
  25751. * Base class of all the textures in babylon.
  25752. * It groups all the common properties the materials, post process, lights... might need
  25753. * in order to make a correct use of the texture.
  25754. * @param scene Define the scene the texture blongs to
  25755. */
  25756. constructor(scene: Nullable<Scene>);
  25757. /**
  25758. * Get the scene the texture belongs to.
  25759. * @returns the scene or null if undefined
  25760. */
  25761. getScene(): Nullable<Scene>;
  25762. /**
  25763. * Get the texture transform matrix used to offset tile the texture for istance.
  25764. * @returns the transformation matrix
  25765. */
  25766. getTextureMatrix(): Matrix;
  25767. /**
  25768. * Get the texture reflection matrix used to rotate/transform the reflection.
  25769. * @returns the reflection matrix
  25770. */
  25771. getReflectionTextureMatrix(): Matrix;
  25772. /**
  25773. * Get the underlying lower level texture from Babylon.
  25774. * @returns the insternal texture
  25775. */
  25776. getInternalTexture(): Nullable<InternalTexture>;
  25777. /**
  25778. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25779. * @returns true if ready or not blocking
  25780. */
  25781. isReadyOrNotBlocking(): boolean;
  25782. /**
  25783. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25784. * @returns true if fully ready
  25785. */
  25786. isReady(): boolean;
  25787. private _cachedSize;
  25788. /**
  25789. * Get the size of the texture.
  25790. * @returns the texture size.
  25791. */
  25792. getSize(): ISize;
  25793. /**
  25794. * Get the base size of the texture.
  25795. * It can be different from the size if the texture has been resized for POT for instance
  25796. * @returns the base size
  25797. */
  25798. getBaseSize(): ISize;
  25799. /**
  25800. * Update the sampling mode of the texture.
  25801. * Default is Trilinear mode.
  25802. *
  25803. * | Value | Type | Description |
  25804. * | ----- | ------------------ | ----------- |
  25805. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25806. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25807. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25808. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25809. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25810. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25811. * | 7 | NEAREST_LINEAR | |
  25812. * | 8 | NEAREST_NEAREST | |
  25813. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25814. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25815. * | 11 | LINEAR_LINEAR | |
  25816. * | 12 | LINEAR_NEAREST | |
  25817. *
  25818. * > _mag_: magnification filter (close to the viewer)
  25819. * > _min_: minification filter (far from the viewer)
  25820. * > _mip_: filter used between mip map levels
  25821. *@param samplingMode Define the new sampling mode of the texture
  25822. */
  25823. updateSamplingMode(samplingMode: number): void;
  25824. /**
  25825. * Scales the texture if is `canRescale()`
  25826. * @param ratio the resize factor we want to use to rescale
  25827. */
  25828. scale(ratio: number): void;
  25829. /**
  25830. * Get if the texture can rescale.
  25831. */
  25832. readonly canRescale: boolean;
  25833. /** @hidden */
  25834. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25835. /** @hidden */
  25836. _rebuild(): void;
  25837. /**
  25838. * Triggers the load sequence in delayed load mode.
  25839. */
  25840. delayLoad(): void;
  25841. /**
  25842. * Clones the texture.
  25843. * @returns the cloned texture
  25844. */
  25845. clone(): Nullable<BaseTexture>;
  25846. /**
  25847. * Get the texture underlying type (INT, FLOAT...)
  25848. */
  25849. readonly textureType: number;
  25850. /**
  25851. * Get the texture underlying format (RGB, RGBA...)
  25852. */
  25853. readonly textureFormat: number;
  25854. /**
  25855. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25856. * This will returns an RGBA array buffer containing either in values (0-255) or
  25857. * float values (0-1) depending of the underlying buffer type.
  25858. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25859. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25860. * @param buffer defines a user defined buffer to fill with data (can be null)
  25861. * @returns The Array buffer containing the pixels data.
  25862. */
  25863. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25864. /**
  25865. * Release and destroy the underlying lower level texture aka internalTexture.
  25866. */
  25867. releaseInternalTexture(): void;
  25868. /**
  25869. * Get the polynomial representation of the texture data.
  25870. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25871. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25872. */
  25873. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25874. /** @hidden */
  25875. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25876. /** @hidden */
  25877. readonly _lodTextureMid: Nullable<BaseTexture>;
  25878. /** @hidden */
  25879. readonly _lodTextureLow: Nullable<BaseTexture>;
  25880. /**
  25881. * Dispose the texture and release its associated resources.
  25882. */
  25883. dispose(): void;
  25884. /**
  25885. * Serialize the texture into a JSON representation that can be parsed later on.
  25886. * @returns the JSON representation of the texture
  25887. */
  25888. serialize(): any;
  25889. /**
  25890. * Helper function to be called back once a list of texture contains only ready textures.
  25891. * @param textures Define the list of textures to wait for
  25892. * @param callback Define the callback triggered once the entire list will be ready
  25893. */
  25894. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25895. }
  25896. }
  25897. declare module "babylonjs/Materials/uniformBuffer" {
  25898. import { Nullable, FloatArray } from "babylonjs/types";
  25899. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25900. import { Engine } from "babylonjs/Engines/engine";
  25901. import { Effect } from "babylonjs/Materials/effect";
  25902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25903. /**
  25904. * Uniform buffer objects.
  25905. *
  25906. * Handles blocks of uniform on the GPU.
  25907. *
  25908. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25909. *
  25910. * For more information, please refer to :
  25911. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25912. */
  25913. export class UniformBuffer {
  25914. private _engine;
  25915. private _buffer;
  25916. private _data;
  25917. private _bufferData;
  25918. private _dynamic?;
  25919. private _uniformLocations;
  25920. private _uniformSizes;
  25921. private _uniformLocationPointer;
  25922. private _needSync;
  25923. private _noUBO;
  25924. private _currentEffect;
  25925. private static _MAX_UNIFORM_SIZE;
  25926. private static _tempBuffer;
  25927. /**
  25928. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25929. * This is dynamic to allow compat with webgl 1 and 2.
  25930. * You will need to pass the name of the uniform as well as the value.
  25931. */
  25932. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25933. /**
  25934. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25935. * This is dynamic to allow compat with webgl 1 and 2.
  25936. * You will need to pass the name of the uniform as well as the value.
  25937. */
  25938. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25939. /**
  25940. * Lambda to Update a single float in a uniform buffer.
  25941. * This is dynamic to allow compat with webgl 1 and 2.
  25942. * You will need to pass the name of the uniform as well as the value.
  25943. */
  25944. updateFloat: (name: string, x: number) => void;
  25945. /**
  25946. * Lambda to Update a vec2 of float in a uniform buffer.
  25947. * This is dynamic to allow compat with webgl 1 and 2.
  25948. * You will need to pass the name of the uniform as well as the value.
  25949. */
  25950. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25951. /**
  25952. * Lambda to Update a vec3 of float in a uniform buffer.
  25953. * This is dynamic to allow compat with webgl 1 and 2.
  25954. * You will need to pass the name of the uniform as well as the value.
  25955. */
  25956. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25957. /**
  25958. * Lambda to Update a vec4 of float in a uniform buffer.
  25959. * This is dynamic to allow compat with webgl 1 and 2.
  25960. * You will need to pass the name of the uniform as well as the value.
  25961. */
  25962. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25963. /**
  25964. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25965. * This is dynamic to allow compat with webgl 1 and 2.
  25966. * You will need to pass the name of the uniform as well as the value.
  25967. */
  25968. updateMatrix: (name: string, mat: Matrix) => void;
  25969. /**
  25970. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25971. * This is dynamic to allow compat with webgl 1 and 2.
  25972. * You will need to pass the name of the uniform as well as the value.
  25973. */
  25974. updateVector3: (name: string, vector: Vector3) => void;
  25975. /**
  25976. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25977. * This is dynamic to allow compat with webgl 1 and 2.
  25978. * You will need to pass the name of the uniform as well as the value.
  25979. */
  25980. updateVector4: (name: string, vector: Vector4) => void;
  25981. /**
  25982. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25983. * This is dynamic to allow compat with webgl 1 and 2.
  25984. * You will need to pass the name of the uniform as well as the value.
  25985. */
  25986. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25987. /**
  25988. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25989. * This is dynamic to allow compat with webgl 1 and 2.
  25990. * You will need to pass the name of the uniform as well as the value.
  25991. */
  25992. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25993. /**
  25994. * Instantiates a new Uniform buffer objects.
  25995. *
  25996. * Handles blocks of uniform on the GPU.
  25997. *
  25998. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25999. *
  26000. * For more information, please refer to :
  26001. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26002. * @param engine Define the engine the buffer is associated with
  26003. * @param data Define the data contained in the buffer
  26004. * @param dynamic Define if the buffer is updatable
  26005. */
  26006. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26007. /**
  26008. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26009. * or just falling back on setUniformXXX calls.
  26010. */
  26011. readonly useUbo: boolean;
  26012. /**
  26013. * Indicates if the WebGL underlying uniform buffer is in sync
  26014. * with the javascript cache data.
  26015. */
  26016. readonly isSync: boolean;
  26017. /**
  26018. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26019. * Also, a dynamic UniformBuffer will disable cache verification and always
  26020. * update the underlying WebGL uniform buffer to the GPU.
  26021. * @returns if Dynamic, otherwise false
  26022. */
  26023. isDynamic(): boolean;
  26024. /**
  26025. * The data cache on JS side.
  26026. * @returns the underlying data as a float array
  26027. */
  26028. getData(): Float32Array;
  26029. /**
  26030. * The underlying WebGL Uniform buffer.
  26031. * @returns the webgl buffer
  26032. */
  26033. getBuffer(): Nullable<WebGLBuffer>;
  26034. /**
  26035. * std140 layout specifies how to align data within an UBO structure.
  26036. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26037. * for specs.
  26038. */
  26039. private _fillAlignment;
  26040. /**
  26041. * Adds an uniform in the buffer.
  26042. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26043. * for the layout to be correct !
  26044. * @param name Name of the uniform, as used in the uniform block in the shader.
  26045. * @param size Data size, or data directly.
  26046. */
  26047. addUniform(name: string, size: number | number[]): void;
  26048. /**
  26049. * Adds a Matrix 4x4 to the uniform buffer.
  26050. * @param name Name of the uniform, as used in the uniform block in the shader.
  26051. * @param mat A 4x4 matrix.
  26052. */
  26053. addMatrix(name: string, mat: Matrix): void;
  26054. /**
  26055. * Adds a vec2 to the uniform buffer.
  26056. * @param name Name of the uniform, as used in the uniform block in the shader.
  26057. * @param x Define the x component value of the vec2
  26058. * @param y Define the y component value of the vec2
  26059. */
  26060. addFloat2(name: string, x: number, y: number): void;
  26061. /**
  26062. * Adds a vec3 to the uniform buffer.
  26063. * @param name Name of the uniform, as used in the uniform block in the shader.
  26064. * @param x Define the x component value of the vec3
  26065. * @param y Define the y component value of the vec3
  26066. * @param z Define the z component value of the vec3
  26067. */
  26068. addFloat3(name: string, x: number, y: number, z: number): void;
  26069. /**
  26070. * Adds a vec3 to the uniform buffer.
  26071. * @param name Name of the uniform, as used in the uniform block in the shader.
  26072. * @param color Define the vec3 from a Color
  26073. */
  26074. addColor3(name: string, color: Color3): void;
  26075. /**
  26076. * Adds a vec4 to the uniform buffer.
  26077. * @param name Name of the uniform, as used in the uniform block in the shader.
  26078. * @param color Define the rgb components from a Color
  26079. * @param alpha Define the a component of the vec4
  26080. */
  26081. addColor4(name: string, color: Color3, alpha: number): void;
  26082. /**
  26083. * Adds a vec3 to the uniform buffer.
  26084. * @param name Name of the uniform, as used in the uniform block in the shader.
  26085. * @param vector Define the vec3 components from a Vector
  26086. */
  26087. addVector3(name: string, vector: Vector3): void;
  26088. /**
  26089. * Adds a Matrix 3x3 to the uniform buffer.
  26090. * @param name Name of the uniform, as used in the uniform block in the shader.
  26091. */
  26092. addMatrix3x3(name: string): void;
  26093. /**
  26094. * Adds a Matrix 2x2 to the uniform buffer.
  26095. * @param name Name of the uniform, as used in the uniform block in the shader.
  26096. */
  26097. addMatrix2x2(name: string): void;
  26098. /**
  26099. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26100. */
  26101. create(): void;
  26102. /** @hidden */
  26103. _rebuild(): void;
  26104. /**
  26105. * Updates the WebGL Uniform Buffer on the GPU.
  26106. * If the `dynamic` flag is set to true, no cache comparison is done.
  26107. * Otherwise, the buffer will be updated only if the cache differs.
  26108. */
  26109. update(): void;
  26110. /**
  26111. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26112. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26113. * @param data Define the flattened data
  26114. * @param size Define the size of the data.
  26115. */
  26116. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26117. private _updateMatrix3x3ForUniform;
  26118. private _updateMatrix3x3ForEffect;
  26119. private _updateMatrix2x2ForEffect;
  26120. private _updateMatrix2x2ForUniform;
  26121. private _updateFloatForEffect;
  26122. private _updateFloatForUniform;
  26123. private _updateFloat2ForEffect;
  26124. private _updateFloat2ForUniform;
  26125. private _updateFloat3ForEffect;
  26126. private _updateFloat3ForUniform;
  26127. private _updateFloat4ForEffect;
  26128. private _updateFloat4ForUniform;
  26129. private _updateMatrixForEffect;
  26130. private _updateMatrixForUniform;
  26131. private _updateVector3ForEffect;
  26132. private _updateVector3ForUniform;
  26133. private _updateVector4ForEffect;
  26134. private _updateVector4ForUniform;
  26135. private _updateColor3ForEffect;
  26136. private _updateColor3ForUniform;
  26137. private _updateColor4ForEffect;
  26138. private _updateColor4ForUniform;
  26139. /**
  26140. * Sets a sampler uniform on the effect.
  26141. * @param name Define the name of the sampler.
  26142. * @param texture Define the texture to set in the sampler
  26143. */
  26144. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26145. /**
  26146. * Directly updates the value of the uniform in the cache AND on the GPU.
  26147. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26148. * @param data Define the flattened data
  26149. */
  26150. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26151. /**
  26152. * Binds this uniform buffer to an effect.
  26153. * @param effect Define the effect to bind the buffer to
  26154. * @param name Name of the uniform block in the shader.
  26155. */
  26156. bindToEffect(effect: Effect, name: string): void;
  26157. /**
  26158. * Disposes the uniform buffer.
  26159. */
  26160. dispose(): void;
  26161. }
  26162. }
  26163. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26164. import { Nullable } from "babylonjs/types";
  26165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26166. /**
  26167. * This represents the required contract to create a new type of texture loader.
  26168. */
  26169. export interface IInternalTextureLoader {
  26170. /**
  26171. * Defines wether the loader supports cascade loading the different faces.
  26172. */
  26173. supportCascades: boolean;
  26174. /**
  26175. * This returns if the loader support the current file information.
  26176. * @param extension defines the file extension of the file being loaded
  26177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26178. * @param fallback defines the fallback internal texture if any
  26179. * @param isBase64 defines whether the texture is encoded as a base64
  26180. * @param isBuffer defines whether the texture data are stored as a buffer
  26181. * @returns true if the loader can load the specified file
  26182. */
  26183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26184. /**
  26185. * Transform the url before loading if required.
  26186. * @param rootUrl the url of the texture
  26187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26188. * @returns the transformed texture
  26189. */
  26190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26191. /**
  26192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26193. * @param rootUrl the url of the texture
  26194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26195. * @returns the fallback texture
  26196. */
  26197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26198. /**
  26199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26200. * @param data contains the texture data
  26201. * @param texture defines the BabylonJS internal texture
  26202. * @param createPolynomials will be true if polynomials have been requested
  26203. * @param onLoad defines the callback to trigger once the texture is ready
  26204. * @param onError defines the callback to trigger in case of error
  26205. */
  26206. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26207. /**
  26208. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26209. * @param data contains the texture data
  26210. * @param texture defines the BabylonJS internal texture
  26211. * @param callback defines the method to call once ready to upload
  26212. */
  26213. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26214. }
  26215. }
  26216. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26217. import { Scene } from "babylonjs/scene";
  26218. import { Engine } from "babylonjs/Engines/engine";
  26219. import { Texture } from "babylonjs/Materials/Textures/texture";
  26220. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26221. /**
  26222. * Creation options of the multi render target texture.
  26223. */
  26224. export interface IMultiRenderTargetOptions {
  26225. /**
  26226. * Define if the texture needs to create mip maps after render.
  26227. */
  26228. generateMipMaps?: boolean;
  26229. /**
  26230. * Define the types of all the draw buffers we want to create
  26231. */
  26232. types?: number[];
  26233. /**
  26234. * Define the sampling modes of all the draw buffers we want to create
  26235. */
  26236. samplingModes?: number[];
  26237. /**
  26238. * Define if a depth buffer is required
  26239. */
  26240. generateDepthBuffer?: boolean;
  26241. /**
  26242. * Define if a stencil buffer is required
  26243. */
  26244. generateStencilBuffer?: boolean;
  26245. /**
  26246. * Define if a depth texture is required instead of a depth buffer
  26247. */
  26248. generateDepthTexture?: boolean;
  26249. /**
  26250. * Define the number of desired draw buffers
  26251. */
  26252. textureCount?: number;
  26253. /**
  26254. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26255. */
  26256. doNotChangeAspectRatio?: boolean;
  26257. /**
  26258. * Define the default type of the buffers we are creating
  26259. */
  26260. defaultType?: number;
  26261. }
  26262. /**
  26263. * A multi render target, like a render target provides the ability to render to a texture.
  26264. * Unlike the render target, it can render to several draw buffers in one draw.
  26265. * This is specially interesting in deferred rendering or for any effects requiring more than
  26266. * just one color from a single pass.
  26267. */
  26268. export class MultiRenderTarget extends RenderTargetTexture {
  26269. private _internalTextures;
  26270. private _textures;
  26271. private _multiRenderTargetOptions;
  26272. /**
  26273. * Get if draw buffers are currently supported by the used hardware and browser.
  26274. */
  26275. readonly isSupported: boolean;
  26276. /**
  26277. * Get the list of textures generated by the multi render target.
  26278. */
  26279. readonly textures: Texture[];
  26280. /**
  26281. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26282. */
  26283. readonly depthTexture: Texture;
  26284. /**
  26285. * Set the wrapping mode on U of all the textures we are rendering to.
  26286. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26287. */
  26288. wrapU: number;
  26289. /**
  26290. * Set the wrapping mode on V of all the textures we are rendering to.
  26291. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26292. */
  26293. wrapV: number;
  26294. /**
  26295. * Instantiate a new multi render target texture.
  26296. * A multi render target, like a render target provides the ability to render to a texture.
  26297. * Unlike the render target, it can render to several draw buffers in one draw.
  26298. * This is specially interesting in deferred rendering or for any effects requiring more than
  26299. * just one color from a single pass.
  26300. * @param name Define the name of the texture
  26301. * @param size Define the size of the buffers to render to
  26302. * @param count Define the number of target we are rendering into
  26303. * @param scene Define the scene the texture belongs to
  26304. * @param options Define the options used to create the multi render target
  26305. */
  26306. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26307. /** @hidden */
  26308. _rebuild(): void;
  26309. private _createInternalTextures;
  26310. private _createTextures;
  26311. /**
  26312. * Define the number of samples used if MSAA is enabled.
  26313. */
  26314. samples: number;
  26315. /**
  26316. * Resize all the textures in the multi render target.
  26317. * Be carrefull as it will recreate all the data in the new texture.
  26318. * @param size Define the new size
  26319. */
  26320. resize(size: any): void;
  26321. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26322. /**
  26323. * Dispose the render targets and their associated resources
  26324. */
  26325. dispose(): void;
  26326. /**
  26327. * Release all the underlying texture used as draw buffers.
  26328. */
  26329. releaseInternalTextures(): void;
  26330. }
  26331. }
  26332. declare module "babylonjs/Audio/analyser" {
  26333. import { Scene } from "babylonjs/scene";
  26334. /**
  26335. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26337. */
  26338. export class Analyser {
  26339. /**
  26340. * Gets or sets the smoothing
  26341. * @ignorenaming
  26342. */
  26343. SMOOTHING: number;
  26344. /**
  26345. * Gets or sets the FFT table size
  26346. * @ignorenaming
  26347. */
  26348. FFT_SIZE: number;
  26349. /**
  26350. * Gets or sets the bar graph amplitude
  26351. * @ignorenaming
  26352. */
  26353. BARGRAPHAMPLITUDE: number;
  26354. /**
  26355. * Gets or sets the position of the debug canvas
  26356. * @ignorenaming
  26357. */
  26358. DEBUGCANVASPOS: {
  26359. x: number;
  26360. y: number;
  26361. };
  26362. /**
  26363. * Gets or sets the debug canvas size
  26364. * @ignorenaming
  26365. */
  26366. DEBUGCANVASSIZE: {
  26367. width: number;
  26368. height: number;
  26369. };
  26370. private _byteFreqs;
  26371. private _byteTime;
  26372. private _floatFreqs;
  26373. private _webAudioAnalyser;
  26374. private _debugCanvas;
  26375. private _debugCanvasContext;
  26376. private _scene;
  26377. private _registerFunc;
  26378. private _audioEngine;
  26379. /**
  26380. * Creates a new analyser
  26381. * @param scene defines hosting scene
  26382. */
  26383. constructor(scene: Scene);
  26384. /**
  26385. * Get the number of data values you will have to play with for the visualization
  26386. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26387. * @returns a number
  26388. */
  26389. getFrequencyBinCount(): number;
  26390. /**
  26391. * Gets the current frequency data as a byte array
  26392. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26393. * @returns a Uint8Array
  26394. */
  26395. getByteFrequencyData(): Uint8Array;
  26396. /**
  26397. * Gets the current waveform as a byte array
  26398. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26399. * @returns a Uint8Array
  26400. */
  26401. getByteTimeDomainData(): Uint8Array;
  26402. /**
  26403. * Gets the current frequency data as a float array
  26404. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26405. * @returns a Float32Array
  26406. */
  26407. getFloatFrequencyData(): Float32Array;
  26408. /**
  26409. * Renders the debug canvas
  26410. */
  26411. drawDebugCanvas(): void;
  26412. /**
  26413. * Stops rendering the debug canvas and removes it
  26414. */
  26415. stopDebugCanvas(): void;
  26416. /**
  26417. * Connects two audio nodes
  26418. * @param inputAudioNode defines first node to connect
  26419. * @param outputAudioNode defines second node to connect
  26420. */
  26421. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26422. /**
  26423. * Releases all associated resources
  26424. */
  26425. dispose(): void;
  26426. }
  26427. }
  26428. declare module "babylonjs/Audio/audioEngine" {
  26429. import { IDisposable } from "babylonjs/scene";
  26430. import { Analyser } from "babylonjs/Audio/analyser";
  26431. import { Nullable } from "babylonjs/types";
  26432. import { Observable } from "babylonjs/Misc/observable";
  26433. /**
  26434. * This represents an audio engine and it is responsible
  26435. * to play, synchronize and analyse sounds throughout the application.
  26436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26437. */
  26438. export interface IAudioEngine extends IDisposable {
  26439. /**
  26440. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26441. */
  26442. readonly canUseWebAudio: boolean;
  26443. /**
  26444. * Gets the current AudioContext if available.
  26445. */
  26446. readonly audioContext: Nullable<AudioContext>;
  26447. /**
  26448. * The master gain node defines the global audio volume of your audio engine.
  26449. */
  26450. readonly masterGain: GainNode;
  26451. /**
  26452. * Gets whether or not mp3 are supported by your browser.
  26453. */
  26454. readonly isMP3supported: boolean;
  26455. /**
  26456. * Gets whether or not ogg are supported by your browser.
  26457. */
  26458. readonly isOGGsupported: boolean;
  26459. /**
  26460. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26461. * @ignoreNaming
  26462. */
  26463. WarnedWebAudioUnsupported: boolean;
  26464. /**
  26465. * Defines if the audio engine relies on a custom unlocked button.
  26466. * In this case, the embedded button will not be displayed.
  26467. */
  26468. useCustomUnlockedButton: boolean;
  26469. /**
  26470. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26471. */
  26472. readonly unlocked: boolean;
  26473. /**
  26474. * Event raised when audio has been unlocked on the browser.
  26475. */
  26476. onAudioUnlockedObservable: Observable<AudioEngine>;
  26477. /**
  26478. * Event raised when audio has been locked on the browser.
  26479. */
  26480. onAudioLockedObservable: Observable<AudioEngine>;
  26481. /**
  26482. * Flags the audio engine in Locked state.
  26483. * This happens due to new browser policies preventing audio to autoplay.
  26484. */
  26485. lock(): void;
  26486. /**
  26487. * Unlocks the audio engine once a user action has been done on the dom.
  26488. * This is helpful to resume play once browser policies have been satisfied.
  26489. */
  26490. unlock(): void;
  26491. }
  26492. /**
  26493. * This represents the default audio engine used in babylon.
  26494. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26496. */
  26497. export class AudioEngine implements IAudioEngine {
  26498. private _audioContext;
  26499. private _audioContextInitialized;
  26500. private _muteButton;
  26501. private _hostElement;
  26502. /**
  26503. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26504. */
  26505. canUseWebAudio: boolean;
  26506. /**
  26507. * The master gain node defines the global audio volume of your audio engine.
  26508. */
  26509. masterGain: GainNode;
  26510. /**
  26511. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26512. * @ignoreNaming
  26513. */
  26514. WarnedWebAudioUnsupported: boolean;
  26515. /**
  26516. * Gets whether or not mp3 are supported by your browser.
  26517. */
  26518. isMP3supported: boolean;
  26519. /**
  26520. * Gets whether or not ogg are supported by your browser.
  26521. */
  26522. isOGGsupported: boolean;
  26523. /**
  26524. * Gets whether audio has been unlocked on the device.
  26525. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26526. * a user interaction has happened.
  26527. */
  26528. unlocked: boolean;
  26529. /**
  26530. * Defines if the audio engine relies on a custom unlocked button.
  26531. * In this case, the embedded button will not be displayed.
  26532. */
  26533. useCustomUnlockedButton: boolean;
  26534. /**
  26535. * Event raised when audio has been unlocked on the browser.
  26536. */
  26537. onAudioUnlockedObservable: Observable<AudioEngine>;
  26538. /**
  26539. * Event raised when audio has been locked on the browser.
  26540. */
  26541. onAudioLockedObservable: Observable<AudioEngine>;
  26542. /**
  26543. * Gets the current AudioContext if available.
  26544. */
  26545. readonly audioContext: Nullable<AudioContext>;
  26546. private _connectedAnalyser;
  26547. /**
  26548. * Instantiates a new audio engine.
  26549. *
  26550. * There should be only one per page as some browsers restrict the number
  26551. * of audio contexts you can create.
  26552. * @param hostElement defines the host element where to display the mute icon if necessary
  26553. */
  26554. constructor(hostElement?: Nullable<HTMLElement>);
  26555. /**
  26556. * Flags the audio engine in Locked state.
  26557. * This happens due to new browser policies preventing audio to autoplay.
  26558. */
  26559. lock(): void;
  26560. /**
  26561. * Unlocks the audio engine once a user action has been done on the dom.
  26562. * This is helpful to resume play once browser policies have been satisfied.
  26563. */
  26564. unlock(): void;
  26565. private _resumeAudioContext;
  26566. private _initializeAudioContext;
  26567. private _tryToRun;
  26568. private _triggerRunningState;
  26569. private _triggerSuspendedState;
  26570. private _displayMuteButton;
  26571. private _moveButtonToTopLeft;
  26572. private _onResize;
  26573. private _hideMuteButton;
  26574. /**
  26575. * Destroy and release the resources associated with the audio ccontext.
  26576. */
  26577. dispose(): void;
  26578. /**
  26579. * Gets the global volume sets on the master gain.
  26580. * @returns the global volume if set or -1 otherwise
  26581. */
  26582. getGlobalVolume(): number;
  26583. /**
  26584. * Sets the global volume of your experience (sets on the master gain).
  26585. * @param newVolume Defines the new global volume of the application
  26586. */
  26587. setGlobalVolume(newVolume: number): void;
  26588. /**
  26589. * Connect the audio engine to an audio analyser allowing some amazing
  26590. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26592. * @param analyser The analyser to connect to the engine
  26593. */
  26594. connectToAnalyser(analyser: Analyser): void;
  26595. }
  26596. }
  26597. declare module "babylonjs/Loading/loadingScreen" {
  26598. /**
  26599. * Interface used to present a loading screen while loading a scene
  26600. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26601. */
  26602. export interface ILoadingScreen {
  26603. /**
  26604. * Function called to display the loading screen
  26605. */
  26606. displayLoadingUI: () => void;
  26607. /**
  26608. * Function called to hide the loading screen
  26609. */
  26610. hideLoadingUI: () => void;
  26611. /**
  26612. * Gets or sets the color to use for the background
  26613. */
  26614. loadingUIBackgroundColor: string;
  26615. /**
  26616. * Gets or sets the text to display while loading
  26617. */
  26618. loadingUIText: string;
  26619. }
  26620. /**
  26621. * Class used for the default loading screen
  26622. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26623. */
  26624. export class DefaultLoadingScreen implements ILoadingScreen {
  26625. private _renderingCanvas;
  26626. private _loadingText;
  26627. private _loadingDivBackgroundColor;
  26628. private _loadingDiv;
  26629. private _loadingTextDiv;
  26630. /**
  26631. * Creates a new default loading screen
  26632. * @param _renderingCanvas defines the canvas used to render the scene
  26633. * @param _loadingText defines the default text to display
  26634. * @param _loadingDivBackgroundColor defines the default background color
  26635. */
  26636. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26637. /**
  26638. * Function called to display the loading screen
  26639. */
  26640. displayLoadingUI(): void;
  26641. /**
  26642. * Function called to hide the loading screen
  26643. */
  26644. hideLoadingUI(): void;
  26645. /**
  26646. * Gets or sets the text to display while loading
  26647. */
  26648. loadingUIText: string;
  26649. /**
  26650. * Gets or sets the color to use for the background
  26651. */
  26652. loadingUIBackgroundColor: string;
  26653. private _resizeLoadingUI;
  26654. }
  26655. }
  26656. declare module "babylonjs/Materials/Textures/videoTexture" {
  26657. import { Observable } from "babylonjs/Misc/observable";
  26658. import { Nullable } from "babylonjs/types";
  26659. import { Scene } from "babylonjs/scene";
  26660. import { Texture } from "babylonjs/Materials/Textures/texture";
  26661. /**
  26662. * Settings for finer control over video usage
  26663. */
  26664. export interface VideoTextureSettings {
  26665. /**
  26666. * Applies `autoplay` to video, if specified
  26667. */
  26668. autoPlay?: boolean;
  26669. /**
  26670. * Applies `loop` to video, if specified
  26671. */
  26672. loop?: boolean;
  26673. /**
  26674. * Automatically updates internal texture from video at every frame in the render loop
  26675. */
  26676. autoUpdateTexture: boolean;
  26677. /**
  26678. * Image src displayed during the video loading or until the user interacts with the video.
  26679. */
  26680. poster?: string;
  26681. }
  26682. /**
  26683. * If you want to display a video in your scene, this is the special texture for that.
  26684. * This special texture works similar to other textures, with the exception of a few parameters.
  26685. * @see https://doc.babylonjs.com/how_to/video_texture
  26686. */
  26687. export class VideoTexture extends Texture {
  26688. /**
  26689. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26690. */
  26691. readonly autoUpdateTexture: boolean;
  26692. /**
  26693. * The video instance used by the texture internally
  26694. */
  26695. readonly video: HTMLVideoElement;
  26696. private _onUserActionRequestedObservable;
  26697. /**
  26698. * Event triggerd when a dom action is required by the user to play the video.
  26699. * This happens due to recent changes in browser policies preventing video to auto start.
  26700. */
  26701. readonly onUserActionRequestedObservable: Observable<Texture>;
  26702. private _generateMipMaps;
  26703. private _engine;
  26704. private _stillImageCaptured;
  26705. private _displayingPosterTexture;
  26706. private _settings;
  26707. private _createInternalTextureOnEvent;
  26708. /**
  26709. * Creates a video texture.
  26710. * If you want to display a video in your scene, this is the special texture for that.
  26711. * This special texture works similar to other textures, with the exception of a few parameters.
  26712. * @see https://doc.babylonjs.com/how_to/video_texture
  26713. * @param name optional name, will detect from video source, if not defined
  26714. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26715. * @param scene is obviously the current scene.
  26716. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26717. * @param invertY is false by default but can be used to invert video on Y axis
  26718. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26719. * @param settings allows finer control over video usage
  26720. */
  26721. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26722. private _getName;
  26723. private _getVideo;
  26724. private _createInternalTexture;
  26725. private reset;
  26726. /**
  26727. * @hidden Internal method to initiate `update`.
  26728. */
  26729. _rebuild(): void;
  26730. /**
  26731. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26732. */
  26733. update(): void;
  26734. /**
  26735. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26736. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26737. */
  26738. updateTexture(isVisible: boolean): void;
  26739. protected _updateInternalTexture: () => void;
  26740. /**
  26741. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26742. * @param url New url.
  26743. */
  26744. updateURL(url: string): void;
  26745. /**
  26746. * Dispose the texture and release its associated resources.
  26747. */
  26748. dispose(): void;
  26749. /**
  26750. * Creates a video texture straight from a stream.
  26751. * @param scene Define the scene the texture should be created in
  26752. * @param stream Define the stream the texture should be created from
  26753. * @returns The created video texture as a promise
  26754. */
  26755. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26756. /**
  26757. * Creates a video texture straight from your WebCam video feed.
  26758. * @param scene Define the scene the texture should be created in
  26759. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26760. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26761. * @returns The created video texture as a promise
  26762. */
  26763. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26764. minWidth: number;
  26765. maxWidth: number;
  26766. minHeight: number;
  26767. maxHeight: number;
  26768. deviceId: string;
  26769. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26770. /**
  26771. * Creates a video texture straight from your WebCam video feed.
  26772. * @param scene Define the scene the texture should be created in
  26773. * @param onReady Define a callback to triggered once the texture will be ready
  26774. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26775. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26776. */
  26777. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26778. minWidth: number;
  26779. maxWidth: number;
  26780. minHeight: number;
  26781. maxHeight: number;
  26782. deviceId: string;
  26783. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26784. }
  26785. }
  26786. declare module "babylonjs/Engines/engine" {
  26787. import { Observable } from "babylonjs/Misc/observable";
  26788. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26789. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26790. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26791. import { Camera } from "babylonjs/Cameras/camera";
  26792. import { Scene } from "babylonjs/scene";
  26793. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26794. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26795. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26796. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26797. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26798. import { Material } from "babylonjs/Materials/material";
  26799. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26802. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26803. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26804. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26805. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26806. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26807. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26808. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26809. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26810. /**
  26811. * Interface for attribute information associated with buffer instanciation
  26812. */
  26813. export class InstancingAttributeInfo {
  26814. /**
  26815. * Index/offset of the attribute in the vertex shader
  26816. */
  26817. index: number;
  26818. /**
  26819. * size of the attribute, 1, 2, 3 or 4
  26820. */
  26821. attributeSize: number;
  26822. /**
  26823. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26824. * default is FLOAT
  26825. */
  26826. attribyteType: number;
  26827. /**
  26828. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26829. */
  26830. normalized: boolean;
  26831. /**
  26832. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26833. */
  26834. offset: number;
  26835. /**
  26836. * Name of the GLSL attribute, for debugging purpose only
  26837. */
  26838. attributeName: string;
  26839. }
  26840. /**
  26841. * Define options used to create a depth texture
  26842. */
  26843. export class DepthTextureCreationOptions {
  26844. /** Specifies whether or not a stencil should be allocated in the texture */
  26845. generateStencil?: boolean;
  26846. /** Specifies whether or not bilinear filtering is enable on the texture */
  26847. bilinearFiltering?: boolean;
  26848. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26849. comparisonFunction?: number;
  26850. /** Specifies if the created texture is a cube texture */
  26851. isCube?: boolean;
  26852. }
  26853. /**
  26854. * Class used to describe the capabilities of the engine relatively to the current browser
  26855. */
  26856. export class EngineCapabilities {
  26857. /** Maximum textures units per fragment shader */
  26858. maxTexturesImageUnits: number;
  26859. /** Maximum texture units per vertex shader */
  26860. maxVertexTextureImageUnits: number;
  26861. /** Maximum textures units in the entire pipeline */
  26862. maxCombinedTexturesImageUnits: number;
  26863. /** Maximum texture size */
  26864. maxTextureSize: number;
  26865. /** Maximum cube texture size */
  26866. maxCubemapTextureSize: number;
  26867. /** Maximum render texture size */
  26868. maxRenderTextureSize: number;
  26869. /** Maximum number of vertex attributes */
  26870. maxVertexAttribs: number;
  26871. /** Maximum number of varyings */
  26872. maxVaryingVectors: number;
  26873. /** Maximum number of uniforms per vertex shader */
  26874. maxVertexUniformVectors: number;
  26875. /** Maximum number of uniforms per fragment shader */
  26876. maxFragmentUniformVectors: number;
  26877. /** Defines if standard derivates (dx/dy) are supported */
  26878. standardDerivatives: boolean;
  26879. /** Defines if s3tc texture compression is supported */
  26880. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26881. /** Defines if pvrtc texture compression is supported */
  26882. pvrtc: any;
  26883. /** Defines if etc1 texture compression is supported */
  26884. etc1: any;
  26885. /** Defines if etc2 texture compression is supported */
  26886. etc2: any;
  26887. /** Defines if astc texture compression is supported */
  26888. astc: any;
  26889. /** Defines if float textures are supported */
  26890. textureFloat: boolean;
  26891. /** Defines if vertex array objects are supported */
  26892. vertexArrayObject: boolean;
  26893. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26894. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26895. /** Gets the maximum level of anisotropy supported */
  26896. maxAnisotropy: number;
  26897. /** Defines if instancing is supported */
  26898. instancedArrays: boolean;
  26899. /** Defines if 32 bits indices are supported */
  26900. uintIndices: boolean;
  26901. /** Defines if high precision shaders are supported */
  26902. highPrecisionShaderSupported: boolean;
  26903. /** Defines if depth reading in the fragment shader is supported */
  26904. fragmentDepthSupported: boolean;
  26905. /** Defines if float texture linear filtering is supported*/
  26906. textureFloatLinearFiltering: boolean;
  26907. /** Defines if rendering to float textures is supported */
  26908. textureFloatRender: boolean;
  26909. /** Defines if half float textures are supported*/
  26910. textureHalfFloat: boolean;
  26911. /** Defines if half float texture linear filtering is supported*/
  26912. textureHalfFloatLinearFiltering: boolean;
  26913. /** Defines if rendering to half float textures is supported */
  26914. textureHalfFloatRender: boolean;
  26915. /** Defines if textureLOD shader command is supported */
  26916. textureLOD: boolean;
  26917. /** Defines if draw buffers extension is supported */
  26918. drawBuffersExtension: boolean;
  26919. /** Defines if depth textures are supported */
  26920. depthTextureExtension: boolean;
  26921. /** Defines if float color buffer are supported */
  26922. colorBufferFloat: boolean;
  26923. /** Gets disjoint timer query extension (null if not supported) */
  26924. timerQuery: EXT_disjoint_timer_query;
  26925. /** Defines if timestamp can be used with timer query */
  26926. canUseTimestampForTimerQuery: boolean;
  26927. /** Function used to let the system compiles shaders in background */
  26928. parallelShaderCompile: {
  26929. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26930. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26931. COMPLETION_STATUS_KHR: number;
  26932. };
  26933. }
  26934. /** Interface defining initialization parameters for Engine class */
  26935. export interface EngineOptions extends WebGLContextAttributes {
  26936. /**
  26937. * Defines if the engine should no exceed a specified device ratio
  26938. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26939. */
  26940. limitDeviceRatio?: number;
  26941. /**
  26942. * Defines if webvr should be enabled automatically
  26943. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26944. */
  26945. autoEnableWebVR?: boolean;
  26946. /**
  26947. * Defines if webgl2 should be turned off even if supported
  26948. * @see http://doc.babylonjs.com/features/webgl2
  26949. */
  26950. disableWebGL2Support?: boolean;
  26951. /**
  26952. * Defines if webaudio should be initialized as well
  26953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26954. */
  26955. audioEngine?: boolean;
  26956. /**
  26957. * Defines if animations should run using a deterministic lock step
  26958. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26959. */
  26960. deterministicLockstep?: boolean;
  26961. /** Defines the maximum steps to use with deterministic lock step mode */
  26962. lockstepMaxSteps?: number;
  26963. /**
  26964. * Defines that engine should ignore context lost events
  26965. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26966. */
  26967. doNotHandleContextLost?: boolean;
  26968. /**
  26969. * Defines that engine should ignore modifying touch action attribute and style
  26970. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26971. */
  26972. doNotHandleTouchAction?: boolean;
  26973. }
  26974. /**
  26975. * Defines the interface used by display changed events
  26976. */
  26977. export interface IDisplayChangedEventArgs {
  26978. /** Gets the vrDisplay object (if any) */
  26979. vrDisplay: Nullable<any>;
  26980. /** Gets a boolean indicating if webVR is supported */
  26981. vrSupported: boolean;
  26982. }
  26983. /**
  26984. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26985. */
  26986. export class Engine {
  26987. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26988. static ExceptionList: ({
  26989. key: string;
  26990. capture: string;
  26991. captureConstraint: number;
  26992. targets: string[];
  26993. } | {
  26994. key: string;
  26995. capture: null;
  26996. captureConstraint: null;
  26997. targets: string[];
  26998. })[];
  26999. /** Gets the list of created engines */
  27000. static readonly Instances: Engine[];
  27001. /**
  27002. * Gets the latest created engine
  27003. */
  27004. static readonly LastCreatedEngine: Nullable<Engine>;
  27005. /**
  27006. * Gets the latest created scene
  27007. */
  27008. static readonly LastCreatedScene: Nullable<Scene>;
  27009. /**
  27010. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27011. * @param flag defines which part of the materials must be marked as dirty
  27012. * @param predicate defines a predicate used to filter which materials should be affected
  27013. */
  27014. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27015. /**
  27016. * Hidden
  27017. */
  27018. static _TextureLoaders: IInternalTextureLoader[];
  27019. /** Defines that alpha blending is disabled */
  27020. static readonly ALPHA_DISABLE: number;
  27021. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27022. static readonly ALPHA_ADD: number;
  27023. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27024. static readonly ALPHA_COMBINE: number;
  27025. /** Defines that alpha blending to DEST - SRC * DEST */
  27026. static readonly ALPHA_SUBTRACT: number;
  27027. /** Defines that alpha blending to SRC * DEST */
  27028. static readonly ALPHA_MULTIPLY: number;
  27029. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27030. static readonly ALPHA_MAXIMIZED: number;
  27031. /** Defines that alpha blending to SRC + DEST */
  27032. static readonly ALPHA_ONEONE: number;
  27033. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27034. static readonly ALPHA_PREMULTIPLIED: number;
  27035. /**
  27036. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27037. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27038. */
  27039. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27040. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27041. static readonly ALPHA_INTERPOLATE: number;
  27042. /**
  27043. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27044. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27045. */
  27046. static readonly ALPHA_SCREENMODE: number;
  27047. /** Defines that the ressource is not delayed*/
  27048. static readonly DELAYLOADSTATE_NONE: number;
  27049. /** Defines that the ressource was successfully delay loaded */
  27050. static readonly DELAYLOADSTATE_LOADED: number;
  27051. /** Defines that the ressource is currently delay loading */
  27052. static readonly DELAYLOADSTATE_LOADING: number;
  27053. /** Defines that the ressource is delayed and has not started loading */
  27054. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27055. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27056. static readonly NEVER: number;
  27057. /** 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 */
  27058. static readonly ALWAYS: number;
  27059. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27060. static readonly LESS: number;
  27061. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27062. static readonly EQUAL: number;
  27063. /** 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 */
  27064. static readonly LEQUAL: number;
  27065. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27066. static readonly GREATER: number;
  27067. /** 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 */
  27068. static readonly GEQUAL: number;
  27069. /** 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 */
  27070. static readonly NOTEQUAL: number;
  27071. /** Passed to stencilOperation to specify that stencil value must be kept */
  27072. static readonly KEEP: number;
  27073. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27074. static readonly REPLACE: number;
  27075. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27076. static readonly INCR: number;
  27077. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27078. static readonly DECR: number;
  27079. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27080. static readonly INVERT: number;
  27081. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27082. static readonly INCR_WRAP: number;
  27083. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27084. static readonly DECR_WRAP: number;
  27085. /** Texture is not repeating outside of 0..1 UVs */
  27086. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27087. /** Texture is repeating outside of 0..1 UVs */
  27088. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27089. /** Texture is repeating and mirrored */
  27090. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27091. /** ALPHA */
  27092. static readonly TEXTUREFORMAT_ALPHA: number;
  27093. /** LUMINANCE */
  27094. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27095. /** LUMINANCE_ALPHA */
  27096. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27097. /** RGB */
  27098. static readonly TEXTUREFORMAT_RGB: number;
  27099. /** RGBA */
  27100. static readonly TEXTUREFORMAT_RGBA: number;
  27101. /** RED */
  27102. static readonly TEXTUREFORMAT_RED: number;
  27103. /** RED (2nd reference) */
  27104. static readonly TEXTUREFORMAT_R: number;
  27105. /** RG */
  27106. static readonly TEXTUREFORMAT_RG: number;
  27107. /** RED_INTEGER */
  27108. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27109. /** RED_INTEGER (2nd reference) */
  27110. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27111. /** RG_INTEGER */
  27112. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27113. /** RGB_INTEGER */
  27114. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27115. /** RGBA_INTEGER */
  27116. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27117. /** UNSIGNED_BYTE */
  27118. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27119. /** UNSIGNED_BYTE (2nd reference) */
  27120. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27121. /** FLOAT */
  27122. static readonly TEXTURETYPE_FLOAT: number;
  27123. /** HALF_FLOAT */
  27124. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27125. /** BYTE */
  27126. static readonly TEXTURETYPE_BYTE: number;
  27127. /** SHORT */
  27128. static readonly TEXTURETYPE_SHORT: number;
  27129. /** UNSIGNED_SHORT */
  27130. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27131. /** INT */
  27132. static readonly TEXTURETYPE_INT: number;
  27133. /** UNSIGNED_INT */
  27134. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27135. /** UNSIGNED_SHORT_4_4_4_4 */
  27136. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27137. /** UNSIGNED_SHORT_5_5_5_1 */
  27138. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27139. /** UNSIGNED_SHORT_5_6_5 */
  27140. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27141. /** UNSIGNED_INT_2_10_10_10_REV */
  27142. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27143. /** UNSIGNED_INT_24_8 */
  27144. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27145. /** UNSIGNED_INT_10F_11F_11F_REV */
  27146. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27147. /** UNSIGNED_INT_5_9_9_9_REV */
  27148. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27149. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27150. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27151. /** nearest is mag = nearest and min = nearest and mip = linear */
  27152. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27154. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27155. /** Trilinear is mag = linear and min = linear and mip = linear */
  27156. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27157. /** nearest is mag = nearest and min = nearest and mip = linear */
  27158. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27159. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27160. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27161. /** Trilinear is mag = linear and min = linear and mip = linear */
  27162. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27163. /** mag = nearest and min = nearest and mip = nearest */
  27164. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27165. /** mag = nearest and min = linear and mip = nearest */
  27166. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27167. /** mag = nearest and min = linear and mip = linear */
  27168. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27169. /** mag = nearest and min = linear and mip = none */
  27170. static readonly TEXTURE_NEAREST_LINEAR: number;
  27171. /** mag = nearest and min = nearest and mip = none */
  27172. static readonly TEXTURE_NEAREST_NEAREST: number;
  27173. /** mag = linear and min = nearest and mip = nearest */
  27174. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27175. /** mag = linear and min = nearest and mip = linear */
  27176. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27177. /** mag = linear and min = linear and mip = none */
  27178. static readonly TEXTURE_LINEAR_LINEAR: number;
  27179. /** mag = linear and min = nearest and mip = none */
  27180. static readonly TEXTURE_LINEAR_NEAREST: number;
  27181. /** Explicit coordinates mode */
  27182. static readonly TEXTURE_EXPLICIT_MODE: number;
  27183. /** Spherical coordinates mode */
  27184. static readonly TEXTURE_SPHERICAL_MODE: number;
  27185. /** Planar coordinates mode */
  27186. static readonly TEXTURE_PLANAR_MODE: number;
  27187. /** Cubic coordinates mode */
  27188. static readonly TEXTURE_CUBIC_MODE: number;
  27189. /** Projection coordinates mode */
  27190. static readonly TEXTURE_PROJECTION_MODE: number;
  27191. /** Skybox coordinates mode */
  27192. static readonly TEXTURE_SKYBOX_MODE: number;
  27193. /** Inverse Cubic coordinates mode */
  27194. static readonly TEXTURE_INVCUBIC_MODE: number;
  27195. /** Equirectangular coordinates mode */
  27196. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27197. /** Equirectangular Fixed coordinates mode */
  27198. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27199. /** Equirectangular Fixed Mirrored coordinates mode */
  27200. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27201. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27202. static readonly SCALEMODE_FLOOR: number;
  27203. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27204. static readonly SCALEMODE_NEAREST: number;
  27205. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27206. static readonly SCALEMODE_CEILING: number;
  27207. /**
  27208. * Returns the current version of the framework
  27209. */
  27210. static readonly Version: string;
  27211. /**
  27212. * Returns a string describing the current engine
  27213. */
  27214. readonly description: string;
  27215. /**
  27216. * Gets or sets the epsilon value used by collision engine
  27217. */
  27218. static CollisionsEpsilon: number;
  27219. /**
  27220. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27221. */
  27222. static ShadersRepository: string;
  27223. /**
  27224. * Method called to create the default loading screen.
  27225. * This can be overriden in your own app.
  27226. * @param canvas The rendering canvas element
  27227. * @returns The loading screen
  27228. */
  27229. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27230. /**
  27231. * Method called to create the default rescale post process on each engine.
  27232. */
  27233. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27234. /**
  27235. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27236. */
  27237. forcePOTTextures: boolean;
  27238. /**
  27239. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27240. */
  27241. isFullscreen: boolean;
  27242. /**
  27243. * Gets a boolean indicating if the pointer is currently locked
  27244. */
  27245. isPointerLock: boolean;
  27246. /**
  27247. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27248. */
  27249. cullBackFaces: boolean;
  27250. /**
  27251. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27252. */
  27253. renderEvenInBackground: boolean;
  27254. /**
  27255. * Gets or sets a boolean indicating that cache can be kept between frames
  27256. */
  27257. preventCacheWipeBetweenFrames: boolean;
  27258. /**
  27259. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27260. **/
  27261. enableOfflineSupport: boolean;
  27262. /**
  27263. * 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)
  27264. **/
  27265. disableManifestCheck: boolean;
  27266. /**
  27267. * Gets the list of created scenes
  27268. */
  27269. scenes: Scene[];
  27270. /**
  27271. * Event raised when a new scene is created
  27272. */
  27273. onNewSceneAddedObservable: Observable<Scene>;
  27274. /**
  27275. * Gets the list of created postprocesses
  27276. */
  27277. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27278. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27279. validateShaderPrograms: boolean;
  27280. /**
  27281. * Observable event triggered each time the rendering canvas is resized
  27282. */
  27283. onResizeObservable: Observable<Engine>;
  27284. /**
  27285. * Observable event triggered each time the canvas loses focus
  27286. */
  27287. onCanvasBlurObservable: Observable<Engine>;
  27288. /**
  27289. * Observable event triggered each time the canvas gains focus
  27290. */
  27291. onCanvasFocusObservable: Observable<Engine>;
  27292. /**
  27293. * Observable event triggered each time the canvas receives pointerout event
  27294. */
  27295. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27296. /**
  27297. * Observable event triggered before each texture is initialized
  27298. */
  27299. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27300. private _vrDisplay;
  27301. private _vrSupported;
  27302. private _oldSize;
  27303. private _oldHardwareScaleFactor;
  27304. private _vrExclusivePointerMode;
  27305. private _webVRInitPromise;
  27306. /**
  27307. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27308. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27309. */
  27310. readonly isInVRExclusivePointerMode: boolean;
  27311. /**
  27312. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27313. */
  27314. disableUniformBuffers: boolean;
  27315. /** @hidden */
  27316. _uniformBuffers: UniformBuffer[];
  27317. /**
  27318. * Gets a boolean indicating that the engine supports uniform buffers
  27319. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27320. */
  27321. readonly supportsUniformBuffers: boolean;
  27322. /**
  27323. * Observable raised when the engine begins a new frame
  27324. */
  27325. onBeginFrameObservable: Observable<Engine>;
  27326. /**
  27327. * If set, will be used to request the next animation frame for the render loop
  27328. */
  27329. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27330. /**
  27331. * Observable raised when the engine ends the current frame
  27332. */
  27333. onEndFrameObservable: Observable<Engine>;
  27334. /**
  27335. * Observable raised when the engine is about to compile a shader
  27336. */
  27337. onBeforeShaderCompilationObservable: Observable<Engine>;
  27338. /**
  27339. * Observable raised when the engine has jsut compiled a shader
  27340. */
  27341. onAfterShaderCompilationObservable: Observable<Engine>;
  27342. /** @hidden */
  27343. _gl: WebGLRenderingContext;
  27344. private _renderingCanvas;
  27345. private _windowIsBackground;
  27346. private _webGLVersion;
  27347. /**
  27348. * Gets a boolean indicating that only power of 2 textures are supported
  27349. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27350. */
  27351. readonly needPOTTextures: boolean;
  27352. /** @hidden */
  27353. _badOS: boolean;
  27354. /** @hidden */
  27355. _badDesktopOS: boolean;
  27356. /**
  27357. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27358. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27359. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27360. */
  27361. disableTextureBindingOptimization: boolean;
  27362. /**
  27363. * Gets the audio engine
  27364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27365. * @ignorenaming
  27366. */
  27367. static audioEngine: IAudioEngine;
  27368. /**
  27369. * Default AudioEngine factory responsible of creating the Audio Engine.
  27370. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27371. */
  27372. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27373. /**
  27374. * Default offline support factory responsible of creating a tool used to store data locally.
  27375. * By default, this will create a Database object if the workload has been embedded.
  27376. */
  27377. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27378. private _onFocus;
  27379. private _onBlur;
  27380. private _onCanvasPointerOut;
  27381. private _onCanvasBlur;
  27382. private _onCanvasFocus;
  27383. private _onFullscreenChange;
  27384. private _onPointerLockChange;
  27385. private _onVRDisplayPointerRestricted;
  27386. private _onVRDisplayPointerUnrestricted;
  27387. private _onVrDisplayConnect;
  27388. private _onVrDisplayDisconnect;
  27389. private _onVrDisplayPresentChange;
  27390. /**
  27391. * Observable signaled when VR display mode changes
  27392. */
  27393. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27394. /**
  27395. * Observable signaled when VR request present is complete
  27396. */
  27397. onVRRequestPresentComplete: Observable<boolean>;
  27398. /**
  27399. * Observable signaled when VR request present starts
  27400. */
  27401. onVRRequestPresentStart: Observable<Engine>;
  27402. private _hardwareScalingLevel;
  27403. /** @hidden */
  27404. protected _caps: EngineCapabilities;
  27405. private _pointerLockRequested;
  27406. private _isStencilEnable;
  27407. private _colorWrite;
  27408. private _loadingScreen;
  27409. /** @hidden */
  27410. _drawCalls: PerfCounter;
  27411. /** @hidden */
  27412. _textureCollisions: PerfCounter;
  27413. private _glVersion;
  27414. private _glRenderer;
  27415. private _glVendor;
  27416. private _videoTextureSupported;
  27417. private _renderingQueueLaunched;
  27418. private _activeRenderLoops;
  27419. private _deterministicLockstep;
  27420. private _lockstepMaxSteps;
  27421. /**
  27422. * Observable signaled when a context lost event is raised
  27423. */
  27424. onContextLostObservable: Observable<Engine>;
  27425. /**
  27426. * Observable signaled when a context restored event is raised
  27427. */
  27428. onContextRestoredObservable: Observable<Engine>;
  27429. private _onContextLost;
  27430. private _onContextRestored;
  27431. private _contextWasLost;
  27432. private _doNotHandleContextLost;
  27433. /**
  27434. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27436. */
  27437. doNotHandleContextLost: boolean;
  27438. private _performanceMonitor;
  27439. private _fps;
  27440. private _deltaTime;
  27441. /**
  27442. * Turn this value on if you want to pause FPS computation when in background
  27443. */
  27444. disablePerformanceMonitorInBackground: boolean;
  27445. /**
  27446. * Gets the performance monitor attached to this engine
  27447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27448. */
  27449. readonly performanceMonitor: PerformanceMonitor;
  27450. /** @hidden */
  27451. protected _depthCullingState: _DepthCullingState;
  27452. /** @hidden */
  27453. protected _stencilState: _StencilState;
  27454. /** @hidden */
  27455. protected _alphaState: _AlphaState;
  27456. /** @hidden */
  27457. protected _alphaMode: number;
  27458. protected _internalTexturesCache: InternalTexture[];
  27459. /** @hidden */
  27460. protected _activeChannel: number;
  27461. private _currentTextureChannel;
  27462. /** @hidden */
  27463. protected _boundTexturesCache: {
  27464. [key: string]: Nullable<InternalTexture>;
  27465. };
  27466. /** @hidden */
  27467. protected _currentEffect: Nullable<Effect>;
  27468. /** @hidden */
  27469. protected _currentProgram: Nullable<WebGLProgram>;
  27470. private _compiledEffects;
  27471. private _vertexAttribArraysEnabled;
  27472. /** @hidden */
  27473. protected _cachedViewport: Nullable<Viewport>;
  27474. private _cachedVertexArrayObject;
  27475. /** @hidden */
  27476. protected _cachedVertexBuffers: any;
  27477. /** @hidden */
  27478. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27479. /** @hidden */
  27480. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27481. /** @hidden */
  27482. protected _currentRenderTarget: Nullable<InternalTexture>;
  27483. private _uintIndicesCurrentlySet;
  27484. private _currentBoundBuffer;
  27485. /** @hidden */
  27486. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27487. private _currentBufferPointers;
  27488. private _currentInstanceLocations;
  27489. private _currentInstanceBuffers;
  27490. private _textureUnits;
  27491. private _firstBoundInternalTextureTracker;
  27492. private _lastBoundInternalTextureTracker;
  27493. private _workingCanvas;
  27494. private _workingContext;
  27495. private _rescalePostProcess;
  27496. private _dummyFramebuffer;
  27497. private _externalData;
  27498. private _bindedRenderFunction;
  27499. private _vaoRecordInProgress;
  27500. private _mustWipeVertexAttributes;
  27501. private _emptyTexture;
  27502. private _emptyCubeTexture;
  27503. private _emptyTexture3D;
  27504. /** @hidden */
  27505. _frameHandler: number;
  27506. private _nextFreeTextureSlots;
  27507. private _maxSimultaneousTextures;
  27508. private _activeRequests;
  27509. private _texturesSupported;
  27510. private _textureFormatInUse;
  27511. /**
  27512. * Gets the list of texture formats supported
  27513. */
  27514. readonly texturesSupported: Array<string>;
  27515. /**
  27516. * Gets the list of texture formats in use
  27517. */
  27518. readonly textureFormatInUse: Nullable<string>;
  27519. /**
  27520. * Gets the current viewport
  27521. */
  27522. readonly currentViewport: Nullable<Viewport>;
  27523. /**
  27524. * Gets the default empty texture
  27525. */
  27526. readonly emptyTexture: InternalTexture;
  27527. /**
  27528. * Gets the default empty 3D texture
  27529. */
  27530. readonly emptyTexture3D: InternalTexture;
  27531. /**
  27532. * Gets the default empty cube texture
  27533. */
  27534. readonly emptyCubeTexture: InternalTexture;
  27535. /**
  27536. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27537. */
  27538. readonly premultipliedAlpha: boolean;
  27539. /**
  27540. * Creates a new engine
  27541. * @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
  27542. * @param antialias defines enable antialiasing (default: false)
  27543. * @param options defines further options to be sent to the getContext() function
  27544. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27545. */
  27546. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27547. private _disableTouchAction;
  27548. private _rebuildInternalTextures;
  27549. private _rebuildEffects;
  27550. /**
  27551. * Gets a boolean indicating if all created effects are ready
  27552. * @returns true if all effects are ready
  27553. */
  27554. areAllEffectsReady(): boolean;
  27555. private _rebuildBuffers;
  27556. private _initGLContext;
  27557. /**
  27558. * Gets version of the current webGL context
  27559. */
  27560. readonly webGLVersion: number;
  27561. /**
  27562. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27563. */
  27564. readonly isStencilEnable: boolean;
  27565. private _prepareWorkingCanvas;
  27566. /**
  27567. * Reset the texture cache to empty state
  27568. */
  27569. resetTextureCache(): void;
  27570. /**
  27571. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27572. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27573. * @returns true if engine is in deterministic lock step mode
  27574. */
  27575. isDeterministicLockStep(): boolean;
  27576. /**
  27577. * Gets the max steps when engine is running in deterministic lock step
  27578. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27579. * @returns the max steps
  27580. */
  27581. getLockstepMaxSteps(): number;
  27582. /**
  27583. * Gets an object containing information about the current webGL context
  27584. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27585. */
  27586. getGlInfo(): {
  27587. vendor: string;
  27588. renderer: string;
  27589. version: string;
  27590. };
  27591. /**
  27592. * Gets current aspect ratio
  27593. * @param camera defines the camera to use to get the aspect ratio
  27594. * @param useScreen defines if screen size must be used (or the current render target if any)
  27595. * @returns a number defining the aspect ratio
  27596. */
  27597. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27598. /**
  27599. * Gets current screen aspect ratio
  27600. * @returns a number defining the aspect ratio
  27601. */
  27602. getScreenAspectRatio(): number;
  27603. /**
  27604. * Gets the current render width
  27605. * @param useScreen defines if screen size must be used (or the current render target if any)
  27606. * @returns a number defining the current render width
  27607. */
  27608. getRenderWidth(useScreen?: boolean): number;
  27609. /**
  27610. * Gets the current render height
  27611. * @param useScreen defines if screen size must be used (or the current render target if any)
  27612. * @returns a number defining the current render height
  27613. */
  27614. getRenderHeight(useScreen?: boolean): number;
  27615. /**
  27616. * Gets the HTML canvas attached with the current webGL context
  27617. * @returns a HTML canvas
  27618. */
  27619. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27620. /**
  27621. * Gets the client rect of the HTML canvas attached with the current webGL context
  27622. * @returns a client rectanglee
  27623. */
  27624. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27625. /**
  27626. * Defines the hardware scaling level.
  27627. * By default the hardware scaling level is computed from the window device ratio.
  27628. * 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.
  27629. * @param level defines the level to use
  27630. */
  27631. setHardwareScalingLevel(level: number): void;
  27632. /**
  27633. * Gets the current hardware scaling level.
  27634. * By default the hardware scaling level is computed from the window device ratio.
  27635. * 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.
  27636. * @returns a number indicating the current hardware scaling level
  27637. */
  27638. getHardwareScalingLevel(): number;
  27639. /**
  27640. * Gets the list of loaded textures
  27641. * @returns an array containing all loaded textures
  27642. */
  27643. getLoadedTexturesCache(): InternalTexture[];
  27644. /**
  27645. * Gets the object containing all engine capabilities
  27646. * @returns the EngineCapabilities object
  27647. */
  27648. getCaps(): EngineCapabilities;
  27649. /**
  27650. * Gets the current depth function
  27651. * @returns a number defining the depth function
  27652. */
  27653. getDepthFunction(): Nullable<number>;
  27654. /**
  27655. * Sets the current depth function
  27656. * @param depthFunc defines the function to use
  27657. */
  27658. setDepthFunction(depthFunc: number): void;
  27659. /**
  27660. * Sets the current depth function to GREATER
  27661. */
  27662. setDepthFunctionToGreater(): void;
  27663. /**
  27664. * Sets the current depth function to GEQUAL
  27665. */
  27666. setDepthFunctionToGreaterOrEqual(): void;
  27667. /**
  27668. * Sets the current depth function to LESS
  27669. */
  27670. setDepthFunctionToLess(): void;
  27671. /**
  27672. * Sets the current depth function to LEQUAL
  27673. */
  27674. setDepthFunctionToLessOrEqual(): void;
  27675. /**
  27676. * Gets a boolean indicating if stencil buffer is enabled
  27677. * @returns the current stencil buffer state
  27678. */
  27679. getStencilBuffer(): boolean;
  27680. /**
  27681. * Enable or disable the stencil buffer
  27682. * @param enable defines if the stencil buffer must be enabled or disabled
  27683. */
  27684. setStencilBuffer(enable: boolean): void;
  27685. /**
  27686. * Gets the current stencil mask
  27687. * @returns a number defining the new stencil mask to use
  27688. */
  27689. getStencilMask(): number;
  27690. /**
  27691. * Sets the current stencil mask
  27692. * @param mask defines the new stencil mask to use
  27693. */
  27694. setStencilMask(mask: number): void;
  27695. /**
  27696. * Gets the current stencil function
  27697. * @returns a number defining the stencil function to use
  27698. */
  27699. getStencilFunction(): number;
  27700. /**
  27701. * Gets the current stencil reference value
  27702. * @returns a number defining the stencil reference value to use
  27703. */
  27704. getStencilFunctionReference(): number;
  27705. /**
  27706. * Gets the current stencil mask
  27707. * @returns a number defining the stencil mask to use
  27708. */
  27709. getStencilFunctionMask(): number;
  27710. /**
  27711. * Sets the current stencil function
  27712. * @param stencilFunc defines the new stencil function to use
  27713. */
  27714. setStencilFunction(stencilFunc: number): void;
  27715. /**
  27716. * Sets the current stencil reference
  27717. * @param reference defines the new stencil reference to use
  27718. */
  27719. setStencilFunctionReference(reference: number): void;
  27720. /**
  27721. * Sets the current stencil mask
  27722. * @param mask defines the new stencil mask to use
  27723. */
  27724. setStencilFunctionMask(mask: number): void;
  27725. /**
  27726. * Gets the current stencil operation when stencil fails
  27727. * @returns a number defining stencil operation to use when stencil fails
  27728. */
  27729. getStencilOperationFail(): number;
  27730. /**
  27731. * Gets the current stencil operation when depth fails
  27732. * @returns a number defining stencil operation to use when depth fails
  27733. */
  27734. getStencilOperationDepthFail(): number;
  27735. /**
  27736. * Gets the current stencil operation when stencil passes
  27737. * @returns a number defining stencil operation to use when stencil passes
  27738. */
  27739. getStencilOperationPass(): number;
  27740. /**
  27741. * Sets the stencil operation to use when stencil fails
  27742. * @param operation defines the stencil operation to use when stencil fails
  27743. */
  27744. setStencilOperationFail(operation: number): void;
  27745. /**
  27746. * Sets the stencil operation to use when depth fails
  27747. * @param operation defines the stencil operation to use when depth fails
  27748. */
  27749. setStencilOperationDepthFail(operation: number): void;
  27750. /**
  27751. * Sets the stencil operation to use when stencil passes
  27752. * @param operation defines the stencil operation to use when stencil passes
  27753. */
  27754. setStencilOperationPass(operation: number): void;
  27755. /**
  27756. * Sets a boolean indicating if the dithering state is enabled or disabled
  27757. * @param value defines the dithering state
  27758. */
  27759. setDitheringState(value: boolean): void;
  27760. /**
  27761. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27762. * @param value defines the rasterizer state
  27763. */
  27764. setRasterizerState(value: boolean): void;
  27765. /**
  27766. * stop executing a render loop function and remove it from the execution array
  27767. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27768. */
  27769. stopRenderLoop(renderFunction?: () => void): void;
  27770. /** @hidden */
  27771. _renderLoop(): void;
  27772. /**
  27773. * Register and execute a render loop. The engine can have more than one render function
  27774. * @param renderFunction defines the function to continuously execute
  27775. */
  27776. runRenderLoop(renderFunction: () => void): void;
  27777. /**
  27778. * Toggle full screen mode
  27779. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27780. */
  27781. switchFullscreen(requestPointerLock: boolean): void;
  27782. /**
  27783. * Enters full screen mode
  27784. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27785. */
  27786. enterFullscreen(requestPointerLock: boolean): void;
  27787. /**
  27788. * Exits full screen mode
  27789. */
  27790. exitFullscreen(): void;
  27791. /**
  27792. * Clear the current render buffer or the current render target (if any is set up)
  27793. * @param color defines the color to use
  27794. * @param backBuffer defines if the back buffer must be cleared
  27795. * @param depth defines if the depth buffer must be cleared
  27796. * @param stencil defines if the stencil buffer must be cleared
  27797. */
  27798. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27799. /**
  27800. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27801. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27802. * @param y defines the y-coordinate of the corner of the clear rectangle
  27803. * @param width defines the width of the clear rectangle
  27804. * @param height defines the height of the clear rectangle
  27805. * @param clearColor defines the clear color
  27806. */
  27807. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27808. /**
  27809. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27810. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27811. * @param y defines the y-coordinate of the corner of the clear rectangle
  27812. * @param width defines the width of the clear rectangle
  27813. * @param height defines the height of the clear rectangle
  27814. */
  27815. enableScissor(x: number, y: number, width: number, height: number): void;
  27816. /**
  27817. * Disable previously set scissor test rectangle
  27818. */
  27819. disableScissor(): void;
  27820. private _viewportCached;
  27821. /** @hidden */
  27822. _viewport(x: number, y: number, width: number, height: number): void;
  27823. /**
  27824. * Set the WebGL's viewport
  27825. * @param viewport defines the viewport element to be used
  27826. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27827. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27828. */
  27829. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27830. /**
  27831. * Directly set the WebGL Viewport
  27832. * @param x defines the x coordinate of the viewport (in screen space)
  27833. * @param y defines the y coordinate of the viewport (in screen space)
  27834. * @param width defines the width of the viewport (in screen space)
  27835. * @param height defines the height of the viewport (in screen space)
  27836. * @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
  27837. */
  27838. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27839. /**
  27840. * Begin a new frame
  27841. */
  27842. beginFrame(): void;
  27843. /**
  27844. * Enf the current frame
  27845. */
  27846. endFrame(): void;
  27847. /**
  27848. * Resize the view according to the canvas' size
  27849. */
  27850. resize(): void;
  27851. /**
  27852. * Force a specific size of the canvas
  27853. * @param width defines the new canvas' width
  27854. * @param height defines the new canvas' height
  27855. */
  27856. setSize(width: number, height: number): void;
  27857. /**
  27858. * Gets a boolean indicating if a webVR device was detected
  27859. * @returns true if a webVR device was detected
  27860. */
  27861. isVRDevicePresent(): boolean;
  27862. /**
  27863. * Gets the current webVR device
  27864. * @returns the current webVR device (or null)
  27865. */
  27866. getVRDevice(): any;
  27867. /**
  27868. * Initializes a webVR display and starts listening to display change events
  27869. * The onVRDisplayChangedObservable will be notified upon these changes
  27870. * @returns The onVRDisplayChangedObservable
  27871. */
  27872. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27873. /**
  27874. * Initializes a webVR display and starts listening to display change events
  27875. * The onVRDisplayChangedObservable will be notified upon these changes
  27876. * @returns A promise containing a VRDisplay and if vr is supported
  27877. */
  27878. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27879. /**
  27880. * Call this function to switch to webVR mode
  27881. * Will do nothing if webVR is not supported or if there is no webVR device
  27882. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27883. */
  27884. enableVR(): void;
  27885. /**
  27886. * Call this function to leave webVR mode
  27887. * Will do nothing if webVR is not supported or if there is no webVR device
  27888. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27889. */
  27890. disableVR(): void;
  27891. private _onVRFullScreenTriggered;
  27892. private _getVRDisplaysAsync;
  27893. /**
  27894. * Binds the frame buffer to the specified texture.
  27895. * @param texture The texture to render to or null for the default canvas
  27896. * @param faceIndex The face of the texture to render to in case of cube texture
  27897. * @param requiredWidth The width of the target to render to
  27898. * @param requiredHeight The height of the target to render to
  27899. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27900. * @param depthStencilTexture The depth stencil texture to use to render
  27901. * @param lodLevel defines le lod level to bind to the frame buffer
  27902. */
  27903. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27904. private bindUnboundFramebuffer;
  27905. /**
  27906. * Unbind the current render target texture from the webGL context
  27907. * @param texture defines the render target texture to unbind
  27908. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27909. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27910. */
  27911. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27912. /**
  27913. * Unbind a list of render target textures from the webGL context
  27914. * This is used only when drawBuffer extension or webGL2 are active
  27915. * @param textures defines the render target textures to unbind
  27916. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27917. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27918. */
  27919. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27920. /**
  27921. * Force the mipmap generation for the given render target texture
  27922. * @param texture defines the render target texture to use
  27923. */
  27924. generateMipMapsForCubemap(texture: InternalTexture): void;
  27925. /**
  27926. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27927. */
  27928. flushFramebuffer(): void;
  27929. /**
  27930. * Unbind the current render target and bind the default framebuffer
  27931. */
  27932. restoreDefaultFramebuffer(): void;
  27933. /**
  27934. * Create an uniform buffer
  27935. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27936. * @param elements defines the content of the uniform buffer
  27937. * @returns the webGL uniform buffer
  27938. */
  27939. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27940. /**
  27941. * Create a dynamic uniform buffer
  27942. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27943. * @param elements defines the content of the uniform buffer
  27944. * @returns the webGL uniform buffer
  27945. */
  27946. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27947. /**
  27948. * Update an existing uniform buffer
  27949. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27950. * @param uniformBuffer defines the target uniform buffer
  27951. * @param elements defines the content to update
  27952. * @param offset defines the offset in the uniform buffer where update should start
  27953. * @param count defines the size of the data to update
  27954. */
  27955. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27956. private _resetVertexBufferBinding;
  27957. /**
  27958. * Creates a vertex buffer
  27959. * @param data the data for the vertex buffer
  27960. * @returns the new WebGL static buffer
  27961. */
  27962. createVertexBuffer(data: DataArray): WebGLBuffer;
  27963. /**
  27964. * Creates a dynamic vertex buffer
  27965. * @param data the data for the dynamic vertex buffer
  27966. * @returns the new WebGL dynamic buffer
  27967. */
  27968. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27969. /**
  27970. * Update a dynamic index buffer
  27971. * @param indexBuffer defines the target index buffer
  27972. * @param indices defines the data to update
  27973. * @param offset defines the offset in the target index buffer where update should start
  27974. */
  27975. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27976. /**
  27977. * Updates a dynamic vertex buffer.
  27978. * @param vertexBuffer the vertex buffer to update
  27979. * @param data the data used to update the vertex buffer
  27980. * @param byteOffset the byte offset of the data
  27981. * @param byteLength the byte length of the data
  27982. */
  27983. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27984. private _resetIndexBufferBinding;
  27985. /**
  27986. * Creates a new index buffer
  27987. * @param indices defines the content of the index buffer
  27988. * @param updatable defines if the index buffer must be updatable
  27989. * @returns a new webGL buffer
  27990. */
  27991. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27992. /**
  27993. * Bind a webGL buffer to the webGL context
  27994. * @param buffer defines the buffer to bind
  27995. */
  27996. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27997. /**
  27998. * Bind an uniform buffer to the current webGL context
  27999. * @param buffer defines the buffer to bind
  28000. */
  28001. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28002. /**
  28003. * Bind a buffer to the current webGL context at a given location
  28004. * @param buffer defines the buffer to bind
  28005. * @param location defines the index where to bind the buffer
  28006. */
  28007. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28008. /**
  28009. * Bind a specific block at a given index in a specific shader program
  28010. * @param shaderProgram defines the shader program
  28011. * @param blockName defines the block name
  28012. * @param index defines the index where to bind the block
  28013. */
  28014. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28015. private bindIndexBuffer;
  28016. private bindBuffer;
  28017. /**
  28018. * update the bound buffer with the given data
  28019. * @param data defines the data to update
  28020. */
  28021. updateArrayBuffer(data: Float32Array): void;
  28022. private _vertexAttribPointer;
  28023. private _bindIndexBufferWithCache;
  28024. private _bindVertexBuffersAttributes;
  28025. /**
  28026. * Records a vertex array object
  28027. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28028. * @param vertexBuffers defines the list of vertex buffers to store
  28029. * @param indexBuffer defines the index buffer to store
  28030. * @param effect defines the effect to store
  28031. * @returns the new vertex array object
  28032. */
  28033. recordVertexArrayObject(vertexBuffers: {
  28034. [key: string]: VertexBuffer;
  28035. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28036. /**
  28037. * Bind a specific vertex array object
  28038. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28039. * @param vertexArrayObject defines the vertex array object to bind
  28040. * @param indexBuffer defines the index buffer to bind
  28041. */
  28042. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28043. /**
  28044. * Bind webGl buffers directly to the webGL context
  28045. * @param vertexBuffer defines the vertex buffer to bind
  28046. * @param indexBuffer defines the index buffer to bind
  28047. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28048. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28049. * @param effect defines the effect associated with the vertex buffer
  28050. */
  28051. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28052. private _unbindVertexArrayObject;
  28053. /**
  28054. * Bind a list of vertex buffers to the webGL context
  28055. * @param vertexBuffers defines the list of vertex buffers to bind
  28056. * @param indexBuffer defines the index buffer to bind
  28057. * @param effect defines the effect associated with the vertex buffers
  28058. */
  28059. bindBuffers(vertexBuffers: {
  28060. [key: string]: Nullable<VertexBuffer>;
  28061. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28062. /**
  28063. * Unbind all instance attributes
  28064. */
  28065. unbindInstanceAttributes(): void;
  28066. /**
  28067. * Release and free the memory of a vertex array object
  28068. * @param vao defines the vertex array object to delete
  28069. */
  28070. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28071. /** @hidden */
  28072. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28073. /**
  28074. * Creates a webGL buffer to use with instanciation
  28075. * @param capacity defines the size of the buffer
  28076. * @returns the webGL buffer
  28077. */
  28078. createInstancesBuffer(capacity: number): WebGLBuffer;
  28079. /**
  28080. * Delete a webGL buffer used with instanciation
  28081. * @param buffer defines the webGL buffer to delete
  28082. */
  28083. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28084. /**
  28085. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28086. * @param instancesBuffer defines the webGL buffer to update and bind
  28087. * @param data defines the data to store in the buffer
  28088. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28089. */
  28090. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28091. /**
  28092. * Apply all cached states (depth, culling, stencil and alpha)
  28093. */
  28094. applyStates(): void;
  28095. /**
  28096. * Send a draw order
  28097. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28098. * @param indexStart defines the starting index
  28099. * @param indexCount defines the number of index to draw
  28100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28101. */
  28102. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28103. /**
  28104. * Draw a list of points
  28105. * @param verticesStart defines the index of first vertex to draw
  28106. * @param verticesCount defines the count of vertices to draw
  28107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28108. */
  28109. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28110. /**
  28111. * Draw a list of unindexed primitives
  28112. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28113. * @param verticesStart defines the index of first vertex to draw
  28114. * @param verticesCount defines the count of vertices to draw
  28115. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28116. */
  28117. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28118. /**
  28119. * Draw a list of indexed primitives
  28120. * @param fillMode defines the primitive to use
  28121. * @param indexStart defines the starting index
  28122. * @param indexCount defines the number of index to draw
  28123. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28124. */
  28125. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28126. /**
  28127. * Draw a list of unindexed primitives
  28128. * @param fillMode defines the primitive to use
  28129. * @param verticesStart defines the index of first vertex to draw
  28130. * @param verticesCount defines the count of vertices to draw
  28131. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28132. */
  28133. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28134. private _drawMode;
  28135. /** @hidden */
  28136. _releaseEffect(effect: Effect): void;
  28137. /** @hidden */
  28138. _deleteProgram(program: WebGLProgram): void;
  28139. /**
  28140. * Create a new effect (used to store vertex/fragment shaders)
  28141. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28142. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28143. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28144. * @param samplers defines an array of string used to represent textures
  28145. * @param defines defines the string containing the defines to use to compile the shaders
  28146. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28147. * @param onCompiled defines a function to call when the effect creation is successful
  28148. * @param onError defines a function to call when the effect creation has failed
  28149. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28150. * @returns the new Effect
  28151. */
  28152. 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;
  28153. private _compileShader;
  28154. private _compileRawShader;
  28155. /**
  28156. * Directly creates a webGL program
  28157. * @param vertexCode defines the vertex shader code to use
  28158. * @param fragmentCode defines the fragment shader code to use
  28159. * @param context defines the webGL context to use (if not set, the current one will be used)
  28160. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28161. * @returns the new webGL program
  28162. */
  28163. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28164. /**
  28165. * Creates a webGL program
  28166. * @param vertexCode defines the vertex shader code to use
  28167. * @param fragmentCode defines the fragment shader code to use
  28168. * @param defines defines the string containing the defines to use to compile the shaders
  28169. * @param context defines the webGL context to use (if not set, the current one will be used)
  28170. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28171. * @returns the new webGL program
  28172. */
  28173. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28174. private _createShaderProgram;
  28175. private _finalizeProgram;
  28176. /** @hidden */
  28177. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28178. /** @hidden */
  28179. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28180. /**
  28181. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28182. * @param shaderProgram defines the webGL program to use
  28183. * @param uniformsNames defines the list of uniform names
  28184. * @returns an array of webGL uniform locations
  28185. */
  28186. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28187. /**
  28188. * Gets the lsit of active attributes for a given webGL program
  28189. * @param shaderProgram defines the webGL program to use
  28190. * @param attributesNames defines the list of attribute names to get
  28191. * @returns an array of indices indicating the offset of each attribute
  28192. */
  28193. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28194. /**
  28195. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28196. * @param effect defines the effect to activate
  28197. */
  28198. enableEffect(effect: Nullable<Effect>): void;
  28199. /**
  28200. * Set the value of an uniform to an array of int32
  28201. * @param uniform defines the webGL uniform location where to store the value
  28202. * @param array defines the array of int32 to store
  28203. */
  28204. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28205. /**
  28206. * Set the value of an uniform to an array of int32 (stored as vec2)
  28207. * @param uniform defines the webGL uniform location where to store the value
  28208. * @param array defines the array of int32 to store
  28209. */
  28210. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28211. /**
  28212. * Set the value of an uniform to an array of int32 (stored as vec3)
  28213. * @param uniform defines the webGL uniform location where to store the value
  28214. * @param array defines the array of int32 to store
  28215. */
  28216. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28217. /**
  28218. * Set the value of an uniform to an array of int32 (stored as vec4)
  28219. * @param uniform defines the webGL uniform location where to store the value
  28220. * @param array defines the array of int32 to store
  28221. */
  28222. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28223. /**
  28224. * Set the value of an uniform to an array of float32
  28225. * @param uniform defines the webGL uniform location where to store the value
  28226. * @param array defines the array of float32 to store
  28227. */
  28228. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28229. /**
  28230. * Set the value of an uniform to an array of float32 (stored as vec2)
  28231. * @param uniform defines the webGL uniform location where to store the value
  28232. * @param array defines the array of float32 to store
  28233. */
  28234. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28235. /**
  28236. * Set the value of an uniform to an array of float32 (stored as vec3)
  28237. * @param uniform defines the webGL uniform location where to store the value
  28238. * @param array defines the array of float32 to store
  28239. */
  28240. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28241. /**
  28242. * Set the value of an uniform to an array of float32 (stored as vec4)
  28243. * @param uniform defines the webGL uniform location where to store the value
  28244. * @param array defines the array of float32 to store
  28245. */
  28246. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28247. /**
  28248. * Set the value of an uniform to an array of number
  28249. * @param uniform defines the webGL uniform location where to store the value
  28250. * @param array defines the array of number to store
  28251. */
  28252. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28253. /**
  28254. * Set the value of an uniform to an array of number (stored as vec2)
  28255. * @param uniform defines the webGL uniform location where to store the value
  28256. * @param array defines the array of number to store
  28257. */
  28258. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28259. /**
  28260. * Set the value of an uniform to an array of number (stored as vec3)
  28261. * @param uniform defines the webGL uniform location where to store the value
  28262. * @param array defines the array of number to store
  28263. */
  28264. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28265. /**
  28266. * Set the value of an uniform to an array of number (stored as vec4)
  28267. * @param uniform defines the webGL uniform location where to store the value
  28268. * @param array defines the array of number to store
  28269. */
  28270. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28271. /**
  28272. * Set the value of an uniform to an array of float32 (stored as matrices)
  28273. * @param uniform defines the webGL uniform location where to store the value
  28274. * @param matrices defines the array of float32 to store
  28275. */
  28276. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28277. /**
  28278. * Set the value of an uniform to a matrix
  28279. * @param uniform defines the webGL uniform location where to store the value
  28280. * @param matrix defines the matrix to store
  28281. */
  28282. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28283. /**
  28284. * Set the value of an uniform to a matrix (3x3)
  28285. * @param uniform defines the webGL uniform location where to store the value
  28286. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28287. */
  28288. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28289. /**
  28290. * Set the value of an uniform to a matrix (2x2)
  28291. * @param uniform defines the webGL uniform location where to store the value
  28292. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28293. */
  28294. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28295. /**
  28296. * Set the value of an uniform to a number (int)
  28297. * @param uniform defines the webGL uniform location where to store the value
  28298. * @param value defines the int number to store
  28299. */
  28300. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28301. /**
  28302. * Set the value of an uniform to a number (float)
  28303. * @param uniform defines the webGL uniform location where to store the value
  28304. * @param value defines the float number to store
  28305. */
  28306. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28307. /**
  28308. * Set the value of an uniform to a vec2
  28309. * @param uniform defines the webGL uniform location where to store the value
  28310. * @param x defines the 1st component of the value
  28311. * @param y defines the 2nd component of the value
  28312. */
  28313. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28314. /**
  28315. * Set the value of an uniform to a vec3
  28316. * @param uniform defines the webGL uniform location where to store the value
  28317. * @param x defines the 1st component of the value
  28318. * @param y defines the 2nd component of the value
  28319. * @param z defines the 3rd component of the value
  28320. */
  28321. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28322. /**
  28323. * Set the value of an uniform to a boolean
  28324. * @param uniform defines the webGL uniform location where to store the value
  28325. * @param bool defines the boolean to store
  28326. */
  28327. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28328. /**
  28329. * Set the value of an uniform to a vec4
  28330. * @param uniform defines the webGL uniform location where to store the value
  28331. * @param x defines the 1st component of the value
  28332. * @param y defines the 2nd component of the value
  28333. * @param z defines the 3rd component of the value
  28334. * @param w defines the 4th component of the value
  28335. */
  28336. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28337. /**
  28338. * Set the value of an uniform to a Color3
  28339. * @param uniform defines the webGL uniform location where to store the value
  28340. * @param color3 defines the color to store
  28341. */
  28342. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28343. /**
  28344. * Set the value of an uniform to a Color3 and an alpha value
  28345. * @param uniform defines the webGL uniform location where to store the value
  28346. * @param color3 defines the color to store
  28347. * @param alpha defines the alpha component to store
  28348. */
  28349. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28350. /**
  28351. * Sets a Color4 on a uniform variable
  28352. * @param uniform defines the uniform location
  28353. * @param color4 defines the value to be set
  28354. */
  28355. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28356. /**
  28357. * Set various states to the webGL context
  28358. * @param culling defines backface culling state
  28359. * @param zOffset defines the value to apply to zOffset (0 by default)
  28360. * @param force defines if states must be applied even if cache is up to date
  28361. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28362. */
  28363. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28364. /**
  28365. * Set the z offset to apply to current rendering
  28366. * @param value defines the offset to apply
  28367. */
  28368. setZOffset(value: number): void;
  28369. /**
  28370. * Gets the current value of the zOffset
  28371. * @returns the current zOffset state
  28372. */
  28373. getZOffset(): number;
  28374. /**
  28375. * Enable or disable depth buffering
  28376. * @param enable defines the state to set
  28377. */
  28378. setDepthBuffer(enable: boolean): void;
  28379. /**
  28380. * Gets a boolean indicating if depth writing is enabled
  28381. * @returns the current depth writing state
  28382. */
  28383. getDepthWrite(): boolean;
  28384. /**
  28385. * Enable or disable depth writing
  28386. * @param enable defines the state to set
  28387. */
  28388. setDepthWrite(enable: boolean): void;
  28389. /**
  28390. * Enable or disable color writing
  28391. * @param enable defines the state to set
  28392. */
  28393. setColorWrite(enable: boolean): void;
  28394. /**
  28395. * Gets a boolean indicating if color writing is enabled
  28396. * @returns the current color writing state
  28397. */
  28398. getColorWrite(): boolean;
  28399. /**
  28400. * Sets alpha constants used by some alpha blending modes
  28401. * @param r defines the red component
  28402. * @param g defines the green component
  28403. * @param b defines the blue component
  28404. * @param a defines the alpha component
  28405. */
  28406. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28407. /**
  28408. * Sets the current alpha mode
  28409. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28410. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28412. */
  28413. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28414. /**
  28415. * Gets the current alpha mode
  28416. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28417. * @returns the current alpha mode
  28418. */
  28419. getAlphaMode(): number;
  28420. /**
  28421. * Clears the list of texture accessible through engine.
  28422. * This can help preventing texture load conflict due to name collision.
  28423. */
  28424. clearInternalTexturesCache(): void;
  28425. /**
  28426. * Force the entire cache to be cleared
  28427. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28428. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28429. */
  28430. wipeCaches(bruteForce?: boolean): void;
  28431. /**
  28432. * Set the compressed texture format to use, based on the formats you have, and the formats
  28433. * supported by the hardware / browser.
  28434. *
  28435. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28436. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28437. * to API arguments needed to compressed textures. This puts the burden on the container
  28438. * generator to house the arcane code for determining these for current & future formats.
  28439. *
  28440. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28441. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28442. *
  28443. * Note: The result of this call is not taken into account when a texture is base64.
  28444. *
  28445. * @param formatsAvailable defines the list of those format families you have created
  28446. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28447. *
  28448. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28449. * @returns The extension selected.
  28450. */
  28451. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28452. private _getSamplingParameters;
  28453. private _partialLoadImg;
  28454. private _cascadeLoadImgs;
  28455. /** @hidden */
  28456. _createTexture(): WebGLTexture;
  28457. /**
  28458. * Usually called from Texture.ts.
  28459. * Passed information to create a WebGLTexture
  28460. * @param urlArg defines a value which contains one of the following:
  28461. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28462. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28463. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28465. * @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)
  28466. * @param scene needed for loading to the correct scene
  28467. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28468. * @param onLoad optional callback to be called upon successful completion
  28469. * @param onError optional callback to be called upon failure
  28470. * @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
  28471. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28472. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28473. * @param forcedExtension defines the extension to use to pick the right loader
  28474. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28475. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28476. */
  28477. 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;
  28478. private _rescaleTexture;
  28479. /**
  28480. * Update a raw texture
  28481. * @param texture defines the texture to update
  28482. * @param data defines the data to store in the texture
  28483. * @param format defines the format of the data
  28484. * @param invertY defines if data must be stored with Y axis inverted
  28485. * @param compression defines the compression used (null by default)
  28486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28487. */
  28488. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28489. /**
  28490. * Creates a raw texture
  28491. * @param data defines the data to store in the texture
  28492. * @param width defines the width of the texture
  28493. * @param height defines the height of the texture
  28494. * @param format defines the format of the data
  28495. * @param generateMipMaps defines if the engine should generate the mip levels
  28496. * @param invertY defines if data must be stored with Y axis inverted
  28497. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28498. * @param compression defines the compression used (null by default)
  28499. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28500. * @returns the raw texture inside an InternalTexture
  28501. */
  28502. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28503. private _unpackFlipYCached;
  28504. /**
  28505. * In case you are sharing the context with other applications, it might
  28506. * be interested to not cache the unpack flip y state to ensure a consistent
  28507. * value would be set.
  28508. */
  28509. enableUnpackFlipYCached: boolean;
  28510. /** @hidden */
  28511. _unpackFlipY(value: boolean): void;
  28512. /** @hidden */
  28513. _getUnpackAlignement(): number;
  28514. /**
  28515. * Creates a dynamic texture
  28516. * @param width defines the width of the texture
  28517. * @param height defines the height of the texture
  28518. * @param generateMipMaps defines if the engine should generate the mip levels
  28519. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28520. * @returns the dynamic texture inside an InternalTexture
  28521. */
  28522. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28523. /**
  28524. * Update the sampling mode of a given texture
  28525. * @param samplingMode defines the required sampling mode
  28526. * @param texture defines the texture to update
  28527. */
  28528. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28529. /**
  28530. * Update the content of a dynamic texture
  28531. * @param texture defines the texture to update
  28532. * @param canvas defines the canvas containing the source
  28533. * @param invertY defines if data must be stored with Y axis inverted
  28534. * @param premulAlpha defines if alpha is stored as premultiplied
  28535. * @param format defines the format of the data
  28536. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28537. */
  28538. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28539. /**
  28540. * Update a video texture
  28541. * @param texture defines the texture to update
  28542. * @param video defines the video element to use
  28543. * @param invertY defines if data must be stored with Y axis inverted
  28544. */
  28545. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28546. /**
  28547. * Updates a depth texture Comparison Mode and Function.
  28548. * If the comparison Function is equal to 0, the mode will be set to none.
  28549. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28550. * @param texture The texture to set the comparison function for
  28551. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28552. */
  28553. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28554. private _setupDepthStencilTexture;
  28555. /**
  28556. * Creates a depth stencil texture.
  28557. * This is only available in WebGL 2 or with the depth texture extension available.
  28558. * @param size The size of face edge in the texture.
  28559. * @param options The options defining the texture.
  28560. * @returns The texture
  28561. */
  28562. createDepthStencilTexture(size: number | {
  28563. width: number;
  28564. height: number;
  28565. }, options: DepthTextureCreationOptions): InternalTexture;
  28566. /**
  28567. * Creates a depth stencil texture.
  28568. * This is only available in WebGL 2 or with the depth texture extension available.
  28569. * @param size The size of face edge in the texture.
  28570. * @param options The options defining the texture.
  28571. * @returns The texture
  28572. */
  28573. private _createDepthStencilTexture;
  28574. /**
  28575. * Creates a depth stencil cube texture.
  28576. * This is only available in WebGL 2.
  28577. * @param size The size of face edge in the cube texture.
  28578. * @param options The options defining the cube texture.
  28579. * @returns The cube texture
  28580. */
  28581. private _createDepthStencilCubeTexture;
  28582. /**
  28583. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28584. * @param renderTarget The render target to set the frame buffer for
  28585. */
  28586. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28587. /**
  28588. * Creates a new render target texture
  28589. * @param size defines the size of the texture
  28590. * @param options defines the options used to create the texture
  28591. * @returns a new render target texture stored in an InternalTexture
  28592. */
  28593. createRenderTargetTexture(size: number | {
  28594. width: number;
  28595. height: number;
  28596. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28597. /**
  28598. * Create a multi render target texture
  28599. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28600. * @param size defines the size of the texture
  28601. * @param options defines the creation options
  28602. * @returns the cube texture as an InternalTexture
  28603. */
  28604. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28605. private _setupFramebufferDepthAttachments;
  28606. /**
  28607. * Updates the sample count of a render target texture
  28608. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28609. * @param texture defines the texture to update
  28610. * @param samples defines the sample count to set
  28611. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28612. */
  28613. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28614. /**
  28615. * Update the sample count for a given multiple render target texture
  28616. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28617. * @param textures defines the textures to update
  28618. * @param samples defines the sample count to set
  28619. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28620. */
  28621. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28622. /** @hidden */
  28623. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28624. /** @hidden */
  28625. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28626. /** @hidden */
  28627. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28628. /** @hidden */
  28629. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28630. /**
  28631. * Creates a new render target cube texture
  28632. * @param size defines the size of the texture
  28633. * @param options defines the options used to create the texture
  28634. * @returns a new render target cube texture stored in an InternalTexture
  28635. */
  28636. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28637. /**
  28638. * Creates a cube texture
  28639. * @param rootUrl defines the url where the files to load is located
  28640. * @param scene defines the current scene
  28641. * @param files defines the list of files to load (1 per face)
  28642. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28643. * @param onLoad defines an optional callback raised when the texture is loaded
  28644. * @param onError defines an optional callback raised if there is an issue to load the texture
  28645. * @param format defines the format of the data
  28646. * @param forcedExtension defines the extension to use to pick the right loader
  28647. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28648. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28649. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28650. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28651. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28652. * @returns the cube texture as an InternalTexture
  28653. */
  28654. 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;
  28655. /**
  28656. * @hidden
  28657. */
  28658. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28659. /**
  28660. * Update a raw cube texture
  28661. * @param texture defines the texture to udpdate
  28662. * @param data defines the data to store
  28663. * @param format defines the data format
  28664. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28665. * @param invertY defines if data must be stored with Y axis inverted
  28666. * @param compression defines the compression used (null by default)
  28667. * @param level defines which level of the texture to update
  28668. */
  28669. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28670. /**
  28671. * Creates a new raw cube texture
  28672. * @param data defines the array of data to use to create each face
  28673. * @param size defines the size of the textures
  28674. * @param format defines the format of the data
  28675. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28676. * @param generateMipMaps defines if the engine should generate the mip levels
  28677. * @param invertY defines if data must be stored with Y axis inverted
  28678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28679. * @param compression defines the compression used (null by default)
  28680. * @returns the cube texture as an InternalTexture
  28681. */
  28682. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28683. /**
  28684. * Creates a new raw cube texture from a specified url
  28685. * @param url defines the url where the data is located
  28686. * @param scene defines the current scene
  28687. * @param size defines the size of the textures
  28688. * @param format defines the format of the data
  28689. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28690. * @param noMipmap defines if the engine should avoid generating the mip levels
  28691. * @param callback defines a callback used to extract texture data from loaded data
  28692. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28693. * @param onLoad defines a callback called when texture is loaded
  28694. * @param onError defines a callback called if there is an error
  28695. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28696. * @param invertY defines if data must be stored with Y axis inverted
  28697. * @returns the cube texture as an InternalTexture
  28698. */
  28699. 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;
  28700. /**
  28701. * Update a raw 3D texture
  28702. * @param texture defines the texture to update
  28703. * @param data defines the data to store
  28704. * @param format defines the data format
  28705. * @param invertY defines if data must be stored with Y axis inverted
  28706. * @param compression defines the used compression (can be null)
  28707. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28708. */
  28709. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28710. /**
  28711. * Creates a new raw 3D texture
  28712. * @param data defines the data used to create the texture
  28713. * @param width defines the width of the texture
  28714. * @param height defines the height of the texture
  28715. * @param depth defines the depth of the texture
  28716. * @param format defines the format of the texture
  28717. * @param generateMipMaps defines if the engine must generate mip levels
  28718. * @param invertY defines if data must be stored with Y axis inverted
  28719. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28720. * @param compression defines the compressed used (can be null)
  28721. * @param textureType defines the compressed used (can be null)
  28722. * @returns a new raw 3D texture (stored in an InternalTexture)
  28723. */
  28724. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28725. private _prepareWebGLTextureContinuation;
  28726. private _prepareWebGLTexture;
  28727. private _convertRGBtoRGBATextureData;
  28728. /** @hidden */
  28729. _releaseFramebufferObjects(texture: InternalTexture): void;
  28730. /** @hidden */
  28731. _releaseTexture(texture: InternalTexture): void;
  28732. private setProgram;
  28733. private _boundUniforms;
  28734. /**
  28735. * Binds an effect to the webGL context
  28736. * @param effect defines the effect to bind
  28737. */
  28738. bindSamplers(effect: Effect): void;
  28739. private _moveBoundTextureOnTop;
  28740. private _getCorrectTextureChannel;
  28741. private _linkTrackers;
  28742. private _removeDesignatedSlot;
  28743. private _activateCurrentTexture;
  28744. /** @hidden */
  28745. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28746. /** @hidden */
  28747. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28748. /**
  28749. * Sets a texture to the webGL context from a postprocess
  28750. * @param channel defines the channel to use
  28751. * @param postProcess defines the source postprocess
  28752. */
  28753. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28754. /**
  28755. * Binds the output of the passed in post process to the texture channel specified
  28756. * @param channel The channel the texture should be bound to
  28757. * @param postProcess The post process which's output should be bound
  28758. */
  28759. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28760. /**
  28761. * Unbind all textures from the webGL context
  28762. */
  28763. unbindAllTextures(): void;
  28764. /**
  28765. * Sets a texture to the according uniform.
  28766. * @param channel The texture channel
  28767. * @param uniform The uniform to set
  28768. * @param texture The texture to apply
  28769. */
  28770. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28771. /**
  28772. * Sets a depth stencil texture from a render target to the according uniform.
  28773. * @param channel The texture channel
  28774. * @param uniform The uniform to set
  28775. * @param texture The render target texture containing the depth stencil texture to apply
  28776. */
  28777. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28778. private _bindSamplerUniformToChannel;
  28779. private _getTextureWrapMode;
  28780. private _setTexture;
  28781. /**
  28782. * Sets an array of texture to the webGL context
  28783. * @param channel defines the channel where the texture array must be set
  28784. * @param uniform defines the associated uniform location
  28785. * @param textures defines the array of textures to bind
  28786. */
  28787. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28788. /** @hidden */
  28789. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28790. private _setTextureParameterFloat;
  28791. private _setTextureParameterInteger;
  28792. /**
  28793. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28794. * @param x defines the x coordinate of the rectangle where pixels must be read
  28795. * @param y defines the y coordinate of the rectangle where pixels must be read
  28796. * @param width defines the width of the rectangle where pixels must be read
  28797. * @param height defines the height of the rectangle where pixels must be read
  28798. * @returns a Uint8Array containing RGBA colors
  28799. */
  28800. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28801. /**
  28802. * Add an externaly attached data from its key.
  28803. * This method call will fail and return false, if such key already exists.
  28804. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28805. * @param key the unique key that identifies the data
  28806. * @param data the data object to associate to the key for this Engine instance
  28807. * @return true if no such key were already present and the data was added successfully, false otherwise
  28808. */
  28809. addExternalData<T>(key: string, data: T): boolean;
  28810. /**
  28811. * Get an externaly attached data from its key
  28812. * @param key the unique key that identifies the data
  28813. * @return the associated data, if present (can be null), or undefined if not present
  28814. */
  28815. getExternalData<T>(key: string): T;
  28816. /**
  28817. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28818. * @param key the unique key that identifies the data
  28819. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28820. * @return the associated data, can be null if the factory returned null.
  28821. */
  28822. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28823. /**
  28824. * Remove an externaly attached data from the Engine instance
  28825. * @param key the unique key that identifies the data
  28826. * @return true if the data was successfully removed, false if it doesn't exist
  28827. */
  28828. removeExternalData(key: string): boolean;
  28829. /**
  28830. * Unbind all vertex attributes from the webGL context
  28831. */
  28832. unbindAllAttributes(): void;
  28833. /**
  28834. * 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
  28835. */
  28836. releaseEffects(): void;
  28837. /**
  28838. * Dispose and release all associated resources
  28839. */
  28840. dispose(): void;
  28841. /**
  28842. * Display the loading screen
  28843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28844. */
  28845. displayLoadingUI(): void;
  28846. /**
  28847. * Hide the loading screen
  28848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28849. */
  28850. hideLoadingUI(): void;
  28851. /**
  28852. * Gets the current loading screen object
  28853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28854. */
  28855. /**
  28856. * Sets the current loading screen object
  28857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28858. */
  28859. loadingScreen: ILoadingScreen;
  28860. /**
  28861. * Sets the current loading screen text
  28862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28863. */
  28864. loadingUIText: string;
  28865. /**
  28866. * Sets the current loading screen background color
  28867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28868. */
  28869. loadingUIBackgroundColor: string;
  28870. /**
  28871. * Attach a new callback raised when context lost event is fired
  28872. * @param callback defines the callback to call
  28873. */
  28874. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28875. /**
  28876. * Attach a new callback raised when context restored event is fired
  28877. * @param callback defines the callback to call
  28878. */
  28879. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28880. /**
  28881. * Gets the source code of the vertex shader associated with a specific webGL program
  28882. * @param program defines the program to use
  28883. * @returns a string containing the source code of the vertex shader associated with the program
  28884. */
  28885. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28886. /**
  28887. * Gets the source code of the fragment shader associated with a specific webGL program
  28888. * @param program defines the program to use
  28889. * @returns a string containing the source code of the fragment shader associated with the program
  28890. */
  28891. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28892. /**
  28893. * Get the current error code of the webGL context
  28894. * @returns the error code
  28895. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28896. */
  28897. getError(): number;
  28898. /**
  28899. * Gets the current framerate
  28900. * @returns a number representing the framerate
  28901. */
  28902. getFps(): number;
  28903. /**
  28904. * Gets the time spent between current and previous frame
  28905. * @returns a number representing the delta time in ms
  28906. */
  28907. getDeltaTime(): number;
  28908. private _measureFps;
  28909. /** @hidden */
  28910. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28911. private _canRenderToFloatFramebuffer;
  28912. private _canRenderToHalfFloatFramebuffer;
  28913. private _canRenderToFramebuffer;
  28914. /** @hidden */
  28915. _getWebGLTextureType(type: number): number;
  28916. private _getInternalFormat;
  28917. /** @hidden */
  28918. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28919. /** @hidden */
  28920. _getRGBAMultiSampleBufferFormat(type: number): number;
  28921. /** @hidden */
  28922. _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;
  28923. /** @hidden */
  28924. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28925. private _partialLoadFile;
  28926. private _cascadeLoadFiles;
  28927. /**
  28928. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28929. * @returns true if the engine can be created
  28930. * @ignorenaming
  28931. */
  28932. static isSupported(): boolean;
  28933. }
  28934. }
  28935. declare module "babylonjs/Materials/effect" {
  28936. import { Observable } from "babylonjs/Misc/observable";
  28937. import { Nullable } from "babylonjs/types";
  28938. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28939. import { Engine } from "babylonjs/Engines/engine";
  28940. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28942. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28943. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28945. /**
  28946. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28947. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28948. */
  28949. export class EffectFallbacks {
  28950. private _defines;
  28951. private _currentRank;
  28952. private _maxRank;
  28953. private _mesh;
  28954. /**
  28955. * Removes the fallback from the bound mesh.
  28956. */
  28957. unBindMesh(): void;
  28958. /**
  28959. * Adds a fallback on the specified property.
  28960. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28961. * @param define The name of the define in the shader
  28962. */
  28963. addFallback(rank: number, define: string): void;
  28964. /**
  28965. * Sets the mesh to use CPU skinning when needing to fallback.
  28966. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28967. * @param mesh The mesh to use the fallbacks.
  28968. */
  28969. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28970. /**
  28971. * Checks to see if more fallbacks are still availible.
  28972. */
  28973. readonly isMoreFallbacks: boolean;
  28974. /**
  28975. * Removes the defines that shoould be removed when falling back.
  28976. * @param currentDefines defines the current define statements for the shader.
  28977. * @param effect defines the current effect we try to compile
  28978. * @returns The resulting defines with defines of the current rank removed.
  28979. */
  28980. reduce(currentDefines: string, effect: Effect): string;
  28981. }
  28982. /**
  28983. * Options to be used when creating an effect.
  28984. */
  28985. export class EffectCreationOptions {
  28986. /**
  28987. * Atrributes that will be used in the shader.
  28988. */
  28989. attributes: string[];
  28990. /**
  28991. * Uniform varible names that will be set in the shader.
  28992. */
  28993. uniformsNames: string[];
  28994. /**
  28995. * Uniform buffer varible names that will be set in the shader.
  28996. */
  28997. uniformBuffersNames: string[];
  28998. /**
  28999. * Sampler texture variable names that will be set in the shader.
  29000. */
  29001. samplers: string[];
  29002. /**
  29003. * Define statements that will be set in the shader.
  29004. */
  29005. defines: any;
  29006. /**
  29007. * Possible fallbacks for this effect to improve performance when needed.
  29008. */
  29009. fallbacks: Nullable<EffectFallbacks>;
  29010. /**
  29011. * Callback that will be called when the shader is compiled.
  29012. */
  29013. onCompiled: Nullable<(effect: Effect) => void>;
  29014. /**
  29015. * Callback that will be called if an error occurs during shader compilation.
  29016. */
  29017. onError: Nullable<(effect: Effect, errors: string) => void>;
  29018. /**
  29019. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29020. */
  29021. indexParameters: any;
  29022. /**
  29023. * Max number of lights that can be used in the shader.
  29024. */
  29025. maxSimultaneousLights: number;
  29026. /**
  29027. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29028. */
  29029. transformFeedbackVaryings: Nullable<string[]>;
  29030. }
  29031. /**
  29032. * Effect containing vertex and fragment shader that can be executed on an object.
  29033. */
  29034. export class Effect {
  29035. /**
  29036. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29037. */
  29038. static ShadersRepository: string;
  29039. /**
  29040. * Name of the effect.
  29041. */
  29042. name: any;
  29043. /**
  29044. * String container all the define statements that should be set on the shader.
  29045. */
  29046. defines: string;
  29047. /**
  29048. * Callback that will be called when the shader is compiled.
  29049. */
  29050. onCompiled: Nullable<(effect: Effect) => void>;
  29051. /**
  29052. * Callback that will be called if an error occurs during shader compilation.
  29053. */
  29054. onError: Nullable<(effect: Effect, errors: string) => void>;
  29055. /**
  29056. * Callback that will be called when effect is bound.
  29057. */
  29058. onBind: Nullable<(effect: Effect) => void>;
  29059. /**
  29060. * Unique ID of the effect.
  29061. */
  29062. uniqueId: number;
  29063. /**
  29064. * Observable that will be called when the shader is compiled.
  29065. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29066. */
  29067. onCompileObservable: Observable<Effect>;
  29068. /**
  29069. * Observable that will be called if an error occurs during shader compilation.
  29070. */
  29071. onErrorObservable: Observable<Effect>;
  29072. /** @hidden */
  29073. _onBindObservable: Nullable<Observable<Effect>>;
  29074. /**
  29075. * Observable that will be called when effect is bound.
  29076. */
  29077. readonly onBindObservable: Observable<Effect>;
  29078. /** @hidden */
  29079. _bonesComputationForcedToCPU: boolean;
  29080. private static _uniqueIdSeed;
  29081. private _engine;
  29082. private _uniformBuffersNames;
  29083. private _uniformsNames;
  29084. private _samplers;
  29085. private _isReady;
  29086. private _compilationError;
  29087. private _attributesNames;
  29088. private _attributes;
  29089. private _uniforms;
  29090. /**
  29091. * Key for the effect.
  29092. * @hidden
  29093. */
  29094. _key: string;
  29095. private _indexParameters;
  29096. private _fallbacks;
  29097. private _vertexSourceCode;
  29098. private _fragmentSourceCode;
  29099. private _vertexSourceCodeOverride;
  29100. private _fragmentSourceCodeOverride;
  29101. private _transformFeedbackVaryings;
  29102. /**
  29103. * Compiled shader to webGL program.
  29104. * @hidden
  29105. */
  29106. _program: WebGLProgram;
  29107. private _valueCache;
  29108. private static _baseCache;
  29109. /**
  29110. * Instantiates an effect.
  29111. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29112. * @param baseName Name of the effect.
  29113. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29114. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29115. * @param samplers List of sampler variables that will be passed to the shader.
  29116. * @param engine Engine to be used to render the effect
  29117. * @param defines Define statements to be added to the shader.
  29118. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29119. * @param onCompiled Callback that will be called when the shader is compiled.
  29120. * @param onError Callback that will be called if an error occurs during shader compilation.
  29121. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29122. */
  29123. 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);
  29124. /**
  29125. * Unique key for this effect
  29126. */
  29127. readonly key: string;
  29128. /**
  29129. * If the effect has been compiled and prepared.
  29130. * @returns if the effect is compiled and prepared.
  29131. */
  29132. isReady(): boolean;
  29133. /**
  29134. * The engine the effect was initialized with.
  29135. * @returns the engine.
  29136. */
  29137. getEngine(): Engine;
  29138. /**
  29139. * The compiled webGL program for the effect
  29140. * @returns the webGL program.
  29141. */
  29142. getProgram(): WebGLProgram;
  29143. /**
  29144. * The set of names of attribute variables for the shader.
  29145. * @returns An array of attribute names.
  29146. */
  29147. getAttributesNames(): string[];
  29148. /**
  29149. * Returns the attribute at the given index.
  29150. * @param index The index of the attribute.
  29151. * @returns The location of the attribute.
  29152. */
  29153. getAttributeLocation(index: number): number;
  29154. /**
  29155. * Returns the attribute based on the name of the variable.
  29156. * @param name of the attribute to look up.
  29157. * @returns the attribute location.
  29158. */
  29159. getAttributeLocationByName(name: string): number;
  29160. /**
  29161. * The number of attributes.
  29162. * @returns the numnber of attributes.
  29163. */
  29164. getAttributesCount(): number;
  29165. /**
  29166. * Gets the index of a uniform variable.
  29167. * @param uniformName of the uniform to look up.
  29168. * @returns the index.
  29169. */
  29170. getUniformIndex(uniformName: string): number;
  29171. /**
  29172. * Returns the attribute based on the name of the variable.
  29173. * @param uniformName of the uniform to look up.
  29174. * @returns the location of the uniform.
  29175. */
  29176. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29177. /**
  29178. * Returns an array of sampler variable names
  29179. * @returns The array of sampler variable neames.
  29180. */
  29181. getSamplers(): string[];
  29182. /**
  29183. * The error from the last compilation.
  29184. * @returns the error string.
  29185. */
  29186. getCompilationError(): string;
  29187. /**
  29188. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29189. * @param func The callback to be used.
  29190. */
  29191. executeWhenCompiled(func: (effect: Effect) => void): void;
  29192. private _checkIsReady;
  29193. /** @hidden */
  29194. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29195. /** @hidden */
  29196. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29197. /** @hidden */
  29198. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29199. private _processShaderConversion;
  29200. private _processIncludes;
  29201. private _processPrecision;
  29202. /**
  29203. * Recompiles the webGL program
  29204. * @param vertexSourceCode The source code for the vertex shader.
  29205. * @param fragmentSourceCode The source code for the fragment shader.
  29206. * @param onCompiled Callback called when completed.
  29207. * @param onError Callback called on error.
  29208. * @hidden
  29209. */
  29210. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29211. /**
  29212. * Gets the uniform locations of the the specified variable names
  29213. * @param names THe names of the variables to lookup.
  29214. * @returns Array of locations in the same order as variable names.
  29215. */
  29216. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29217. /**
  29218. * Prepares the effect
  29219. * @hidden
  29220. */
  29221. _prepareEffect(): void;
  29222. /**
  29223. * Checks if the effect is supported. (Must be called after compilation)
  29224. */
  29225. readonly isSupported: boolean;
  29226. /**
  29227. * Binds a texture to the engine to be used as output of the shader.
  29228. * @param channel Name of the output variable.
  29229. * @param texture Texture to bind.
  29230. * @hidden
  29231. */
  29232. _bindTexture(channel: string, texture: InternalTexture): void;
  29233. /**
  29234. * Sets a texture on the engine to be used in the shader.
  29235. * @param channel Name of the sampler variable.
  29236. * @param texture Texture to set.
  29237. */
  29238. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29239. /**
  29240. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29241. * @param channel Name of the sampler variable.
  29242. * @param texture Texture to set.
  29243. */
  29244. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29245. /**
  29246. * Sets an array of textures on the engine to be used in the shader.
  29247. * @param channel Name of the variable.
  29248. * @param textures Textures to set.
  29249. */
  29250. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29251. /**
  29252. * 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)
  29253. * @param channel Name of the sampler variable.
  29254. * @param postProcess Post process to get the input texture from.
  29255. */
  29256. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29257. /**
  29258. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29259. * 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)
  29260. * @param channel Name of the sampler variable.
  29261. * @param postProcess Post process to get the output texture from.
  29262. */
  29263. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29264. /** @hidden */
  29265. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29266. /** @hidden */
  29267. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29268. /** @hidden */
  29269. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29270. /** @hidden */
  29271. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29272. /**
  29273. * Binds a buffer to a uniform.
  29274. * @param buffer Buffer to bind.
  29275. * @param name Name of the uniform variable to bind to.
  29276. */
  29277. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29278. /**
  29279. * Binds block to a uniform.
  29280. * @param blockName Name of the block to bind.
  29281. * @param index Index to bind.
  29282. */
  29283. bindUniformBlock(blockName: string, index: number): void;
  29284. /**
  29285. * Sets an interger value on a uniform variable.
  29286. * @param uniformName Name of the variable.
  29287. * @param value Value to be set.
  29288. * @returns this effect.
  29289. */
  29290. setInt(uniformName: string, value: number): Effect;
  29291. /**
  29292. * Sets an int array on a uniform variable.
  29293. * @param uniformName Name of the variable.
  29294. * @param array array to be set.
  29295. * @returns this effect.
  29296. */
  29297. setIntArray(uniformName: string, array: Int32Array): Effect;
  29298. /**
  29299. * 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)
  29300. * @param uniformName Name of the variable.
  29301. * @param array array to be set.
  29302. * @returns this effect.
  29303. */
  29304. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29305. /**
  29306. * 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)
  29307. * @param uniformName Name of the variable.
  29308. * @param array array to be set.
  29309. * @returns this effect.
  29310. */
  29311. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29312. /**
  29313. * 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)
  29314. * @param uniformName Name of the variable.
  29315. * @param array array to be set.
  29316. * @returns this effect.
  29317. */
  29318. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29319. /**
  29320. * Sets an float array on a uniform variable.
  29321. * @param uniformName Name of the variable.
  29322. * @param array array to be set.
  29323. * @returns this effect.
  29324. */
  29325. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29326. /**
  29327. * 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)
  29328. * @param uniformName Name of the variable.
  29329. * @param array array to be set.
  29330. * @returns this effect.
  29331. */
  29332. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29333. /**
  29334. * 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)
  29335. * @param uniformName Name of the variable.
  29336. * @param array array to be set.
  29337. * @returns this effect.
  29338. */
  29339. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29340. /**
  29341. * 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)
  29342. * @param uniformName Name of the variable.
  29343. * @param array array to be set.
  29344. * @returns this effect.
  29345. */
  29346. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29347. /**
  29348. * Sets an array on a uniform variable.
  29349. * @param uniformName Name of the variable.
  29350. * @param array array to be set.
  29351. * @returns this effect.
  29352. */
  29353. setArray(uniformName: string, array: number[]): Effect;
  29354. /**
  29355. * 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)
  29356. * @param uniformName Name of the variable.
  29357. * @param array array to be set.
  29358. * @returns this effect.
  29359. */
  29360. setArray2(uniformName: string, array: number[]): Effect;
  29361. /**
  29362. * 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)
  29363. * @param uniformName Name of the variable.
  29364. * @param array array to be set.
  29365. * @returns this effect.
  29366. */
  29367. setArray3(uniformName: string, array: number[]): Effect;
  29368. /**
  29369. * 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)
  29370. * @param uniformName Name of the variable.
  29371. * @param array array to be set.
  29372. * @returns this effect.
  29373. */
  29374. setArray4(uniformName: string, array: number[]): Effect;
  29375. /**
  29376. * Sets matrices on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param matrices matrices to be set.
  29379. * @returns this effect.
  29380. */
  29381. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29382. /**
  29383. * Sets matrix on a uniform variable.
  29384. * @param uniformName Name of the variable.
  29385. * @param matrix matrix to be set.
  29386. * @returns this effect.
  29387. */
  29388. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29389. /**
  29390. * 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)
  29391. * @param uniformName Name of the variable.
  29392. * @param matrix matrix to be set.
  29393. * @returns this effect.
  29394. */
  29395. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29396. /**
  29397. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29398. * @param uniformName Name of the variable.
  29399. * @param matrix matrix to be set.
  29400. * @returns this effect.
  29401. */
  29402. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29403. /**
  29404. * Sets a float on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param value value to be set.
  29407. * @returns this effect.
  29408. */
  29409. setFloat(uniformName: string, value: number): Effect;
  29410. /**
  29411. * Sets a boolean on a uniform variable.
  29412. * @param uniformName Name of the variable.
  29413. * @param bool value to be set.
  29414. * @returns this effect.
  29415. */
  29416. setBool(uniformName: string, bool: boolean): Effect;
  29417. /**
  29418. * Sets a Vector2 on a uniform variable.
  29419. * @param uniformName Name of the variable.
  29420. * @param vector2 vector2 to be set.
  29421. * @returns this effect.
  29422. */
  29423. setVector2(uniformName: string, vector2: Vector2): Effect;
  29424. /**
  29425. * Sets a float2 on a uniform variable.
  29426. * @param uniformName Name of the variable.
  29427. * @param x First float in float2.
  29428. * @param y Second float in float2.
  29429. * @returns this effect.
  29430. */
  29431. setFloat2(uniformName: string, x: number, y: number): Effect;
  29432. /**
  29433. * Sets a Vector3 on a uniform variable.
  29434. * @param uniformName Name of the variable.
  29435. * @param vector3 Value to be set.
  29436. * @returns this effect.
  29437. */
  29438. setVector3(uniformName: string, vector3: Vector3): Effect;
  29439. /**
  29440. * Sets a float3 on a uniform variable.
  29441. * @param uniformName Name of the variable.
  29442. * @param x First float in float3.
  29443. * @param y Second float in float3.
  29444. * @param z Third float in float3.
  29445. * @returns this effect.
  29446. */
  29447. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29448. /**
  29449. * Sets a Vector4 on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param vector4 Value to be set.
  29452. * @returns this effect.
  29453. */
  29454. setVector4(uniformName: string, vector4: Vector4): Effect;
  29455. /**
  29456. * Sets a float4 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param x First float in float4.
  29459. * @param y Second float in float4.
  29460. * @param z Third float in float4.
  29461. * @param w Fourth float in float4.
  29462. * @returns this effect.
  29463. */
  29464. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29465. /**
  29466. * Sets a Color3 on a uniform variable.
  29467. * @param uniformName Name of the variable.
  29468. * @param color3 Value to be set.
  29469. * @returns this effect.
  29470. */
  29471. setColor3(uniformName: string, color3: Color3): Effect;
  29472. /**
  29473. * Sets a Color4 on a uniform variable.
  29474. * @param uniformName Name of the variable.
  29475. * @param color3 Value to be set.
  29476. * @param alpha Alpha value to be set.
  29477. * @returns this effect.
  29478. */
  29479. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29480. /**
  29481. * Sets a Color4 on a uniform variable
  29482. * @param uniformName defines the name of the variable
  29483. * @param color4 defines the value to be set
  29484. * @returns this effect.
  29485. */
  29486. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29487. /**
  29488. * This function will add a new shader to the shader store
  29489. * @param name the name of the shader
  29490. * @param pixelShader optional pixel shader content
  29491. * @param vertexShader optional vertex shader content
  29492. */
  29493. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29494. /**
  29495. * Store of each shader (The can be looked up using effect.key)
  29496. */
  29497. static ShadersStore: {
  29498. [key: string]: string;
  29499. };
  29500. /**
  29501. * Store of each included file for a shader (The can be looked up using effect.key)
  29502. */
  29503. static IncludesShadersStore: {
  29504. [key: string]: string;
  29505. };
  29506. /**
  29507. * Resets the cache of effects.
  29508. */
  29509. static ResetCache(): void;
  29510. }
  29511. }
  29512. declare module "babylonjs/Materials/colorCurves" {
  29513. import { Effect } from "babylonjs/Materials/effect";
  29514. /**
  29515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29517. * 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;
  29518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29519. */
  29520. export class ColorCurves {
  29521. private _dirty;
  29522. private _tempColor;
  29523. private _globalCurve;
  29524. private _highlightsCurve;
  29525. private _midtonesCurve;
  29526. private _shadowsCurve;
  29527. private _positiveCurve;
  29528. private _negativeCurve;
  29529. private _globalHue;
  29530. private _globalDensity;
  29531. private _globalSaturation;
  29532. private _globalExposure;
  29533. /**
  29534. * Gets the global Hue value.
  29535. * 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).
  29536. */
  29537. /**
  29538. * Sets the global Hue value.
  29539. * 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).
  29540. */
  29541. globalHue: number;
  29542. /**
  29543. * Gets the global Density value.
  29544. * 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.
  29545. * Values less than zero provide a filter of opposite hue.
  29546. */
  29547. /**
  29548. * Sets the global Density value.
  29549. * 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.
  29550. * Values less than zero provide a filter of opposite hue.
  29551. */
  29552. globalDensity: number;
  29553. /**
  29554. * Gets the global Saturation value.
  29555. * 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.
  29556. */
  29557. /**
  29558. * Sets the global Saturation value.
  29559. * 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.
  29560. */
  29561. globalSaturation: number;
  29562. /**
  29563. * Gets the global Exposure value.
  29564. * 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.
  29565. */
  29566. /**
  29567. * Sets the global Exposure value.
  29568. * 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.
  29569. */
  29570. globalExposure: number;
  29571. private _highlightsHue;
  29572. private _highlightsDensity;
  29573. private _highlightsSaturation;
  29574. private _highlightsExposure;
  29575. /**
  29576. * Gets the highlights Hue value.
  29577. * 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).
  29578. */
  29579. /**
  29580. * Sets the highlights Hue value.
  29581. * 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).
  29582. */
  29583. highlightsHue: number;
  29584. /**
  29585. * Gets the highlights Density value.
  29586. * 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.
  29587. * Values less than zero provide a filter of opposite hue.
  29588. */
  29589. /**
  29590. * Sets the highlights Density value.
  29591. * 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.
  29592. * Values less than zero provide a filter of opposite hue.
  29593. */
  29594. highlightsDensity: number;
  29595. /**
  29596. * Gets the highlights Saturation value.
  29597. * 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.
  29598. */
  29599. /**
  29600. * Sets the highlights Saturation value.
  29601. * 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.
  29602. */
  29603. highlightsSaturation: number;
  29604. /**
  29605. * Gets the highlights Exposure value.
  29606. * 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.
  29607. */
  29608. /**
  29609. * Sets the highlights Exposure value.
  29610. * 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.
  29611. */
  29612. highlightsExposure: number;
  29613. private _midtonesHue;
  29614. private _midtonesDensity;
  29615. private _midtonesSaturation;
  29616. private _midtonesExposure;
  29617. /**
  29618. * Gets the midtones Hue value.
  29619. * 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).
  29620. */
  29621. /**
  29622. * Sets the midtones Hue value.
  29623. * 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).
  29624. */
  29625. midtonesHue: number;
  29626. /**
  29627. * Gets the midtones Density value.
  29628. * 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.
  29629. * Values less than zero provide a filter of opposite hue.
  29630. */
  29631. /**
  29632. * Sets the midtones Density value.
  29633. * 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.
  29634. * Values less than zero provide a filter of opposite hue.
  29635. */
  29636. midtonesDensity: number;
  29637. /**
  29638. * Gets the midtones Saturation value.
  29639. * 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.
  29640. */
  29641. /**
  29642. * Sets the midtones Saturation value.
  29643. * 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.
  29644. */
  29645. midtonesSaturation: number;
  29646. /**
  29647. * Gets the midtones Exposure value.
  29648. * 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.
  29649. */
  29650. /**
  29651. * Sets the midtones Exposure value.
  29652. * 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.
  29653. */
  29654. midtonesExposure: number;
  29655. private _shadowsHue;
  29656. private _shadowsDensity;
  29657. private _shadowsSaturation;
  29658. private _shadowsExposure;
  29659. /**
  29660. * Gets the shadows Hue value.
  29661. * 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).
  29662. */
  29663. /**
  29664. * Sets the shadows Hue value.
  29665. * 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).
  29666. */
  29667. shadowsHue: number;
  29668. /**
  29669. * Gets the shadows Density value.
  29670. * 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.
  29671. * Values less than zero provide a filter of opposite hue.
  29672. */
  29673. /**
  29674. * Sets the shadows Density value.
  29675. * 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.
  29676. * Values less than zero provide a filter of opposite hue.
  29677. */
  29678. shadowsDensity: number;
  29679. /**
  29680. * Gets the shadows Saturation value.
  29681. * 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.
  29682. */
  29683. /**
  29684. * Sets the shadows Saturation value.
  29685. * 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.
  29686. */
  29687. shadowsSaturation: number;
  29688. /**
  29689. * Gets the shadows Exposure value.
  29690. * 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.
  29691. */
  29692. /**
  29693. * Sets the shadows Exposure value.
  29694. * 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.
  29695. */
  29696. shadowsExposure: number;
  29697. /**
  29698. * Returns the class name
  29699. * @returns The class name
  29700. */
  29701. getClassName(): string;
  29702. /**
  29703. * Binds the color curves to the shader.
  29704. * @param colorCurves The color curve to bind
  29705. * @param effect The effect to bind to
  29706. * @param positiveUniform The positive uniform shader parameter
  29707. * @param neutralUniform The neutral uniform shader parameter
  29708. * @param negativeUniform The negative uniform shader parameter
  29709. */
  29710. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29711. /**
  29712. * Prepare the list of uniforms associated with the ColorCurves effects.
  29713. * @param uniformsList The list of uniforms used in the effect
  29714. */
  29715. static PrepareUniforms(uniformsList: string[]): void;
  29716. /**
  29717. * Returns color grading data based on a hue, density, saturation and exposure value.
  29718. * @param filterHue The hue of the color filter.
  29719. * @param filterDensity The density of the color filter.
  29720. * @param saturation The saturation.
  29721. * @param exposure The exposure.
  29722. * @param result The result data container.
  29723. */
  29724. private getColorGradingDataToRef;
  29725. /**
  29726. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29727. * @param value The input slider value in range [-100,100].
  29728. * @returns Adjusted value.
  29729. */
  29730. private static applyColorGradingSliderNonlinear;
  29731. /**
  29732. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29733. * @param hue The hue (H) input.
  29734. * @param saturation The saturation (S) input.
  29735. * @param brightness The brightness (B) input.
  29736. * @result An RGBA color represented as Vector4.
  29737. */
  29738. private static fromHSBToRef;
  29739. /**
  29740. * Returns a value clamped between min and max
  29741. * @param value The value to clamp
  29742. * @param min The minimum of value
  29743. * @param max The maximum of value
  29744. * @returns The clamped value.
  29745. */
  29746. private static clamp;
  29747. /**
  29748. * Clones the current color curve instance.
  29749. * @return The cloned curves
  29750. */
  29751. clone(): ColorCurves;
  29752. /**
  29753. * Serializes the current color curve instance to a json representation.
  29754. * @return a JSON representation
  29755. */
  29756. serialize(): any;
  29757. /**
  29758. * Parses the color curve from a json representation.
  29759. * @param source the JSON source to parse
  29760. * @return The parsed curves
  29761. */
  29762. static Parse(source: any): ColorCurves;
  29763. }
  29764. }
  29765. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29766. import { Observable } from "babylonjs/Misc/observable";
  29767. import { Nullable } from "babylonjs/types";
  29768. import { Color4 } from "babylonjs/Maths/math";
  29769. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29770. import { Effect } from "babylonjs/Materials/effect";
  29771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29772. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29773. /**
  29774. * Interface to follow in your material defines to integrate easily the
  29775. * Image proccessing functions.
  29776. * @hidden
  29777. */
  29778. export interface IImageProcessingConfigurationDefines {
  29779. IMAGEPROCESSING: boolean;
  29780. VIGNETTE: boolean;
  29781. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29782. VIGNETTEBLENDMODEOPAQUE: boolean;
  29783. TONEMAPPING: boolean;
  29784. TONEMAPPING_ACES: boolean;
  29785. CONTRAST: boolean;
  29786. EXPOSURE: boolean;
  29787. COLORCURVES: boolean;
  29788. COLORGRADING: boolean;
  29789. COLORGRADING3D: boolean;
  29790. SAMPLER3DGREENDEPTH: boolean;
  29791. SAMPLER3DBGRMAP: boolean;
  29792. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29793. }
  29794. /**
  29795. * @hidden
  29796. */
  29797. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29798. IMAGEPROCESSING: boolean;
  29799. VIGNETTE: boolean;
  29800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29801. VIGNETTEBLENDMODEOPAQUE: boolean;
  29802. TONEMAPPING: boolean;
  29803. TONEMAPPING_ACES: boolean;
  29804. CONTRAST: boolean;
  29805. COLORCURVES: boolean;
  29806. COLORGRADING: boolean;
  29807. COLORGRADING3D: boolean;
  29808. SAMPLER3DGREENDEPTH: boolean;
  29809. SAMPLER3DBGRMAP: boolean;
  29810. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29811. EXPOSURE: boolean;
  29812. constructor();
  29813. }
  29814. /**
  29815. * This groups together the common properties used for image processing either in direct forward pass
  29816. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29817. * or not.
  29818. */
  29819. export class ImageProcessingConfiguration {
  29820. /**
  29821. * Default tone mapping applied in BabylonJS.
  29822. */
  29823. static readonly TONEMAPPING_STANDARD: number;
  29824. /**
  29825. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29826. * to other engines rendering to increase portability.
  29827. */
  29828. static readonly TONEMAPPING_ACES: number;
  29829. /**
  29830. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29831. */
  29832. colorCurves: Nullable<ColorCurves>;
  29833. private _colorCurvesEnabled;
  29834. /**
  29835. * Gets wether the color curves effect is enabled.
  29836. */
  29837. /**
  29838. * Sets wether the color curves effect is enabled.
  29839. */
  29840. colorCurvesEnabled: boolean;
  29841. private _colorGradingTexture;
  29842. /**
  29843. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29844. */
  29845. /**
  29846. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29847. */
  29848. colorGradingTexture: Nullable<BaseTexture>;
  29849. private _colorGradingEnabled;
  29850. /**
  29851. * Gets wether the color grading effect is enabled.
  29852. */
  29853. /**
  29854. * Sets wether the color grading effect is enabled.
  29855. */
  29856. colorGradingEnabled: boolean;
  29857. private _colorGradingWithGreenDepth;
  29858. /**
  29859. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29860. */
  29861. /**
  29862. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29863. */
  29864. colorGradingWithGreenDepth: boolean;
  29865. private _colorGradingBGR;
  29866. /**
  29867. * Gets wether the color grading texture contains BGR values.
  29868. */
  29869. /**
  29870. * Sets wether the color grading texture contains BGR values.
  29871. */
  29872. colorGradingBGR: boolean;
  29873. /** @hidden */
  29874. _exposure: number;
  29875. /**
  29876. * Gets the Exposure used in the effect.
  29877. */
  29878. /**
  29879. * Sets the Exposure used in the effect.
  29880. */
  29881. exposure: number;
  29882. private _toneMappingEnabled;
  29883. /**
  29884. * Gets wether the tone mapping effect is enabled.
  29885. */
  29886. /**
  29887. * Sets wether the tone mapping effect is enabled.
  29888. */
  29889. toneMappingEnabled: boolean;
  29890. private _toneMappingType;
  29891. /**
  29892. * Gets the type of tone mapping effect.
  29893. */
  29894. /**
  29895. * Sets the type of tone mapping effect used in BabylonJS.
  29896. */
  29897. toneMappingType: number;
  29898. protected _contrast: number;
  29899. /**
  29900. * Gets the contrast used in the effect.
  29901. */
  29902. /**
  29903. * Sets the contrast used in the effect.
  29904. */
  29905. contrast: number;
  29906. /**
  29907. * Vignette stretch size.
  29908. */
  29909. vignetteStretch: number;
  29910. /**
  29911. * Vignette centre X Offset.
  29912. */
  29913. vignetteCentreX: number;
  29914. /**
  29915. * Vignette centre Y Offset.
  29916. */
  29917. vignetteCentreY: number;
  29918. /**
  29919. * Vignette weight or intensity of the vignette effect.
  29920. */
  29921. vignetteWeight: number;
  29922. /**
  29923. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29924. * if vignetteEnabled is set to true.
  29925. */
  29926. vignetteColor: Color4;
  29927. /**
  29928. * Camera field of view used by the Vignette effect.
  29929. */
  29930. vignetteCameraFov: number;
  29931. private _vignetteBlendMode;
  29932. /**
  29933. * Gets the vignette blend mode allowing different kind of effect.
  29934. */
  29935. /**
  29936. * Sets the vignette blend mode allowing different kind of effect.
  29937. */
  29938. vignetteBlendMode: number;
  29939. private _vignetteEnabled;
  29940. /**
  29941. * Gets wether the vignette effect is enabled.
  29942. */
  29943. /**
  29944. * Sets wether the vignette effect is enabled.
  29945. */
  29946. vignetteEnabled: boolean;
  29947. private _applyByPostProcess;
  29948. /**
  29949. * Gets wether the image processing is applied through a post process or not.
  29950. */
  29951. /**
  29952. * Sets wether the image processing is applied through a post process or not.
  29953. */
  29954. applyByPostProcess: boolean;
  29955. private _isEnabled;
  29956. /**
  29957. * Gets wether the image processing is enabled or not.
  29958. */
  29959. /**
  29960. * Sets wether the image processing is enabled or not.
  29961. */
  29962. isEnabled: boolean;
  29963. /**
  29964. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29965. */
  29966. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29967. /**
  29968. * Method called each time the image processing information changes requires to recompile the effect.
  29969. */
  29970. protected _updateParameters(): void;
  29971. /**
  29972. * Gets the current class name.
  29973. * @return "ImageProcessingConfiguration"
  29974. */
  29975. getClassName(): string;
  29976. /**
  29977. * Prepare the list of uniforms associated with the Image Processing effects.
  29978. * @param uniforms The list of uniforms used in the effect
  29979. * @param defines the list of defines currently in use
  29980. */
  29981. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29982. /**
  29983. * Prepare the list of samplers associated with the Image Processing effects.
  29984. * @param samplersList The list of uniforms used in the effect
  29985. * @param defines the list of defines currently in use
  29986. */
  29987. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29988. /**
  29989. * Prepare the list of defines associated to the shader.
  29990. * @param defines the list of defines to complete
  29991. * @param forPostProcess Define if we are currently in post process mode or not
  29992. */
  29993. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29994. /**
  29995. * Returns true if all the image processing information are ready.
  29996. * @returns True if ready, otherwise, false
  29997. */
  29998. isReady(): boolean;
  29999. /**
  30000. * Binds the image processing to the shader.
  30001. * @param effect The effect to bind to
  30002. * @param aspectRatio Define the current aspect ratio of the effect
  30003. */
  30004. bind(effect: Effect, aspectRatio?: number): void;
  30005. /**
  30006. * Clones the current image processing instance.
  30007. * @return The cloned image processing
  30008. */
  30009. clone(): ImageProcessingConfiguration;
  30010. /**
  30011. * Serializes the current image processing instance to a json representation.
  30012. * @return a JSON representation
  30013. */
  30014. serialize(): any;
  30015. /**
  30016. * Parses the image processing from a json representation.
  30017. * @param source the JSON source to parse
  30018. * @return The parsed image processing
  30019. */
  30020. static Parse(source: any): ImageProcessingConfiguration;
  30021. private static _VIGNETTEMODE_MULTIPLY;
  30022. private static _VIGNETTEMODE_OPAQUE;
  30023. /**
  30024. * Used to apply the vignette as a mix with the pixel color.
  30025. */
  30026. static readonly VIGNETTEMODE_MULTIPLY: number;
  30027. /**
  30028. * Used to apply the vignette as a replacement of the pixel color.
  30029. */
  30030. static readonly VIGNETTEMODE_OPAQUE: number;
  30031. }
  30032. }
  30033. declare module "babylonjs/Materials/fresnelParameters" {
  30034. import { Color3 } from "babylonjs/Maths/math";
  30035. /**
  30036. * This represents all the required information to add a fresnel effect on a material:
  30037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30038. */
  30039. export class FresnelParameters {
  30040. private _isEnabled;
  30041. /**
  30042. * Define if the fresnel effect is enable or not.
  30043. */
  30044. isEnabled: boolean;
  30045. /**
  30046. * Define the color used on edges (grazing angle)
  30047. */
  30048. leftColor: Color3;
  30049. /**
  30050. * Define the color used on center
  30051. */
  30052. rightColor: Color3;
  30053. /**
  30054. * Define bias applied to computed fresnel term
  30055. */
  30056. bias: number;
  30057. /**
  30058. * Defined the power exponent applied to fresnel term
  30059. */
  30060. power: number;
  30061. /**
  30062. * Clones the current fresnel and its valuues
  30063. * @returns a clone fresnel configuration
  30064. */
  30065. clone(): FresnelParameters;
  30066. /**
  30067. * Serializes the current fresnel parameters to a JSON representation.
  30068. * @return the JSON serialization
  30069. */
  30070. serialize(): any;
  30071. /**
  30072. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30073. * @param parsedFresnelParameters Define the JSON representation
  30074. * @returns the parsed parameters
  30075. */
  30076. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30077. }
  30078. }
  30079. declare module "babylonjs/Misc/decorators" {
  30080. import { Nullable } from "babylonjs/types";
  30081. import { Scene } from "babylonjs/scene";
  30082. import { IAnimatable } from "babylonjs/Misc/tools";
  30083. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30084. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30085. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30086. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30087. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30088. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30089. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30090. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30091. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30092. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30093. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30094. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30095. /**
  30096. * Decorator used to define property that can be serialized as reference to a camera
  30097. * @param sourceName defines the name of the property to decorate
  30098. */
  30099. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30100. /**
  30101. * Class used to help serialization objects
  30102. */
  30103. export class SerializationHelper {
  30104. /** hidden */
  30105. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30106. /** hidden */
  30107. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30108. /** hidden */
  30109. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30110. /** hidden */
  30111. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30112. /**
  30113. * Appends the serialized animations from the source animations
  30114. * @param source Source containing the animations
  30115. * @param destination Target to store the animations
  30116. */
  30117. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30118. /**
  30119. * Static function used to serialized a specific entity
  30120. * @param entity defines the entity to serialize
  30121. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30122. * @returns a JSON compatible object representing the serialization of the entity
  30123. */
  30124. static Serialize<T>(entity: T, serializationObject?: any): any;
  30125. /**
  30126. * Creates a new entity from a serialization data object
  30127. * @param creationFunction defines a function used to instanciated the new entity
  30128. * @param source defines the source serialization data
  30129. * @param scene defines the hosting scene
  30130. * @param rootUrl defines the root url for resources
  30131. * @returns a new entity
  30132. */
  30133. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30134. /**
  30135. * Clones an object
  30136. * @param creationFunction defines the function used to instanciate the new object
  30137. * @param source defines the source object
  30138. * @returns the cloned object
  30139. */
  30140. static Clone<T>(creationFunction: () => T, source: T): T;
  30141. /**
  30142. * Instanciates a new object based on a source one (some data will be shared between both object)
  30143. * @param creationFunction defines the function used to instanciate the new object
  30144. * @param source defines the source object
  30145. * @returns the new object
  30146. */
  30147. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30148. }
  30149. }
  30150. declare module "babylonjs/Cameras/camera" {
  30151. import { SmartArray } from "babylonjs/Misc/smartArray";
  30152. import { Observable } from "babylonjs/Misc/observable";
  30153. import { Nullable } from "babylonjs/types";
  30154. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30155. import { Scene } from "babylonjs/scene";
  30156. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30157. import { Node } from "babylonjs/node";
  30158. import { Mesh } from "babylonjs/Meshes/mesh";
  30159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30160. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30164. import { Ray } from "babylonjs/Culling/ray";
  30165. /**
  30166. * This is the base class of all the camera used in the application.
  30167. * @see http://doc.babylonjs.com/features/cameras
  30168. */
  30169. export class Camera extends Node {
  30170. /** @hidden */
  30171. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30172. /**
  30173. * This is the default projection mode used by the cameras.
  30174. * It helps recreating a feeling of perspective and better appreciate depth.
  30175. * This is the best way to simulate real life cameras.
  30176. */
  30177. static readonly PERSPECTIVE_CAMERA: number;
  30178. /**
  30179. * This helps creating camera with an orthographic mode.
  30180. * 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.
  30181. */
  30182. static readonly ORTHOGRAPHIC_CAMERA: number;
  30183. /**
  30184. * This is the default FOV mode for perspective cameras.
  30185. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30186. */
  30187. static readonly FOVMODE_VERTICAL_FIXED: number;
  30188. /**
  30189. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30190. */
  30191. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30192. /**
  30193. * This specifies ther is no need for a camera rig.
  30194. * Basically only one eye is rendered corresponding to the camera.
  30195. */
  30196. static readonly RIG_MODE_NONE: number;
  30197. /**
  30198. * Simulates a camera Rig with one blue eye and one red eye.
  30199. * This can be use with 3d blue and red glasses.
  30200. */
  30201. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30202. /**
  30203. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30204. */
  30205. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30206. /**
  30207. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30208. */
  30209. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30210. /**
  30211. * Defines that both eyes of the camera will be rendered over under each other.
  30212. */
  30213. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30214. /**
  30215. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30216. */
  30217. static readonly RIG_MODE_VR: number;
  30218. /**
  30219. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30220. */
  30221. static readonly RIG_MODE_WEBVR: number;
  30222. /**
  30223. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30224. */
  30225. static readonly RIG_MODE_CUSTOM: number;
  30226. /**
  30227. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30228. */
  30229. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30230. /**
  30231. * @hidden
  30232. * Might be removed once multiview will be a thing
  30233. */
  30234. static UseAlternateWebVRRendering: boolean;
  30235. /**
  30236. * Define the input manager associated with the camera.
  30237. */
  30238. inputs: CameraInputsManager<Camera>;
  30239. /** @hidden */
  30240. _position: Vector3;
  30241. /**
  30242. * Define the current local position of the camera in the scene
  30243. */
  30244. position: Vector3;
  30245. /**
  30246. * The vector the camera should consider as up.
  30247. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30248. */
  30249. upVector: Vector3;
  30250. /**
  30251. * Define the current limit on the left side for an orthographic camera
  30252. * In scene unit
  30253. */
  30254. orthoLeft: Nullable<number>;
  30255. /**
  30256. * Define the current limit on the right side for an orthographic camera
  30257. * In scene unit
  30258. */
  30259. orthoRight: Nullable<number>;
  30260. /**
  30261. * Define the current limit on the bottom side for an orthographic camera
  30262. * In scene unit
  30263. */
  30264. orthoBottom: Nullable<number>;
  30265. /**
  30266. * Define the current limit on the top side for an orthographic camera
  30267. * In scene unit
  30268. */
  30269. orthoTop: Nullable<number>;
  30270. /**
  30271. * Field Of View is set in Radians. (default is 0.8)
  30272. */
  30273. fov: number;
  30274. /**
  30275. * Define the minimum distance the camera can see from.
  30276. * This is important to note that the depth buffer are not infinite and the closer it starts
  30277. * the more your scene might encounter depth fighting issue.
  30278. */
  30279. minZ: number;
  30280. /**
  30281. * Define the maximum distance the camera can see to.
  30282. * This is important to note that the depth buffer are not infinite and the further it end
  30283. * the more your scene might encounter depth fighting issue.
  30284. */
  30285. maxZ: number;
  30286. /**
  30287. * Define the default inertia of the camera.
  30288. * This helps giving a smooth feeling to the camera movement.
  30289. */
  30290. inertia: number;
  30291. /**
  30292. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30293. */
  30294. mode: number;
  30295. /**
  30296. * Define wether the camera is intermediate.
  30297. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30298. */
  30299. isIntermediate: boolean;
  30300. /**
  30301. * Define the viewport of the camera.
  30302. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30303. */
  30304. viewport: Viewport;
  30305. /**
  30306. * Restricts the camera to viewing objects with the same layerMask.
  30307. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30308. */
  30309. layerMask: number;
  30310. /**
  30311. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30312. */
  30313. fovMode: number;
  30314. /**
  30315. * Rig mode of the camera.
  30316. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30317. * This is normally controlled byt the camera themselves as internal use.
  30318. */
  30319. cameraRigMode: number;
  30320. /**
  30321. * Defines the distance between both "eyes" in case of a RIG
  30322. */
  30323. interaxialDistance: number;
  30324. /**
  30325. * Defines if stereoscopic rendering is done side by side or over under.
  30326. */
  30327. isStereoscopicSideBySide: boolean;
  30328. /**
  30329. * 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
  30330. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30331. * else in the scene.
  30332. */
  30333. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30334. /**
  30335. * When set, the camera will render to this render target instead of the default canvas
  30336. */
  30337. outputRenderTarget: Nullable<RenderTargetTexture>;
  30338. /**
  30339. * Observable triggered when the camera view matrix has changed.
  30340. */
  30341. onViewMatrixChangedObservable: Observable<Camera>;
  30342. /**
  30343. * Observable triggered when the camera Projection matrix has changed.
  30344. */
  30345. onProjectionMatrixChangedObservable: Observable<Camera>;
  30346. /**
  30347. * Observable triggered when the inputs have been processed.
  30348. */
  30349. onAfterCheckInputsObservable: Observable<Camera>;
  30350. /**
  30351. * Observable triggered when reset has been called and applied to the camera.
  30352. */
  30353. onRestoreStateObservable: Observable<Camera>;
  30354. /** @hidden */
  30355. _cameraRigParams: any;
  30356. /** @hidden */
  30357. _rigCameras: Camera[];
  30358. /** @hidden */
  30359. _rigPostProcess: Nullable<PostProcess>;
  30360. protected _webvrViewMatrix: Matrix;
  30361. /** @hidden */
  30362. _skipRendering: boolean;
  30363. /** @hidden */
  30364. _alternateCamera: Camera;
  30365. /** @hidden */
  30366. _projectionMatrix: Matrix;
  30367. /** @hidden */
  30368. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30369. /** @hidden */
  30370. _activeMeshes: SmartArray<AbstractMesh>;
  30371. protected _globalPosition: Vector3;
  30372. /** hidden */
  30373. _computedViewMatrix: Matrix;
  30374. private _doNotComputeProjectionMatrix;
  30375. private _transformMatrix;
  30376. private _frustumPlanes;
  30377. private _refreshFrustumPlanes;
  30378. private _storedFov;
  30379. private _stateStored;
  30380. /**
  30381. * Instantiates a new camera object.
  30382. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30383. * @see http://doc.babylonjs.com/features/cameras
  30384. * @param name Defines the name of the camera in the scene
  30385. * @param position Defines the position of the camera
  30386. * @param scene Defines the scene the camera belongs too
  30387. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30388. */
  30389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30390. /**
  30391. * Store current camera state (fov, position, etc..)
  30392. * @returns the camera
  30393. */
  30394. storeState(): Camera;
  30395. /**
  30396. * Restores the camera state values if it has been stored. You must call storeState() first
  30397. */
  30398. protected _restoreStateValues(): boolean;
  30399. /**
  30400. * Restored camera state. You must call storeState() first.
  30401. * @returns true if restored and false otherwise
  30402. */
  30403. restoreState(): boolean;
  30404. /**
  30405. * Gets the class name of the camera.
  30406. * @returns the class name
  30407. */
  30408. getClassName(): string;
  30409. /** @hidden */
  30410. readonly _isCamera: boolean;
  30411. /**
  30412. * Gets a string representation of the camera useful for debug purpose.
  30413. * @param fullDetails Defines that a more verboe level of logging is required
  30414. * @returns the string representation
  30415. */
  30416. toString(fullDetails?: boolean): string;
  30417. /**
  30418. * Gets the current world space position of the camera.
  30419. */
  30420. readonly globalPosition: Vector3;
  30421. /**
  30422. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30423. * @returns the active meshe list
  30424. */
  30425. getActiveMeshes(): SmartArray<AbstractMesh>;
  30426. /**
  30427. * Check wether a mesh is part of the current active mesh list of the camera
  30428. * @param mesh Defines the mesh to check
  30429. * @returns true if active, false otherwise
  30430. */
  30431. isActiveMesh(mesh: Mesh): boolean;
  30432. /**
  30433. * Is this camera ready to be used/rendered
  30434. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30435. * @return true if the camera is ready
  30436. */
  30437. isReady(completeCheck?: boolean): boolean;
  30438. /** @hidden */
  30439. _initCache(): void;
  30440. /** @hidden */
  30441. _updateCache(ignoreParentClass?: boolean): void;
  30442. /** @hidden */
  30443. _isSynchronized(): boolean;
  30444. /** @hidden */
  30445. _isSynchronizedViewMatrix(): boolean;
  30446. /** @hidden */
  30447. _isSynchronizedProjectionMatrix(): boolean;
  30448. /**
  30449. * Attach the input controls to a specific dom element to get the input from.
  30450. * @param element Defines the element the controls should be listened from
  30451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30452. */
  30453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30454. /**
  30455. * Detach the current controls from the specified dom element.
  30456. * @param element Defines the element to stop listening the inputs from
  30457. */
  30458. detachControl(element: HTMLElement): void;
  30459. /**
  30460. * Update the camera state according to the different inputs gathered during the frame.
  30461. */
  30462. update(): void;
  30463. /** @hidden */
  30464. _checkInputs(): void;
  30465. /** @hidden */
  30466. readonly rigCameras: Camera[];
  30467. /**
  30468. * Gets the post process used by the rig cameras
  30469. */
  30470. readonly rigPostProcess: Nullable<PostProcess>;
  30471. /**
  30472. * Internal, gets the first post proces.
  30473. * @returns the first post process to be run on this camera.
  30474. */
  30475. _getFirstPostProcess(): Nullable<PostProcess>;
  30476. private _cascadePostProcessesToRigCams;
  30477. /**
  30478. * Attach a post process to the camera.
  30479. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30480. * @param postProcess The post process to attach to the camera
  30481. * @param insertAt The position of the post process in case several of them are in use in the scene
  30482. * @returns the position the post process has been inserted at
  30483. */
  30484. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30485. /**
  30486. * Detach a post process to the camera.
  30487. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30488. * @param postProcess The post process to detach from the camera
  30489. */
  30490. detachPostProcess(postProcess: PostProcess): void;
  30491. /**
  30492. * Gets the current world matrix of the camera
  30493. */
  30494. getWorldMatrix(): Matrix;
  30495. /** @hidden */
  30496. _getViewMatrix(): Matrix;
  30497. /**
  30498. * Gets the current view matrix of the camera.
  30499. * @param force forces the camera to recompute the matrix without looking at the cached state
  30500. * @returns the view matrix
  30501. */
  30502. getViewMatrix(force?: boolean): Matrix;
  30503. /**
  30504. * Freeze the projection matrix.
  30505. * It will prevent the cache check of the camera projection compute and can speed up perf
  30506. * if no parameter of the camera are meant to change
  30507. * @param projection Defines manually a projection if necessary
  30508. */
  30509. freezeProjectionMatrix(projection?: Matrix): void;
  30510. /**
  30511. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30512. */
  30513. unfreezeProjectionMatrix(): void;
  30514. /**
  30515. * Gets the current projection matrix of the camera.
  30516. * @param force forces the camera to recompute the matrix without looking at the cached state
  30517. * @returns the projection matrix
  30518. */
  30519. getProjectionMatrix(force?: boolean): Matrix;
  30520. /**
  30521. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30522. * @returns a Matrix
  30523. */
  30524. getTransformationMatrix(): Matrix;
  30525. private _updateFrustumPlanes;
  30526. /**
  30527. * Checks if a cullable object (mesh...) is in the camera frustum
  30528. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30529. * @param target The object to check
  30530. * @returns true if the object is in frustum otherwise false
  30531. */
  30532. isInFrustum(target: ICullable): boolean;
  30533. /**
  30534. * Checks if a cullable object (mesh...) is in the camera frustum
  30535. * Unlike isInFrustum this cheks the full bounding box
  30536. * @param target The object to check
  30537. * @returns true if the object is in frustum otherwise false
  30538. */
  30539. isCompletelyInFrustum(target: ICullable): boolean;
  30540. /**
  30541. * Gets a ray in the forward direction from the camera.
  30542. * @param length Defines the length of the ray to create
  30543. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30544. * @param origin Defines the start point of the ray which defaults to the camera position
  30545. * @returns the forward ray
  30546. */
  30547. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30548. /**
  30549. * Releases resources associated with this node.
  30550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30552. */
  30553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30554. /** @hidden */
  30555. _isLeftCamera: boolean;
  30556. /**
  30557. * Gets the left camera of a rig setup in case of Rigged Camera
  30558. */
  30559. readonly isLeftCamera: boolean;
  30560. /** @hidden */
  30561. _isRightCamera: boolean;
  30562. /**
  30563. * Gets the right camera of a rig setup in case of Rigged Camera
  30564. */
  30565. readonly isRightCamera: boolean;
  30566. /**
  30567. * Gets the left camera of a rig setup in case of Rigged Camera
  30568. */
  30569. readonly leftCamera: Nullable<FreeCamera>;
  30570. /**
  30571. * Gets the right camera of a rig setup in case of Rigged Camera
  30572. */
  30573. readonly rightCamera: Nullable<FreeCamera>;
  30574. /**
  30575. * Gets the left camera target of a rig setup in case of Rigged Camera
  30576. * @returns the target position
  30577. */
  30578. getLeftTarget(): Nullable<Vector3>;
  30579. /**
  30580. * Gets the right camera target of a rig setup in case of Rigged Camera
  30581. * @returns the target position
  30582. */
  30583. getRightTarget(): Nullable<Vector3>;
  30584. /**
  30585. * @hidden
  30586. */
  30587. setCameraRigMode(mode: number, rigParams: any): void;
  30588. /** @hidden */
  30589. static _setStereoscopicRigMode(camera: Camera): void;
  30590. /** @hidden */
  30591. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30592. /** @hidden */
  30593. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30594. /** @hidden */
  30595. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30596. /** @hidden */
  30597. _getVRProjectionMatrix(): Matrix;
  30598. protected _updateCameraRotationMatrix(): void;
  30599. protected _updateWebVRCameraRotationMatrix(): void;
  30600. /**
  30601. * This function MUST be overwritten by the different WebVR cameras available.
  30602. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30603. * @hidden
  30604. */
  30605. _getWebVRProjectionMatrix(): Matrix;
  30606. /**
  30607. * This function MUST be overwritten by the different WebVR cameras available.
  30608. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30609. * @hidden
  30610. */
  30611. _getWebVRViewMatrix(): Matrix;
  30612. /** @hidden */
  30613. setCameraRigParameter(name: string, value: any): void;
  30614. /**
  30615. * needs to be overridden by children so sub has required properties to be copied
  30616. * @hidden
  30617. */
  30618. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30619. /**
  30620. * May need to be overridden by children
  30621. * @hidden
  30622. */
  30623. _updateRigCameras(): void;
  30624. /** @hidden */
  30625. _setupInputs(): void;
  30626. /**
  30627. * Serialiaze the camera setup to a json represention
  30628. * @returns the JSON representation
  30629. */
  30630. serialize(): any;
  30631. /**
  30632. * Clones the current camera.
  30633. * @param name The cloned camera name
  30634. * @returns the cloned camera
  30635. */
  30636. clone(name: string): Camera;
  30637. /**
  30638. * Gets the direction of the camera relative to a given local axis.
  30639. * @param localAxis Defines the reference axis to provide a relative direction.
  30640. * @return the direction
  30641. */
  30642. getDirection(localAxis: Vector3): Vector3;
  30643. /**
  30644. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30645. * @param localAxis Defines the reference axis to provide a relative direction.
  30646. * @param result Defines the vector to store the result in
  30647. */
  30648. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30649. /**
  30650. * Gets a camera constructor for a given camera type
  30651. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30652. * @param name The name of the camera the result will be able to instantiate
  30653. * @param scene The scene the result will construct the camera in
  30654. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30655. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30656. * @returns a factory method to construc the camera
  30657. */
  30658. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30659. /**
  30660. * Compute the world matrix of the camera.
  30661. * @returns the camera workd matrix
  30662. */
  30663. computeWorldMatrix(): Matrix;
  30664. /**
  30665. * Parse a JSON and creates the camera from the parsed information
  30666. * @param parsedCamera The JSON to parse
  30667. * @param scene The scene to instantiate the camera in
  30668. * @returns the newly constructed camera
  30669. */
  30670. static Parse(parsedCamera: any, scene: Scene): Camera;
  30671. }
  30672. }
  30673. declare module "babylonjs/Misc/tools" {
  30674. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30675. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30676. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30677. import { Observable } from "babylonjs/Misc/observable";
  30678. import { DomManagement } from "babylonjs/Misc/domManagement";
  30679. import { Camera } from "babylonjs/Cameras/camera";
  30680. import { Engine } from "babylonjs/Engines/engine";
  30681. import { Animation } from "babylonjs/Animations/animation";
  30682. /**
  30683. * Interface for any object that can request an animation frame
  30684. */
  30685. export interface ICustomAnimationFrameRequester {
  30686. /**
  30687. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30688. */
  30689. renderFunction?: Function;
  30690. /**
  30691. * Called to request the next frame to render to
  30692. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30693. */
  30694. requestAnimationFrame: Function;
  30695. /**
  30696. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30697. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30698. */
  30699. requestID?: number;
  30700. }
  30701. /**
  30702. * Interface containing an array of animations
  30703. */
  30704. export interface IAnimatable {
  30705. /**
  30706. * Array of animations
  30707. */
  30708. animations: Array<Animation>;
  30709. }
  30710. /** Interface used by value gradients (color, factor, ...) */
  30711. export interface IValueGradient {
  30712. /**
  30713. * Gets or sets the gradient value (between 0 and 1)
  30714. */
  30715. gradient: number;
  30716. }
  30717. /** Class used to store color4 gradient */
  30718. export class ColorGradient implements IValueGradient {
  30719. /**
  30720. * Gets or sets the gradient value (between 0 and 1)
  30721. */
  30722. gradient: number;
  30723. /**
  30724. * Gets or sets first associated color
  30725. */
  30726. color1: Color4;
  30727. /**
  30728. * Gets or sets second associated color
  30729. */
  30730. color2?: Color4;
  30731. /**
  30732. * Will get a color picked randomly between color1 and color2.
  30733. * If color2 is undefined then color1 will be used
  30734. * @param result defines the target Color4 to store the result in
  30735. */
  30736. getColorToRef(result: Color4): void;
  30737. }
  30738. /** Class used to store color 3 gradient */
  30739. export class Color3Gradient implements IValueGradient {
  30740. /**
  30741. * Gets or sets the gradient value (between 0 and 1)
  30742. */
  30743. gradient: number;
  30744. /**
  30745. * Gets or sets the associated color
  30746. */
  30747. color: Color3;
  30748. }
  30749. /** Class used to store factor gradient */
  30750. export class FactorGradient implements IValueGradient {
  30751. /**
  30752. * Gets or sets the gradient value (between 0 and 1)
  30753. */
  30754. gradient: number;
  30755. /**
  30756. * Gets or sets first associated factor
  30757. */
  30758. factor1: number;
  30759. /**
  30760. * Gets or sets second associated factor
  30761. */
  30762. factor2?: number;
  30763. /**
  30764. * Will get a number picked randomly between factor1 and factor2.
  30765. * If factor2 is undefined then factor1 will be used
  30766. * @returns the picked number
  30767. */
  30768. getFactor(): number;
  30769. }
  30770. /**
  30771. * @ignore
  30772. * Application error to support additional information when loading a file
  30773. */
  30774. export class LoadFileError extends Error {
  30775. /** defines the optional XHR request */
  30776. request?: XMLHttpRequest | undefined;
  30777. private static _setPrototypeOf;
  30778. /**
  30779. * Creates a new LoadFileError
  30780. * @param message defines the message of the error
  30781. * @param request defines the optional XHR request
  30782. */
  30783. constructor(message: string,
  30784. /** defines the optional XHR request */
  30785. request?: XMLHttpRequest | undefined);
  30786. }
  30787. /**
  30788. * Class used to define a retry strategy when error happens while loading assets
  30789. */
  30790. export class RetryStrategy {
  30791. /**
  30792. * Function used to defines an exponential back off strategy
  30793. * @param maxRetries defines the maximum number of retries (3 by default)
  30794. * @param baseInterval defines the interval between retries
  30795. * @returns the strategy function to use
  30796. */
  30797. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30798. }
  30799. /**
  30800. * File request interface
  30801. */
  30802. export interface IFileRequest {
  30803. /**
  30804. * Raised when the request is complete (success or error).
  30805. */
  30806. onCompleteObservable: Observable<IFileRequest>;
  30807. /**
  30808. * Aborts the request for a file.
  30809. */
  30810. abort: () => void;
  30811. }
  30812. /**
  30813. * Class containing a set of static utilities functions
  30814. */
  30815. export class Tools {
  30816. /**
  30817. * Gets or sets the base URL to use to load assets
  30818. */
  30819. static BaseUrl: string;
  30820. /**
  30821. * Enable/Disable Custom HTTP Request Headers globally.
  30822. * default = false
  30823. * @see CustomRequestHeaders
  30824. */
  30825. static UseCustomRequestHeaders: boolean;
  30826. /**
  30827. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30828. * i.e. when loading files, where the server/service expects an Authorization header.
  30829. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30830. */
  30831. static CustomRequestHeaders: {
  30832. [key: string]: string;
  30833. };
  30834. /**
  30835. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30836. */
  30837. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30838. /**
  30839. * Default behaviour for cors in the application.
  30840. * It can be a string if the expected behavior is identical in the entire app.
  30841. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30842. */
  30843. static CorsBehavior: string | ((url: string | string[]) => string);
  30844. /**
  30845. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30846. * @ignorenaming
  30847. */
  30848. static UseFallbackTexture: boolean;
  30849. /**
  30850. * Use this object to register external classes like custom textures or material
  30851. * to allow the laoders to instantiate them
  30852. */
  30853. static RegisteredExternalClasses: {
  30854. [key: string]: Object;
  30855. };
  30856. /**
  30857. * Texture content used if a texture cannot loaded
  30858. * @ignorenaming
  30859. */
  30860. static fallbackTexture: string;
  30861. /**
  30862. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30863. * @param u defines the coordinate on X axis
  30864. * @param v defines the coordinate on Y axis
  30865. * @param width defines the width of the source data
  30866. * @param height defines the height of the source data
  30867. * @param pixels defines the source byte array
  30868. * @param color defines the output color
  30869. */
  30870. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30871. /**
  30872. * Interpolates between a and b via alpha
  30873. * @param a The lower value (returned when alpha = 0)
  30874. * @param b The upper value (returned when alpha = 1)
  30875. * @param alpha The interpolation-factor
  30876. * @return The mixed value
  30877. */
  30878. static Mix(a: number, b: number, alpha: number): number;
  30879. /**
  30880. * Tries to instantiate a new object from a given class name
  30881. * @param className defines the class name to instantiate
  30882. * @returns the new object or null if the system was not able to do the instantiation
  30883. */
  30884. static Instantiate(className: string): any;
  30885. /**
  30886. * Provides a slice function that will work even on IE
  30887. * @param data defines the array to slice
  30888. * @param start defines the start of the data (optional)
  30889. * @param end defines the end of the data (optional)
  30890. * @returns the new sliced array
  30891. */
  30892. static Slice<T>(data: T, start?: number, end?: number): T;
  30893. /**
  30894. * Polyfill for setImmediate
  30895. * @param action defines the action to execute after the current execution block
  30896. */
  30897. static SetImmediate(action: () => void): void;
  30898. /**
  30899. * Function indicating if a number is an exponent of 2
  30900. * @param value defines the value to test
  30901. * @returns true if the value is an exponent of 2
  30902. */
  30903. static IsExponentOfTwo(value: number): boolean;
  30904. private static _tmpFloatArray;
  30905. /**
  30906. * Returns the nearest 32-bit single precision float representation of a Number
  30907. * @param value A Number. If the parameter is of a different type, it will get converted
  30908. * to a number or to NaN if it cannot be converted
  30909. * @returns number
  30910. */
  30911. static FloatRound(value: number): number;
  30912. /**
  30913. * Find the next highest power of two.
  30914. * @param x Number to start search from.
  30915. * @return Next highest power of two.
  30916. */
  30917. static CeilingPOT(x: number): number;
  30918. /**
  30919. * Find the next lowest power of two.
  30920. * @param x Number to start search from.
  30921. * @return Next lowest power of two.
  30922. */
  30923. static FloorPOT(x: number): number;
  30924. /**
  30925. * Find the nearest power of two.
  30926. * @param x Number to start search from.
  30927. * @return Next nearest power of two.
  30928. */
  30929. static NearestPOT(x: number): number;
  30930. /**
  30931. * Get the closest exponent of two
  30932. * @param value defines the value to approximate
  30933. * @param max defines the maximum value to return
  30934. * @param mode defines how to define the closest value
  30935. * @returns closest exponent of two of the given value
  30936. */
  30937. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30938. /**
  30939. * Extracts the filename from a path
  30940. * @param path defines the path to use
  30941. * @returns the filename
  30942. */
  30943. static GetFilename(path: string): string;
  30944. /**
  30945. * Extracts the "folder" part of a path (everything before the filename).
  30946. * @param uri The URI to extract the info from
  30947. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30948. * @returns The "folder" part of the path
  30949. */
  30950. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30951. /**
  30952. * Extracts text content from a DOM element hierarchy
  30953. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30954. */
  30955. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30956. /**
  30957. * Convert an angle in radians to degrees
  30958. * @param angle defines the angle to convert
  30959. * @returns the angle in degrees
  30960. */
  30961. static ToDegrees(angle: number): number;
  30962. /**
  30963. * Convert an angle in degrees to radians
  30964. * @param angle defines the angle to convert
  30965. * @returns the angle in radians
  30966. */
  30967. static ToRadians(angle: number): number;
  30968. /**
  30969. * Encode a buffer to a base64 string
  30970. * @param buffer defines the buffer to encode
  30971. * @returns the encoded string
  30972. */
  30973. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30974. /**
  30975. * Extracts minimum and maximum values from a list of indexed positions
  30976. * @param positions defines the positions to use
  30977. * @param indices defines the indices to the positions
  30978. * @param indexStart defines the start index
  30979. * @param indexCount defines the end index
  30980. * @param bias defines bias value to add to the result
  30981. * @return minimum and maximum values
  30982. */
  30983. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30984. minimum: Vector3;
  30985. maximum: Vector3;
  30986. };
  30987. /**
  30988. * Extracts minimum and maximum values from a list of positions
  30989. * @param positions defines the positions to use
  30990. * @param start defines the start index in the positions array
  30991. * @param count defines the number of positions to handle
  30992. * @param bias defines bias value to add to the result
  30993. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30994. * @return minimum and maximum values
  30995. */
  30996. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30997. minimum: Vector3;
  30998. maximum: Vector3;
  30999. };
  31000. /**
  31001. * Returns an array if obj is not an array
  31002. * @param obj defines the object to evaluate as an array
  31003. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31004. * @returns either obj directly if obj is an array or a new array containing obj
  31005. */
  31006. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31007. /**
  31008. * Gets the pointer prefix to use
  31009. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31010. */
  31011. static GetPointerPrefix(): string;
  31012. /**
  31013. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31014. * @param func - the function to be called
  31015. * @param requester - the object that will request the next frame. Falls back to window.
  31016. * @returns frame number
  31017. */
  31018. static QueueNewFrame(func: () => void, requester?: any): number;
  31019. /**
  31020. * Ask the browser to promote the current element to fullscreen rendering mode
  31021. * @param element defines the DOM element to promote
  31022. */
  31023. static RequestFullscreen(element: HTMLElement): void;
  31024. /**
  31025. * Asks the browser to exit fullscreen mode
  31026. */
  31027. static ExitFullscreen(): void;
  31028. /**
  31029. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31030. * @param url define the url we are trying
  31031. * @param element define the dom element where to configure the cors policy
  31032. */
  31033. static SetCorsBehavior(url: string | string[], element: {
  31034. crossOrigin: string | null;
  31035. }): void;
  31036. /**
  31037. * Removes unwanted characters from an url
  31038. * @param url defines the url to clean
  31039. * @returns the cleaned url
  31040. */
  31041. static CleanUrl(url: string): string;
  31042. /**
  31043. * Gets or sets a function used to pre-process url before using them to load assets
  31044. */
  31045. static PreprocessUrl: (url: string) => string;
  31046. /**
  31047. * Loads an image as an HTMLImageElement.
  31048. * @param input url string, ArrayBuffer, or Blob to load
  31049. * @param onLoad callback called when the image successfully loads
  31050. * @param onError callback called when the image fails to load
  31051. * @param offlineProvider offline provider for caching
  31052. * @returns the HTMLImageElement of the loaded image
  31053. */
  31054. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31055. /**
  31056. * Loads a file
  31057. * @param url url string, ArrayBuffer, or Blob to load
  31058. * @param onSuccess callback called when the file successfully loads
  31059. * @param onProgress callback called while file is loading (if the server supports this mode)
  31060. * @param offlineProvider defines the offline provider for caching
  31061. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31062. * @param onError callback called when the file fails to load
  31063. * @returns a file request object
  31064. */
  31065. 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;
  31066. /**
  31067. * Load a script (identified by an url). When the url returns, the
  31068. * content of this file is added into a new script element, attached to the DOM (body element)
  31069. * @param scriptUrl defines the url of the script to laod
  31070. * @param onSuccess defines the callback called when the script is loaded
  31071. * @param onError defines the callback to call if an error occurs
  31072. */
  31073. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31074. /**
  31075. * Loads a file from a blob
  31076. * @param fileToLoad defines the blob to use
  31077. * @param callback defines the callback to call when data is loaded
  31078. * @param progressCallback defines the callback to call during loading process
  31079. * @returns a file request object
  31080. */
  31081. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31082. /**
  31083. * Loads a file
  31084. * @param fileToLoad defines the file to load
  31085. * @param callback defines the callback to call when data is loaded
  31086. * @param progressCallBack defines the callback to call during loading process
  31087. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31088. * @returns a file request object
  31089. */
  31090. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31091. /**
  31092. * Creates a data url from a given string content
  31093. * @param content defines the content to convert
  31094. * @returns the new data url link
  31095. */
  31096. static FileAsURL(content: string): string;
  31097. /**
  31098. * Format the given number to a specific decimal format
  31099. * @param value defines the number to format
  31100. * @param decimals defines the number of decimals to use
  31101. * @returns the formatted string
  31102. */
  31103. static Format(value: number, decimals?: number): string;
  31104. /**
  31105. * Checks if a given vector is inside a specific range
  31106. * @param v defines the vector to test
  31107. * @param min defines the minimum range
  31108. * @param max defines the maximum range
  31109. */
  31110. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31111. /**
  31112. * Tries to copy an object by duplicating every property
  31113. * @param source defines the source object
  31114. * @param destination defines the target object
  31115. * @param doNotCopyList defines a list of properties to avoid
  31116. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31117. */
  31118. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31119. /**
  31120. * Gets a boolean indicating if the given object has no own property
  31121. * @param obj defines the object to test
  31122. * @returns true if object has no own property
  31123. */
  31124. static IsEmpty(obj: any): boolean;
  31125. /**
  31126. * Function used to register events at window level
  31127. * @param events defines the events to register
  31128. */
  31129. static RegisterTopRootEvents(events: {
  31130. name: string;
  31131. handler: Nullable<(e: FocusEvent) => any>;
  31132. }[]): void;
  31133. /**
  31134. * Function used to unregister events from window level
  31135. * @param events defines the events to unregister
  31136. */
  31137. static UnregisterTopRootEvents(events: {
  31138. name: string;
  31139. handler: Nullable<(e: FocusEvent) => any>;
  31140. }[]): void;
  31141. /**
  31142. * @ignore
  31143. */
  31144. static _ScreenshotCanvas: HTMLCanvasElement;
  31145. /**
  31146. * Dumps the current bound framebuffer
  31147. * @param width defines the rendering width
  31148. * @param height defines the rendering height
  31149. * @param engine defines the hosting engine
  31150. * @param successCallback defines the callback triggered once the data are available
  31151. * @param mimeType defines the mime type of the result
  31152. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31153. */
  31154. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31155. /**
  31156. * Converts the canvas data to blob.
  31157. * This acts as a polyfill for browsers not supporting the to blob function.
  31158. * @param canvas Defines the canvas to extract the data from
  31159. * @param successCallback Defines the callback triggered once the data are available
  31160. * @param mimeType Defines the mime type of the result
  31161. */
  31162. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31163. /**
  31164. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31165. * @param successCallback defines the callback triggered once the data are available
  31166. * @param mimeType defines the mime type of the result
  31167. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31168. */
  31169. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31170. /**
  31171. * Downloads a blob in the browser
  31172. * @param blob defines the blob to download
  31173. * @param fileName defines the name of the downloaded file
  31174. */
  31175. static Download(blob: Blob, fileName: string): void;
  31176. /**
  31177. * Captures a screenshot of the current rendering
  31178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31179. * @param engine defines the rendering engine
  31180. * @param camera defines the source camera
  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 defines 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 defines the MIME type of the screenshot image (default: image/png).
  31190. * Check your browser for supported MIME types
  31191. */
  31192. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31193. /**
  31194. * Generates an image screenshot from the specified camera.
  31195. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31196. * @param engine The engine to use for rendering
  31197. * @param camera The camera to use for rendering
  31198. * @param size This parameter can be set to a single number or to an object with the
  31199. * following (optional) properties: precision, width, height. If a single number is passed,
  31200. * it will be used for both width and height. If an object is passed, the screenshot size
  31201. * will be derived from the parameters. The precision property is a multiplier allowing
  31202. * rendering at a higher or lower resolution
  31203. * @param successCallback The callback receives a single parameter which contains the
  31204. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31205. * src parameter of an <img> to display it
  31206. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31207. * Check your browser for supported MIME types
  31208. * @param samples Texture samples (default: 1)
  31209. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31210. * @param fileName A name for for the downloaded file.
  31211. */
  31212. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31213. /**
  31214. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31215. * Be aware Math.random() could cause collisions, but:
  31216. * "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"
  31217. * @returns a pseudo random id
  31218. */
  31219. static RandomId(): string;
  31220. /**
  31221. * Test if the given uri is a base64 string
  31222. * @param uri The uri to test
  31223. * @return True if the uri is a base64 string or false otherwise
  31224. */
  31225. static IsBase64(uri: string): boolean;
  31226. /**
  31227. * Decode the given base64 uri.
  31228. * @param uri The uri to decode
  31229. * @return The decoded base64 data.
  31230. */
  31231. static DecodeBase64(uri: string): ArrayBuffer;
  31232. /**
  31233. * No log
  31234. */
  31235. static readonly NoneLogLevel: number;
  31236. /**
  31237. * Only message logs
  31238. */
  31239. static readonly MessageLogLevel: number;
  31240. /**
  31241. * Only warning logs
  31242. */
  31243. static readonly WarningLogLevel: number;
  31244. /**
  31245. * Only error logs
  31246. */
  31247. static readonly ErrorLogLevel: number;
  31248. /**
  31249. * All logs
  31250. */
  31251. static readonly AllLogLevel: number;
  31252. /**
  31253. * Gets a value indicating the number of loading errors
  31254. * @ignorenaming
  31255. */
  31256. static readonly errorsCount: number;
  31257. /**
  31258. * Callback called when a new log is added
  31259. */
  31260. static OnNewCacheEntry: (entry: string) => void;
  31261. /**
  31262. * Log a message to the console
  31263. * @param message defines the message to log
  31264. */
  31265. static Log(message: string): void;
  31266. /**
  31267. * Write a warning message to the console
  31268. * @param message defines the message to log
  31269. */
  31270. static Warn(message: string): void;
  31271. /**
  31272. * Write an error message to the console
  31273. * @param message defines the message to log
  31274. */
  31275. static Error(message: string): void;
  31276. /**
  31277. * Gets current log cache (list of logs)
  31278. */
  31279. static readonly LogCache: string;
  31280. /**
  31281. * Clears the log cache
  31282. */
  31283. static ClearLogCache(): void;
  31284. /**
  31285. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31286. */
  31287. static LogLevels: number;
  31288. /**
  31289. * Checks if the loaded document was accessed via `file:`-Protocol.
  31290. * @returns boolean
  31291. */
  31292. static IsFileURL(): boolean;
  31293. /**
  31294. * Checks if the window object exists
  31295. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31296. */
  31297. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31298. /**
  31299. * No performance log
  31300. */
  31301. static readonly PerformanceNoneLogLevel: number;
  31302. /**
  31303. * Use user marks to log performance
  31304. */
  31305. static readonly PerformanceUserMarkLogLevel: number;
  31306. /**
  31307. * Log performance to the console
  31308. */
  31309. static readonly PerformanceConsoleLogLevel: number;
  31310. private static _performance;
  31311. /**
  31312. * Sets the current performance log level
  31313. */
  31314. static PerformanceLogLevel: number;
  31315. private static _StartPerformanceCounterDisabled;
  31316. private static _EndPerformanceCounterDisabled;
  31317. private static _StartUserMark;
  31318. private static _EndUserMark;
  31319. private static _StartPerformanceConsole;
  31320. private static _EndPerformanceConsole;
  31321. /**
  31322. * Injects the @see CustomRequestHeaders into the given request
  31323. * @param request the request that should be used for injection
  31324. */
  31325. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31326. /**
  31327. * Starts a performance counter
  31328. */
  31329. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31330. /**
  31331. * Ends a specific performance coutner
  31332. */
  31333. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31334. /**
  31335. * Gets either window.performance.now() if supported or Date.now() else
  31336. */
  31337. static readonly Now: number;
  31338. /**
  31339. * This method will return the name of the class used to create the instance of the given object.
  31340. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31341. * @param object the object to get the class name from
  31342. * @param isType defines if the object is actually a type
  31343. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31344. */
  31345. static GetClassName(object: any, isType?: boolean): string;
  31346. /**
  31347. * Gets the first element of an array satisfying a given predicate
  31348. * @param array defines the array to browse
  31349. * @param predicate defines the predicate to use
  31350. * @returns null if not found or the element
  31351. */
  31352. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31353. /**
  31354. * This method will return the name of the full name of the class, including its owning module (if any).
  31355. * 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).
  31356. * @param object the object to get the class name from
  31357. * @param isType defines if the object is actually a type
  31358. * @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.
  31359. * @ignorenaming
  31360. */
  31361. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31362. /**
  31363. * Returns a promise that resolves after the given amount of time.
  31364. * @param delay Number of milliseconds to delay
  31365. * @returns Promise that resolves after the given amount of time
  31366. */
  31367. static DelayAsync(delay: number): Promise<void>;
  31368. /**
  31369. * Gets the current gradient from an array of IValueGradient
  31370. * @param ratio defines the current ratio to get
  31371. * @param gradients defines the array of IValueGradient
  31372. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31373. */
  31374. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31375. }
  31376. /**
  31377. * This class is used to track a performance counter which is number based.
  31378. * The user has access to many properties which give statistics of different nature.
  31379. *
  31380. * The implementer can track two kinds of Performance Counter: time and count.
  31381. * 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.
  31382. * 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.
  31383. */
  31384. export class PerfCounter {
  31385. /**
  31386. * Gets or sets a global boolean to turn on and off all the counters
  31387. */
  31388. static Enabled: boolean;
  31389. /**
  31390. * Returns the smallest value ever
  31391. */
  31392. readonly min: number;
  31393. /**
  31394. * Returns the biggest value ever
  31395. */
  31396. readonly max: number;
  31397. /**
  31398. * Returns the average value since the performance counter is running
  31399. */
  31400. readonly average: number;
  31401. /**
  31402. * Returns the average value of the last second the counter was monitored
  31403. */
  31404. readonly lastSecAverage: number;
  31405. /**
  31406. * Returns the current value
  31407. */
  31408. readonly current: number;
  31409. /**
  31410. * Gets the accumulated total
  31411. */
  31412. readonly total: number;
  31413. /**
  31414. * Gets the total value count
  31415. */
  31416. readonly count: number;
  31417. /**
  31418. * Creates a new counter
  31419. */
  31420. constructor();
  31421. /**
  31422. * Call this method to start monitoring a new frame.
  31423. * 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.
  31424. */
  31425. fetchNewFrame(): void;
  31426. /**
  31427. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31428. * @param newCount the count value to add to the monitored count
  31429. * @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.
  31430. */
  31431. addCount(newCount: number, fetchResult: boolean): void;
  31432. /**
  31433. * Start monitoring this performance counter
  31434. */
  31435. beginMonitoring(): void;
  31436. /**
  31437. * Compute the time lapsed since the previous beginMonitoring() call.
  31438. * @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
  31439. */
  31440. endMonitoring(newFrame?: boolean): void;
  31441. private _fetchResult;
  31442. private _startMonitoringTime;
  31443. private _min;
  31444. private _max;
  31445. private _average;
  31446. private _current;
  31447. private _totalValueCount;
  31448. private _totalAccumulated;
  31449. private _lastSecAverage;
  31450. private _lastSecAccumulated;
  31451. private _lastSecTime;
  31452. private _lastSecValueCount;
  31453. }
  31454. /**
  31455. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31456. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31457. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31458. * @param name The name of the class, case should be preserved
  31459. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31460. */
  31461. export function className(name: string, module?: string): (target: Object) => void;
  31462. /**
  31463. * An implementation of a loop for asynchronous functions.
  31464. */
  31465. export class AsyncLoop {
  31466. /**
  31467. * Defines the number of iterations for the loop
  31468. */
  31469. iterations: number;
  31470. /**
  31471. * Defines the current index of the loop.
  31472. */
  31473. index: number;
  31474. private _done;
  31475. private _fn;
  31476. private _successCallback;
  31477. /**
  31478. * Constructor.
  31479. * @param iterations the number of iterations.
  31480. * @param func the function to run each iteration
  31481. * @param successCallback the callback that will be called upon succesful execution
  31482. * @param offset starting offset.
  31483. */
  31484. constructor(
  31485. /**
  31486. * Defines the number of iterations for the loop
  31487. */
  31488. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31489. /**
  31490. * Execute the next iteration. Must be called after the last iteration was finished.
  31491. */
  31492. executeNext(): void;
  31493. /**
  31494. * Break the loop and run the success callback.
  31495. */
  31496. breakLoop(): void;
  31497. /**
  31498. * Create and run an async loop.
  31499. * @param iterations the number of iterations.
  31500. * @param fn the function to run each iteration
  31501. * @param successCallback the callback that will be called upon succesful execution
  31502. * @param offset starting offset.
  31503. * @returns the created async loop object
  31504. */
  31505. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31506. /**
  31507. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31508. * @param iterations total number of iterations
  31509. * @param syncedIterations number of synchronous iterations in each async iteration.
  31510. * @param fn the function to call each iteration.
  31511. * @param callback a success call back that will be called when iterating stops.
  31512. * @param breakFunction a break condition (optional)
  31513. * @param timeout timeout settings for the setTimeout function. default - 0.
  31514. * @returns the created async loop object
  31515. */
  31516. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31517. }
  31518. }
  31519. declare module "babylonjs/Collisions/collisionCoordinator" {
  31520. import { Nullable } from "babylonjs/types";
  31521. import { Scene } from "babylonjs/scene";
  31522. import { Vector3 } from "babylonjs/Maths/math";
  31523. import { Collider } from "babylonjs/Collisions/collider";
  31524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31525. /** @hidden */
  31526. export interface ICollisionCoordinator {
  31527. createCollider(): Collider;
  31528. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31529. init(scene: Scene): void;
  31530. }
  31531. /** @hidden */
  31532. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31533. private _scene;
  31534. private _scaledPosition;
  31535. private _scaledVelocity;
  31536. private _finalPosition;
  31537. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31538. createCollider(): Collider;
  31539. init(scene: Scene): void;
  31540. private _collideWithWorld;
  31541. }
  31542. }
  31543. declare module "babylonjs/Animations/animationGroup" {
  31544. import { Animatable } from "babylonjs/Animations/animatable";
  31545. import { Animation } from "babylonjs/Animations/animation";
  31546. import { Scene, IDisposable } from "babylonjs/scene";
  31547. import { Observable } from "babylonjs/Misc/observable";
  31548. import { Nullable } from "babylonjs/types";
  31549. /**
  31550. * This class defines the direct association between an animation and a target
  31551. */
  31552. export class TargetedAnimation {
  31553. /**
  31554. * Animation to perform
  31555. */
  31556. animation: Animation;
  31557. /**
  31558. * Target to animate
  31559. */
  31560. target: any;
  31561. }
  31562. /**
  31563. * Use this class to create coordinated animations on multiple targets
  31564. */
  31565. export class AnimationGroup implements IDisposable {
  31566. /** The name of the animation group */
  31567. name: string;
  31568. private _scene;
  31569. private _targetedAnimations;
  31570. private _animatables;
  31571. private _from;
  31572. private _to;
  31573. private _isStarted;
  31574. private _isPaused;
  31575. private _speedRatio;
  31576. /**
  31577. * Gets or sets the unique id of the node
  31578. */
  31579. uniqueId: number;
  31580. /**
  31581. * This observable will notify when one animation have ended
  31582. */
  31583. onAnimationEndObservable: Observable<TargetedAnimation>;
  31584. /**
  31585. * Observer raised when one animation loops
  31586. */
  31587. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31588. /**
  31589. * This observable will notify when all animations have ended.
  31590. */
  31591. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31592. /**
  31593. * This observable will notify when all animations have paused.
  31594. */
  31595. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31596. /**
  31597. * This observable will notify when all animations are playing.
  31598. */
  31599. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31600. /**
  31601. * Gets the first frame
  31602. */
  31603. readonly from: number;
  31604. /**
  31605. * Gets the last frame
  31606. */
  31607. readonly to: number;
  31608. /**
  31609. * Define if the animations are started
  31610. */
  31611. readonly isStarted: boolean;
  31612. /**
  31613. * Gets a value indicating that the current group is playing
  31614. */
  31615. readonly isPlaying: boolean;
  31616. /**
  31617. * Gets or sets the speed ratio to use for all animations
  31618. */
  31619. /**
  31620. * Gets or sets the speed ratio to use for all animations
  31621. */
  31622. speedRatio: number;
  31623. /**
  31624. * Gets the targeted animations for this animation group
  31625. */
  31626. readonly targetedAnimations: Array<TargetedAnimation>;
  31627. /**
  31628. * returning the list of animatables controlled by this animation group.
  31629. */
  31630. readonly animatables: Array<Animatable>;
  31631. /**
  31632. * Instantiates a new Animation Group.
  31633. * This helps managing several animations at once.
  31634. * @see http://doc.babylonjs.com/how_to/group
  31635. * @param name Defines the name of the group
  31636. * @param scene Defines the scene the group belongs to
  31637. */
  31638. constructor(
  31639. /** The name of the animation group */
  31640. name: string, scene?: Nullable<Scene>);
  31641. /**
  31642. * Add an animation (with its target) in the group
  31643. * @param animation defines the animation we want to add
  31644. * @param target defines the target of the animation
  31645. * @returns the TargetedAnimation object
  31646. */
  31647. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31648. /**
  31649. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31650. * It can add constant keys at begin or end
  31651. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31652. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31653. * @returns the animation group
  31654. */
  31655. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31656. /**
  31657. * Start all animations on given targets
  31658. * @param loop defines if animations must loop
  31659. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31660. * @param from defines the from key (optional)
  31661. * @param to defines the to key (optional)
  31662. * @returns the current animation group
  31663. */
  31664. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31665. /**
  31666. * Pause all animations
  31667. * @returns the animation group
  31668. */
  31669. pause(): AnimationGroup;
  31670. /**
  31671. * Play all animations to initial state
  31672. * This function will start() the animations if they were not started or will restart() them if they were paused
  31673. * @param loop defines if animations must loop
  31674. * @returns the animation group
  31675. */
  31676. play(loop?: boolean): AnimationGroup;
  31677. /**
  31678. * Reset all animations to initial state
  31679. * @returns the animation group
  31680. */
  31681. reset(): AnimationGroup;
  31682. /**
  31683. * Restart animations from key 0
  31684. * @returns the animation group
  31685. */
  31686. restart(): AnimationGroup;
  31687. /**
  31688. * Stop all animations
  31689. * @returns the animation group
  31690. */
  31691. stop(): AnimationGroup;
  31692. /**
  31693. * Set animation weight for all animatables
  31694. * @param weight defines the weight to use
  31695. * @return the animationGroup
  31696. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31697. */
  31698. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31699. /**
  31700. * Synchronize and normalize all animatables with a source animatable
  31701. * @param root defines the root animatable to synchronize with
  31702. * @return the animationGroup
  31703. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31704. */
  31705. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31706. /**
  31707. * Goes to a specific frame in this animation group
  31708. * @param frame the frame number to go to
  31709. * @return the animationGroup
  31710. */
  31711. goToFrame(frame: number): AnimationGroup;
  31712. /**
  31713. * Dispose all associated resources
  31714. */
  31715. dispose(): void;
  31716. private _checkAnimationGroupEnded;
  31717. /**
  31718. * Clone the current animation group and returns a copy
  31719. * @param newName defines the name of the new group
  31720. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31721. * @returns the new aniamtion group
  31722. */
  31723. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31724. /**
  31725. * Returns a new AnimationGroup object parsed from the source provided.
  31726. * @param parsedAnimationGroup defines the source
  31727. * @param scene defines the scene that will receive the animationGroup
  31728. * @returns a new AnimationGroup
  31729. */
  31730. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31731. /**
  31732. * Returns the string "AnimationGroup"
  31733. * @returns "AnimationGroup"
  31734. */
  31735. getClassName(): string;
  31736. /**
  31737. * Creates a detailled string about the object
  31738. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31739. * @returns a string representing the object
  31740. */
  31741. toString(fullDetails?: boolean): string;
  31742. }
  31743. }
  31744. declare module "babylonjs/scene" {
  31745. import { Nullable } from "babylonjs/types";
  31746. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31747. import { Observable } from "babylonjs/Misc/observable";
  31748. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31749. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31750. import { Geometry } from "babylonjs/Meshes/geometry";
  31751. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31754. import { Mesh } from "babylonjs/Meshes/mesh";
  31755. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31756. import { Bone } from "babylonjs/Bones/bone";
  31757. import { Skeleton } from "babylonjs/Bones/skeleton";
  31758. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31759. import { Camera } from "babylonjs/Cameras/camera";
  31760. import { AbstractScene } from "babylonjs/abstractScene";
  31761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31763. import { Material } from "babylonjs/Materials/material";
  31764. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31765. import { Effect } from "babylonjs/Materials/effect";
  31766. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31767. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31768. import { Light } from "babylonjs/Lights/light";
  31769. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31770. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31771. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31772. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31773. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31774. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31775. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31776. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31777. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31778. import { Engine } from "babylonjs/Engines/engine";
  31779. import { Node } from "babylonjs/node";
  31780. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31781. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31782. import { Ray } from "babylonjs/Culling/ray";
  31783. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31784. import { Animation } from "babylonjs/Animations/animation";
  31785. import { Animatable } from "babylonjs/Animations/animatable";
  31786. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31787. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31788. import { Collider } from "babylonjs/Collisions/collider";
  31789. /**
  31790. * Define an interface for all classes that will hold resources
  31791. */
  31792. export interface IDisposable {
  31793. /**
  31794. * Releases all held resources
  31795. */
  31796. dispose(): void;
  31797. }
  31798. /** Interface defining initialization parameters for Scene class */
  31799. export interface SceneOptions {
  31800. /**
  31801. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31802. * It will improve performance when the number of geometries becomes important.
  31803. */
  31804. useGeometryUniqueIdsMap?: boolean;
  31805. /**
  31806. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31807. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31808. */
  31809. useMaterialMeshMap?: boolean;
  31810. /**
  31811. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31812. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31813. */
  31814. useClonedMeshhMap?: boolean;
  31815. }
  31816. /**
  31817. * Represents a scene to be rendered by the engine.
  31818. * @see http://doc.babylonjs.com/features/scene
  31819. */
  31820. export class Scene extends AbstractScene implements IAnimatable {
  31821. private static _uniqueIdCounter;
  31822. /** The fog is deactivated */
  31823. static readonly FOGMODE_NONE: number;
  31824. /** The fog density is following an exponential function */
  31825. static readonly FOGMODE_EXP: number;
  31826. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31827. static readonly FOGMODE_EXP2: number;
  31828. /** The fog density is following a linear function. */
  31829. static readonly FOGMODE_LINEAR: number;
  31830. /**
  31831. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31833. */
  31834. static MinDeltaTime: number;
  31835. /**
  31836. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31837. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31838. */
  31839. static MaxDeltaTime: number;
  31840. /**
  31841. * Factory used to create the default material.
  31842. * @param name The name of the material to create
  31843. * @param scene The scene to create the material for
  31844. * @returns The default material
  31845. */
  31846. static DefaultMaterialFactory(scene: Scene): Material;
  31847. /**
  31848. * Factory used to create the a collision coordinator.
  31849. * @returns The collision coordinator
  31850. */
  31851. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31852. /** @hidden */
  31853. readonly _isScene: boolean;
  31854. /**
  31855. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31856. */
  31857. autoClear: boolean;
  31858. /**
  31859. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31860. */
  31861. autoClearDepthAndStencil: boolean;
  31862. /**
  31863. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31864. */
  31865. clearColor: Color4;
  31866. /**
  31867. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31868. */
  31869. ambientColor: Color3;
  31870. /** @hidden */
  31871. _environmentBRDFTexture: BaseTexture;
  31872. /** @hidden */
  31873. protected _environmentTexture: Nullable<BaseTexture>;
  31874. /**
  31875. * Texture used in all pbr material as the reflection texture.
  31876. * As in the majority of the scene they are the same (exception for multi room and so on),
  31877. * this is easier to reference from here than from all the materials.
  31878. */
  31879. /**
  31880. * Texture used in all pbr material as the reflection texture.
  31881. * As in the majority of the scene they are the same (exception for multi room and so on),
  31882. * this is easier to set here than in all the materials.
  31883. */
  31884. environmentTexture: Nullable<BaseTexture>;
  31885. /** @hidden */
  31886. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31887. /**
  31888. * Default image processing configuration used either in the rendering
  31889. * Forward main pass or through the imageProcessingPostProcess if present.
  31890. * As in the majority of the scene they are the same (exception for multi camera),
  31891. * this is easier to reference from here than from all the materials and post process.
  31892. *
  31893. * No setter as we it is a shared configuration, you can set the values instead.
  31894. */
  31895. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31896. private _forceWireframe;
  31897. /**
  31898. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31899. */
  31900. forceWireframe: boolean;
  31901. private _forcePointsCloud;
  31902. /**
  31903. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31904. */
  31905. forcePointsCloud: boolean;
  31906. /**
  31907. * Gets or sets the active clipplane 1
  31908. */
  31909. clipPlane: Nullable<Plane>;
  31910. /**
  31911. * Gets or sets the active clipplane 2
  31912. */
  31913. clipPlane2: Nullable<Plane>;
  31914. /**
  31915. * Gets or sets the active clipplane 3
  31916. */
  31917. clipPlane3: Nullable<Plane>;
  31918. /**
  31919. * Gets or sets the active clipplane 4
  31920. */
  31921. clipPlane4: Nullable<Plane>;
  31922. /**
  31923. * Gets or sets a boolean indicating if animations are enabled
  31924. */
  31925. animationsEnabled: boolean;
  31926. private _animationPropertiesOverride;
  31927. /**
  31928. * Gets or sets the animation properties override
  31929. */
  31930. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31931. /**
  31932. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31933. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31934. */
  31935. useConstantAnimationDeltaTime: boolean;
  31936. /**
  31937. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31938. * Please note that it requires to run a ray cast through the scene on every frame
  31939. */
  31940. constantlyUpdateMeshUnderPointer: boolean;
  31941. /**
  31942. * Defines the HTML cursor to use when hovering over interactive elements
  31943. */
  31944. hoverCursor: string;
  31945. /**
  31946. * Defines the HTML default cursor to use (empty by default)
  31947. */
  31948. defaultCursor: string;
  31949. /**
  31950. * This is used to call preventDefault() on pointer down
  31951. * in order to block unwanted artifacts like system double clicks
  31952. */
  31953. preventDefaultOnPointerDown: boolean;
  31954. /**
  31955. * This is used to call preventDefault() on pointer up
  31956. * in order to block unwanted artifacts like system double clicks
  31957. */
  31958. preventDefaultOnPointerUp: boolean;
  31959. /**
  31960. * Gets or sets user defined metadata
  31961. */
  31962. metadata: any;
  31963. /**
  31964. * For internal use only. Please do not use.
  31965. */
  31966. reservedDataStore: any;
  31967. /**
  31968. * Gets the name of the plugin used to load this scene (null by default)
  31969. */
  31970. loadingPluginName: string;
  31971. /**
  31972. * Use this array to add regular expressions used to disable offline support for specific urls
  31973. */
  31974. disableOfflineSupportExceptionRules: RegExp[];
  31975. /**
  31976. * An event triggered when the scene is disposed.
  31977. */
  31978. onDisposeObservable: Observable<Scene>;
  31979. private _onDisposeObserver;
  31980. /** Sets a function to be executed when this scene is disposed. */
  31981. onDispose: () => void;
  31982. /**
  31983. * An event triggered before rendering the scene (right after animations and physics)
  31984. */
  31985. onBeforeRenderObservable: Observable<Scene>;
  31986. private _onBeforeRenderObserver;
  31987. /** Sets a function to be executed before rendering this scene */
  31988. beforeRender: Nullable<() => void>;
  31989. /**
  31990. * An event triggered after rendering the scene
  31991. */
  31992. onAfterRenderObservable: Observable<Scene>;
  31993. private _onAfterRenderObserver;
  31994. /** Sets a function to be executed after rendering this scene */
  31995. afterRender: Nullable<() => void>;
  31996. /**
  31997. * An event triggered before animating the scene
  31998. */
  31999. onBeforeAnimationsObservable: Observable<Scene>;
  32000. /**
  32001. * An event triggered after animations processing
  32002. */
  32003. onAfterAnimationsObservable: Observable<Scene>;
  32004. /**
  32005. * An event triggered before draw calls are ready to be sent
  32006. */
  32007. onBeforeDrawPhaseObservable: Observable<Scene>;
  32008. /**
  32009. * An event triggered after draw calls have been sent
  32010. */
  32011. onAfterDrawPhaseObservable: Observable<Scene>;
  32012. /**
  32013. * An event triggered when the scene is ready
  32014. */
  32015. onReadyObservable: Observable<Scene>;
  32016. /**
  32017. * An event triggered before rendering a camera
  32018. */
  32019. onBeforeCameraRenderObservable: Observable<Camera>;
  32020. private _onBeforeCameraRenderObserver;
  32021. /** Sets a function to be executed before rendering a camera*/
  32022. beforeCameraRender: () => void;
  32023. /**
  32024. * An event triggered after rendering a camera
  32025. */
  32026. onAfterCameraRenderObservable: Observable<Camera>;
  32027. private _onAfterCameraRenderObserver;
  32028. /** Sets a function to be executed after rendering a camera*/
  32029. afterCameraRender: () => void;
  32030. /**
  32031. * An event triggered when active meshes evaluation is about to start
  32032. */
  32033. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32034. /**
  32035. * An event triggered when active meshes evaluation is done
  32036. */
  32037. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32038. /**
  32039. * An event triggered when particles rendering is about to start
  32040. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32041. */
  32042. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32043. /**
  32044. * An event triggered when particles rendering is done
  32045. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32046. */
  32047. onAfterParticlesRenderingObservable: Observable<Scene>;
  32048. /**
  32049. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32050. */
  32051. onDataLoadedObservable: Observable<Scene>;
  32052. /**
  32053. * An event triggered when a camera is created
  32054. */
  32055. onNewCameraAddedObservable: Observable<Camera>;
  32056. /**
  32057. * An event triggered when a camera is removed
  32058. */
  32059. onCameraRemovedObservable: Observable<Camera>;
  32060. /**
  32061. * An event triggered when a light is created
  32062. */
  32063. onNewLightAddedObservable: Observable<Light>;
  32064. /**
  32065. * An event triggered when a light is removed
  32066. */
  32067. onLightRemovedObservable: Observable<Light>;
  32068. /**
  32069. * An event triggered when a geometry is created
  32070. */
  32071. onNewGeometryAddedObservable: Observable<Geometry>;
  32072. /**
  32073. * An event triggered when a geometry is removed
  32074. */
  32075. onGeometryRemovedObservable: Observable<Geometry>;
  32076. /**
  32077. * An event triggered when a transform node is created
  32078. */
  32079. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32080. /**
  32081. * An event triggered when a transform node is removed
  32082. */
  32083. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32084. /**
  32085. * An event triggered when a mesh is created
  32086. */
  32087. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32088. /**
  32089. * An event triggered when a mesh is removed
  32090. */
  32091. onMeshRemovedObservable: Observable<AbstractMesh>;
  32092. /**
  32093. * An event triggered when a material is created
  32094. */
  32095. onNewMaterialAddedObservable: Observable<Material>;
  32096. /**
  32097. * An event triggered when a material is removed
  32098. */
  32099. onMaterialRemovedObservable: Observable<Material>;
  32100. /**
  32101. * An event triggered when a texture is created
  32102. */
  32103. onNewTextureAddedObservable: Observable<BaseTexture>;
  32104. /**
  32105. * An event triggered when a texture is removed
  32106. */
  32107. onTextureRemovedObservable: Observable<BaseTexture>;
  32108. /**
  32109. * An event triggered when render targets are about to be rendered
  32110. * Can happen multiple times per frame.
  32111. */
  32112. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32113. /**
  32114. * An event triggered when render targets were rendered.
  32115. * Can happen multiple times per frame.
  32116. */
  32117. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32118. /**
  32119. * An event triggered before calculating deterministic simulation step
  32120. */
  32121. onBeforeStepObservable: Observable<Scene>;
  32122. /**
  32123. * An event triggered after calculating deterministic simulation step
  32124. */
  32125. onAfterStepObservable: Observable<Scene>;
  32126. /**
  32127. * An event triggered when the activeCamera property is updated
  32128. */
  32129. onActiveCameraChanged: Observable<Scene>;
  32130. /**
  32131. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32132. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32133. * 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)
  32134. */
  32135. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32136. /**
  32137. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32138. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32139. * 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)
  32140. */
  32141. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32142. /**
  32143. * This Observable will when a mesh has been imported into the scene.
  32144. */
  32145. onMeshImportedObservable: Observable<AbstractMesh>;
  32146. /**
  32147. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32148. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32149. */
  32150. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32151. /** @hidden */
  32152. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32153. /**
  32154. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32155. */
  32156. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32157. /**
  32158. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32159. */
  32160. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32161. /**
  32162. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32163. */
  32164. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32165. private _onPointerMove;
  32166. private _onPointerDown;
  32167. private _onPointerUp;
  32168. /** Callback called when a pointer move is detected */
  32169. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32170. /** Callback called when a pointer down is detected */
  32171. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32172. /** Callback called when a pointer up is detected */
  32173. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32174. /** Callback called when a pointer pick is detected */
  32175. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32176. /**
  32177. * 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).
  32178. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32179. */
  32180. onPrePointerObservable: Observable<PointerInfoPre>;
  32181. /**
  32182. * Observable event triggered each time an input event is received from the rendering canvas
  32183. */
  32184. onPointerObservable: Observable<PointerInfo>;
  32185. /**
  32186. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32187. */
  32188. readonly unTranslatedPointer: Vector2;
  32189. /** The distance in pixel that you have to move to prevent some events */
  32190. static DragMovementThreshold: number;
  32191. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32192. static LongPressDelay: number;
  32193. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32194. static DoubleClickDelay: number;
  32195. /** If you need to check double click without raising a single click at first click, enable this flag */
  32196. static ExclusiveDoubleClickMode: boolean;
  32197. private _initClickEvent;
  32198. private _initActionManager;
  32199. private _delayedSimpleClick;
  32200. private _delayedSimpleClickTimeout;
  32201. private _previousDelayedSimpleClickTimeout;
  32202. private _meshPickProceed;
  32203. private _previousButtonPressed;
  32204. private _currentPickResult;
  32205. private _previousPickResult;
  32206. private _totalPointersPressed;
  32207. private _doubleClickOccured;
  32208. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32209. cameraToUseForPointers: Nullable<Camera>;
  32210. private _pointerX;
  32211. private _pointerY;
  32212. private _unTranslatedPointerX;
  32213. private _unTranslatedPointerY;
  32214. private _startingPointerPosition;
  32215. private _previousStartingPointerPosition;
  32216. private _startingPointerTime;
  32217. private _previousStartingPointerTime;
  32218. private _pointerCaptures;
  32219. private _timeAccumulator;
  32220. private _currentStepId;
  32221. private _currentInternalStep;
  32222. /** @hidden */
  32223. _mirroredCameraPosition: Nullable<Vector3>;
  32224. /**
  32225. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32226. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32227. */
  32228. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32229. /**
  32230. * Observable event triggered each time an keyboard event is received from the hosting window
  32231. */
  32232. onKeyboardObservable: Observable<KeyboardInfo>;
  32233. private _onKeyDown;
  32234. private _onKeyUp;
  32235. private _onCanvasFocusObserver;
  32236. private _onCanvasBlurObserver;
  32237. private _useRightHandedSystem;
  32238. /**
  32239. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32240. */
  32241. useRightHandedSystem: boolean;
  32242. /**
  32243. * Sets the step Id used by deterministic lock step
  32244. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32245. * @param newStepId defines the step Id
  32246. */
  32247. setStepId(newStepId: number): void;
  32248. /**
  32249. * Gets the step Id used by deterministic lock step
  32250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32251. * @returns the step Id
  32252. */
  32253. getStepId(): number;
  32254. /**
  32255. * Gets the internal step used by deterministic lock step
  32256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32257. * @returns the internal step
  32258. */
  32259. getInternalStep(): number;
  32260. private _fogEnabled;
  32261. /**
  32262. * Gets or sets a boolean indicating if fog is enabled on this scene
  32263. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32264. * (Default is true)
  32265. */
  32266. fogEnabled: boolean;
  32267. private _fogMode;
  32268. /**
  32269. * Gets or sets the fog mode to use
  32270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32271. * | mode | value |
  32272. * | --- | --- |
  32273. * | FOGMODE_NONE | 0 |
  32274. * | FOGMODE_EXP | 1 |
  32275. * | FOGMODE_EXP2 | 2 |
  32276. * | FOGMODE_LINEAR | 3 |
  32277. */
  32278. fogMode: number;
  32279. /**
  32280. * Gets or sets the fog color to use
  32281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32282. * (Default is Color3(0.2, 0.2, 0.3))
  32283. */
  32284. fogColor: Color3;
  32285. /**
  32286. * Gets or sets the fog density to use
  32287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32288. * (Default is 0.1)
  32289. */
  32290. fogDensity: number;
  32291. /**
  32292. * Gets or sets the fog start distance to use
  32293. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32294. * (Default is 0)
  32295. */
  32296. fogStart: number;
  32297. /**
  32298. * Gets or sets the fog end distance to use
  32299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32300. * (Default is 1000)
  32301. */
  32302. fogEnd: number;
  32303. private _shadowsEnabled;
  32304. /**
  32305. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32306. */
  32307. shadowsEnabled: boolean;
  32308. private _lightsEnabled;
  32309. /**
  32310. * Gets or sets a boolean indicating if lights are enabled on this scene
  32311. */
  32312. lightsEnabled: boolean;
  32313. /** All of the active cameras added to this scene. */
  32314. activeCameras: Camera[];
  32315. private _activeCamera;
  32316. /** Gets or sets the current active camera */
  32317. activeCamera: Nullable<Camera>;
  32318. private _defaultMaterial;
  32319. /** The default material used on meshes when no material is affected */
  32320. /** The default material used on meshes when no material is affected */
  32321. defaultMaterial: Material;
  32322. private _texturesEnabled;
  32323. /**
  32324. * Gets or sets a boolean indicating if textures are enabled on this scene
  32325. */
  32326. texturesEnabled: boolean;
  32327. /**
  32328. * Gets or sets a boolean indicating if particles are enabled on this scene
  32329. */
  32330. particlesEnabled: boolean;
  32331. /**
  32332. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32333. */
  32334. spritesEnabled: boolean;
  32335. private _skeletonsEnabled;
  32336. /**
  32337. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32338. */
  32339. skeletonsEnabled: boolean;
  32340. /**
  32341. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32342. */
  32343. lensFlaresEnabled: boolean;
  32344. /**
  32345. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32347. */
  32348. collisionsEnabled: boolean;
  32349. private _collisionCoordinator;
  32350. /** @hidden */
  32351. readonly collisionCoordinator: ICollisionCoordinator;
  32352. /**
  32353. * Defines the gravity applied to this scene (used only for collisions)
  32354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32355. */
  32356. gravity: Vector3;
  32357. /**
  32358. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32359. */
  32360. postProcessesEnabled: boolean;
  32361. /**
  32362. * The list of postprocesses added to the scene
  32363. */
  32364. postProcesses: PostProcess[];
  32365. /**
  32366. * Gets the current postprocess manager
  32367. */
  32368. postProcessManager: PostProcessManager;
  32369. /**
  32370. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32371. */
  32372. renderTargetsEnabled: boolean;
  32373. /**
  32374. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32375. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32376. */
  32377. dumpNextRenderTargets: boolean;
  32378. /**
  32379. * The list of user defined render targets added to the scene
  32380. */
  32381. customRenderTargets: RenderTargetTexture[];
  32382. /**
  32383. * Defines if texture loading must be delayed
  32384. * If true, textures will only be loaded when they need to be rendered
  32385. */
  32386. useDelayedTextureLoading: boolean;
  32387. /**
  32388. * Gets the list of meshes imported to the scene through SceneLoader
  32389. */
  32390. importedMeshesFiles: String[];
  32391. /**
  32392. * Gets or sets a boolean indicating if probes are enabled on this scene
  32393. */
  32394. probesEnabled: boolean;
  32395. /**
  32396. * Gets or sets the current offline provider to use to store scene data
  32397. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32398. */
  32399. offlineProvider: IOfflineProvider;
  32400. /**
  32401. * Gets or sets the action manager associated with the scene
  32402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32403. */
  32404. actionManager: AbstractActionManager;
  32405. private _meshesForIntersections;
  32406. /**
  32407. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32408. */
  32409. proceduralTexturesEnabled: boolean;
  32410. private _engine;
  32411. private _totalVertices;
  32412. /** @hidden */
  32413. _activeIndices: PerfCounter;
  32414. /** @hidden */
  32415. _activeParticles: PerfCounter;
  32416. /** @hidden */
  32417. _activeBones: PerfCounter;
  32418. private _animationRatio;
  32419. /** @hidden */
  32420. _animationTimeLast: number;
  32421. /** @hidden */
  32422. _animationTime: number;
  32423. /**
  32424. * Gets or sets a general scale for animation speed
  32425. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32426. */
  32427. animationTimeScale: number;
  32428. /** @hidden */
  32429. _cachedMaterial: Nullable<Material>;
  32430. /** @hidden */
  32431. _cachedEffect: Nullable<Effect>;
  32432. /** @hidden */
  32433. _cachedVisibility: Nullable<number>;
  32434. private _renderId;
  32435. private _frameId;
  32436. private _executeWhenReadyTimeoutId;
  32437. private _intermediateRendering;
  32438. private _viewUpdateFlag;
  32439. private _projectionUpdateFlag;
  32440. private _alternateViewUpdateFlag;
  32441. private _alternateProjectionUpdateFlag;
  32442. /** @hidden */
  32443. _toBeDisposed: Nullable<IDisposable>[];
  32444. private _activeRequests;
  32445. /** @hidden */
  32446. _pendingData: any[];
  32447. private _isDisposed;
  32448. /**
  32449. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32450. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32451. */
  32452. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32453. private _activeMeshes;
  32454. private _processedMaterials;
  32455. private _renderTargets;
  32456. /** @hidden */
  32457. _activeParticleSystems: SmartArray<IParticleSystem>;
  32458. private _activeSkeletons;
  32459. private _softwareSkinnedMeshes;
  32460. private _renderingManager;
  32461. /** @hidden */
  32462. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32463. private _transformMatrix;
  32464. private _sceneUbo;
  32465. private _alternateSceneUbo;
  32466. private _viewMatrix;
  32467. private _projectionMatrix;
  32468. private _alternateViewMatrix;
  32469. private _alternateProjectionMatrix;
  32470. private _alternateTransformMatrix;
  32471. private _useAlternateCameraConfiguration;
  32472. private _alternateRendering;
  32473. private _wheelEventName;
  32474. /** @hidden */
  32475. _forcedViewPosition: Nullable<Vector3>;
  32476. /** @hidden */
  32477. readonly _isAlternateRenderingEnabled: boolean;
  32478. private _frustumPlanes;
  32479. /**
  32480. * Gets the list of frustum planes (built from the active camera)
  32481. */
  32482. readonly frustumPlanes: Plane[];
  32483. /**
  32484. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32485. * This is useful if there are more lights that the maximum simulteanous authorized
  32486. */
  32487. requireLightSorting: boolean;
  32488. /** @hidden */
  32489. readonly useMaterialMeshMap: boolean;
  32490. /** @hidden */
  32491. readonly useClonedMeshhMap: boolean;
  32492. private _pointerOverMesh;
  32493. private _pickedDownMesh;
  32494. private _pickedUpMesh;
  32495. private _externalData;
  32496. private _uid;
  32497. /**
  32498. * @hidden
  32499. * Backing store of defined scene components.
  32500. */
  32501. _components: ISceneComponent[];
  32502. /**
  32503. * @hidden
  32504. * Backing store of defined scene components.
  32505. */
  32506. _serializableComponents: ISceneSerializableComponent[];
  32507. /**
  32508. * List of components to register on the next registration step.
  32509. */
  32510. private _transientComponents;
  32511. /**
  32512. * Registers the transient components if needed.
  32513. */
  32514. private _registerTransientComponents;
  32515. /**
  32516. * @hidden
  32517. * Add a component to the scene.
  32518. * Note that the ccomponent could be registered on th next frame if this is called after
  32519. * the register component stage.
  32520. * @param component Defines the component to add to the scene
  32521. */
  32522. _addComponent(component: ISceneComponent): void;
  32523. /**
  32524. * @hidden
  32525. * Gets a component from the scene.
  32526. * @param name defines the name of the component to retrieve
  32527. * @returns the component or null if not present
  32528. */
  32529. _getComponent(name: string): Nullable<ISceneComponent>;
  32530. /**
  32531. * @hidden
  32532. * Defines the actions happening before camera updates.
  32533. */
  32534. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32535. /**
  32536. * @hidden
  32537. * Defines the actions happening before clear the canvas.
  32538. */
  32539. _beforeClearStage: Stage<SimpleStageAction>;
  32540. /**
  32541. * @hidden
  32542. * Defines the actions when collecting render targets for the frame.
  32543. */
  32544. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32545. /**
  32546. * @hidden
  32547. * Defines the actions happening for one camera in the frame.
  32548. */
  32549. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32550. /**
  32551. * @hidden
  32552. * Defines the actions happening during the per mesh ready checks.
  32553. */
  32554. _isReadyForMeshStage: Stage<MeshStageAction>;
  32555. /**
  32556. * @hidden
  32557. * Defines the actions happening before evaluate active mesh checks.
  32558. */
  32559. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32560. /**
  32561. * @hidden
  32562. * Defines the actions happening during the evaluate sub mesh checks.
  32563. */
  32564. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32565. /**
  32566. * @hidden
  32567. * Defines the actions happening during the active mesh stage.
  32568. */
  32569. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32570. /**
  32571. * @hidden
  32572. * Defines the actions happening during the per camera render target step.
  32573. */
  32574. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32575. /**
  32576. * @hidden
  32577. * Defines the actions happening just before the active camera is drawing.
  32578. */
  32579. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32580. /**
  32581. * @hidden
  32582. * Defines the actions happening just before a render target is drawing.
  32583. */
  32584. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32585. /**
  32586. * @hidden
  32587. * Defines the actions happening just before a rendering group is drawing.
  32588. */
  32589. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32590. /**
  32591. * @hidden
  32592. * Defines the actions happening just before a mesh is drawing.
  32593. */
  32594. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32595. /**
  32596. * @hidden
  32597. * Defines the actions happening just after a mesh has been drawn.
  32598. */
  32599. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32600. /**
  32601. * @hidden
  32602. * Defines the actions happening just after a rendering group has been drawn.
  32603. */
  32604. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32605. /**
  32606. * @hidden
  32607. * Defines the actions happening just after the active camera has been drawn.
  32608. */
  32609. _afterCameraDrawStage: Stage<CameraStageAction>;
  32610. /**
  32611. * @hidden
  32612. * Defines the actions happening just after a render target has been drawn.
  32613. */
  32614. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32615. /**
  32616. * @hidden
  32617. * Defines the actions happening just after rendering all cameras and computing intersections.
  32618. */
  32619. _afterRenderStage: Stage<SimpleStageAction>;
  32620. /**
  32621. * @hidden
  32622. * Defines the actions happening when a pointer move event happens.
  32623. */
  32624. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32625. /**
  32626. * @hidden
  32627. * Defines the actions happening when a pointer down event happens.
  32628. */
  32629. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32630. /**
  32631. * @hidden
  32632. * Defines the actions happening when a pointer up event happens.
  32633. */
  32634. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32635. /**
  32636. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32637. */
  32638. private geometriesByUniqueId;
  32639. /**
  32640. * Creates a new Scene
  32641. * @param engine defines the engine to use to render this scene
  32642. * @param options defines the scene options
  32643. */
  32644. constructor(engine: Engine, options?: SceneOptions);
  32645. private _defaultMeshCandidates;
  32646. /**
  32647. * @hidden
  32648. */
  32649. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32650. private _defaultSubMeshCandidates;
  32651. /**
  32652. * @hidden
  32653. */
  32654. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32655. /**
  32656. * Sets the default candidate providers for the scene.
  32657. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32658. * and getCollidingSubMeshCandidates to their default function
  32659. */
  32660. setDefaultCandidateProviders(): void;
  32661. /**
  32662. * Gets the mesh that is currently under the pointer
  32663. */
  32664. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32665. /**
  32666. * Gets or sets the current on-screen X position of the pointer
  32667. */
  32668. pointerX: number;
  32669. /**
  32670. * Gets or sets the current on-screen Y position of the pointer
  32671. */
  32672. pointerY: number;
  32673. /**
  32674. * Gets the cached material (ie. the latest rendered one)
  32675. * @returns the cached material
  32676. */
  32677. getCachedMaterial(): Nullable<Material>;
  32678. /**
  32679. * Gets the cached effect (ie. the latest rendered one)
  32680. * @returns the cached effect
  32681. */
  32682. getCachedEffect(): Nullable<Effect>;
  32683. /**
  32684. * Gets the cached visibility state (ie. the latest rendered one)
  32685. * @returns the cached visibility state
  32686. */
  32687. getCachedVisibility(): Nullable<number>;
  32688. /**
  32689. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32690. * @param material defines the current material
  32691. * @param effect defines the current effect
  32692. * @param visibility defines the current visibility state
  32693. * @returns true if one parameter is not cached
  32694. */
  32695. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32696. /**
  32697. * Gets the engine associated with the scene
  32698. * @returns an Engine
  32699. */
  32700. getEngine(): Engine;
  32701. /**
  32702. * Gets the total number of vertices rendered per frame
  32703. * @returns the total number of vertices rendered per frame
  32704. */
  32705. getTotalVertices(): number;
  32706. /**
  32707. * Gets the performance counter for total vertices
  32708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32709. */
  32710. readonly totalVerticesPerfCounter: PerfCounter;
  32711. /**
  32712. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32713. * @returns the total number of active indices rendered per frame
  32714. */
  32715. getActiveIndices(): number;
  32716. /**
  32717. * Gets the performance counter for active indices
  32718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32719. */
  32720. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32721. /**
  32722. * Gets the total number of active particles rendered per frame
  32723. * @returns the total number of active particles rendered per frame
  32724. */
  32725. getActiveParticles(): number;
  32726. /**
  32727. * Gets the performance counter for active particles
  32728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32729. */
  32730. readonly activeParticlesPerfCounter: PerfCounter;
  32731. /**
  32732. * Gets the total number of active bones rendered per frame
  32733. * @returns the total number of active bones rendered per frame
  32734. */
  32735. getActiveBones(): number;
  32736. /**
  32737. * Gets the performance counter for active bones
  32738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32739. */
  32740. readonly activeBonesPerfCounter: PerfCounter;
  32741. /**
  32742. * Gets the array of active meshes
  32743. * @returns an array of AbstractMesh
  32744. */
  32745. getActiveMeshes(): SmartArray<AbstractMesh>;
  32746. /**
  32747. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32748. * @returns a number
  32749. */
  32750. getAnimationRatio(): number;
  32751. /**
  32752. * Gets an unique Id for the current render phase
  32753. * @returns a number
  32754. */
  32755. getRenderId(): number;
  32756. /**
  32757. * Gets an unique Id for the current frame
  32758. * @returns a number
  32759. */
  32760. getFrameId(): number;
  32761. /** Call this function if you want to manually increment the render Id*/
  32762. incrementRenderId(): void;
  32763. private _updatePointerPosition;
  32764. private _createUbo;
  32765. private _createAlternateUbo;
  32766. private _setRayOnPointerInfo;
  32767. /**
  32768. * Use this method to simulate a pointer move on a mesh
  32769. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32770. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32771. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32772. * @returns the current scene
  32773. */
  32774. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32775. private _processPointerMove;
  32776. private _checkPrePointerObservable;
  32777. /**
  32778. * Use this method to simulate a pointer down on a mesh
  32779. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32780. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32781. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32782. * @returns the current scene
  32783. */
  32784. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32785. private _processPointerDown;
  32786. /**
  32787. * Use this method to simulate a pointer up on a mesh
  32788. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32789. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32790. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32791. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32792. * @returns the current scene
  32793. */
  32794. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32795. private _processPointerUp;
  32796. /**
  32797. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32798. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32799. * @returns true if the pointer was captured
  32800. */
  32801. isPointerCaptured(pointerId?: number): boolean;
  32802. /** @hidden */
  32803. _isPointerSwiping(): boolean;
  32804. /**
  32805. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32806. * @param attachUp defines if you want to attach events to pointerup
  32807. * @param attachDown defines if you want to attach events to pointerdown
  32808. * @param attachMove defines if you want to attach events to pointermove
  32809. */
  32810. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32811. /** Detaches all event handlers*/
  32812. detachControl(): void;
  32813. /**
  32814. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32815. * Delay loaded resources are not taking in account
  32816. * @return true if all required resources are ready
  32817. */
  32818. isReady(): boolean;
  32819. /** Resets all cached information relative to material (including effect and visibility) */
  32820. resetCachedMaterial(): void;
  32821. /**
  32822. * Registers a function to be called before every frame render
  32823. * @param func defines the function to register
  32824. */
  32825. registerBeforeRender(func: () => void): void;
  32826. /**
  32827. * Unregisters a function called before every frame render
  32828. * @param func defines the function to unregister
  32829. */
  32830. unregisterBeforeRender(func: () => void): void;
  32831. /**
  32832. * Registers a function to be called after every frame render
  32833. * @param func defines the function to register
  32834. */
  32835. registerAfterRender(func: () => void): void;
  32836. /**
  32837. * Unregisters a function called after every frame render
  32838. * @param func defines the function to unregister
  32839. */
  32840. unregisterAfterRender(func: () => void): void;
  32841. private _executeOnceBeforeRender;
  32842. /**
  32843. * The provided function will run before render once and will be disposed afterwards.
  32844. * A timeout delay can be provided so that the function will be executed in N ms.
  32845. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32846. * @param func The function to be executed.
  32847. * @param timeout optional delay in ms
  32848. */
  32849. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32850. /** @hidden */
  32851. _addPendingData(data: any): void;
  32852. /** @hidden */
  32853. _removePendingData(data: any): void;
  32854. /**
  32855. * Returns the number of items waiting to be loaded
  32856. * @returns the number of items waiting to be loaded
  32857. */
  32858. getWaitingItemsCount(): number;
  32859. /**
  32860. * Returns a boolean indicating if the scene is still loading data
  32861. */
  32862. readonly isLoading: boolean;
  32863. /**
  32864. * Registers a function to be executed when the scene is ready
  32865. * @param {Function} func - the function to be executed
  32866. */
  32867. executeWhenReady(func: () => void): void;
  32868. /**
  32869. * Returns a promise that resolves when the scene is ready
  32870. * @returns A promise that resolves when the scene is ready
  32871. */
  32872. whenReadyAsync(): Promise<void>;
  32873. /** @hidden */
  32874. _checkIsReady(): void;
  32875. /**
  32876. * Gets all animatable attached to the scene
  32877. */
  32878. readonly animatables: Animatable[];
  32879. /**
  32880. * Resets the last animation time frame.
  32881. * Useful to override when animations start running when loading a scene for the first time.
  32882. */
  32883. resetLastAnimationTimeFrame(): void;
  32884. /** @hidden */
  32885. _switchToAlternateCameraConfiguration(active: boolean): void;
  32886. /**
  32887. * Gets the current view matrix
  32888. * @returns a Matrix
  32889. */
  32890. getViewMatrix(): Matrix;
  32891. /**
  32892. * Gets the current projection matrix
  32893. * @returns a Matrix
  32894. */
  32895. getProjectionMatrix(): Matrix;
  32896. /**
  32897. * Gets the current transform matrix
  32898. * @returns a Matrix made of View * Projection
  32899. */
  32900. getTransformMatrix(): Matrix;
  32901. /**
  32902. * Sets the current transform matrix
  32903. * @param view defines the View matrix to use
  32904. * @param projection defines the Projection matrix to use
  32905. */
  32906. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32907. /** @hidden */
  32908. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32909. /**
  32910. * Gets the uniform buffer used to store scene data
  32911. * @returns a UniformBuffer
  32912. */
  32913. getSceneUniformBuffer(): UniformBuffer;
  32914. /**
  32915. * Gets an unique (relatively to the current scene) Id
  32916. * @returns an unique number for the scene
  32917. */
  32918. getUniqueId(): number;
  32919. /**
  32920. * Add a mesh to the list of scene's meshes
  32921. * @param newMesh defines the mesh to add
  32922. * @param recursive if all child meshes should also be added to the scene
  32923. */
  32924. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32925. /**
  32926. * Remove a mesh for the list of scene's meshes
  32927. * @param toRemove defines the mesh to remove
  32928. * @param recursive if all child meshes should also be removed from the scene
  32929. * @returns the index where the mesh was in the mesh list
  32930. */
  32931. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32932. /**
  32933. * Add a transform node to the list of scene's transform nodes
  32934. * @param newTransformNode defines the transform node to add
  32935. */
  32936. addTransformNode(newTransformNode: TransformNode): void;
  32937. /**
  32938. * Remove a transform node for the list of scene's transform nodes
  32939. * @param toRemove defines the transform node to remove
  32940. * @returns the index where the transform node was in the transform node list
  32941. */
  32942. removeTransformNode(toRemove: TransformNode): number;
  32943. /**
  32944. * Remove a skeleton for the list of scene's skeletons
  32945. * @param toRemove defines the skeleton to remove
  32946. * @returns the index where the skeleton was in the skeleton list
  32947. */
  32948. removeSkeleton(toRemove: Skeleton): number;
  32949. /**
  32950. * Remove a morph target for the list of scene's morph targets
  32951. * @param toRemove defines the morph target to remove
  32952. * @returns the index where the morph target was in the morph target list
  32953. */
  32954. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32955. /**
  32956. * Remove a light for the list of scene's lights
  32957. * @param toRemove defines the light to remove
  32958. * @returns the index where the light was in the light list
  32959. */
  32960. removeLight(toRemove: Light): number;
  32961. /**
  32962. * Remove a camera for the list of scene's cameras
  32963. * @param toRemove defines the camera to remove
  32964. * @returns the index where the camera was in the camera list
  32965. */
  32966. removeCamera(toRemove: Camera): number;
  32967. /**
  32968. * Remove a particle system for the list of scene's particle systems
  32969. * @param toRemove defines the particle system to remove
  32970. * @returns the index where the particle system was in the particle system list
  32971. */
  32972. removeParticleSystem(toRemove: IParticleSystem): number;
  32973. /**
  32974. * Remove a animation for the list of scene's animations
  32975. * @param toRemove defines the animation to remove
  32976. * @returns the index where the animation was in the animation list
  32977. */
  32978. removeAnimation(toRemove: Animation): number;
  32979. /**
  32980. * Removes the given animation group from this scene.
  32981. * @param toRemove The animation group to remove
  32982. * @returns The index of the removed animation group
  32983. */
  32984. removeAnimationGroup(toRemove: AnimationGroup): number;
  32985. /**
  32986. * Removes the given multi-material from this scene.
  32987. * @param toRemove The multi-material to remove
  32988. * @returns The index of the removed multi-material
  32989. */
  32990. removeMultiMaterial(toRemove: MultiMaterial): number;
  32991. /**
  32992. * Removes the given material from this scene.
  32993. * @param toRemove The material to remove
  32994. * @returns The index of the removed material
  32995. */
  32996. removeMaterial(toRemove: Material): number;
  32997. /**
  32998. * Removes the given action manager from this scene.
  32999. * @param toRemove The action manager to remove
  33000. * @returns The index of the removed action manager
  33001. */
  33002. removeActionManager(toRemove: AbstractActionManager): number;
  33003. /**
  33004. * Removes the given texture from this scene.
  33005. * @param toRemove The texture to remove
  33006. * @returns The index of the removed texture
  33007. */
  33008. removeTexture(toRemove: BaseTexture): number;
  33009. /**
  33010. * Adds the given light to this scene
  33011. * @param newLight The light to add
  33012. */
  33013. addLight(newLight: Light): void;
  33014. /**
  33015. * Sorts the list list based on light priorities
  33016. */
  33017. sortLightsByPriority(): void;
  33018. /**
  33019. * Adds the given camera to this scene
  33020. * @param newCamera The camera to add
  33021. */
  33022. addCamera(newCamera: Camera): void;
  33023. /**
  33024. * Adds the given skeleton to this scene
  33025. * @param newSkeleton The skeleton to add
  33026. */
  33027. addSkeleton(newSkeleton: Skeleton): void;
  33028. /**
  33029. * Adds the given particle system to this scene
  33030. * @param newParticleSystem The particle system to add
  33031. */
  33032. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33033. /**
  33034. * Adds the given animation to this scene
  33035. * @param newAnimation The animation to add
  33036. */
  33037. addAnimation(newAnimation: Animation): void;
  33038. /**
  33039. * Adds the given animation group to this scene.
  33040. * @param newAnimationGroup The animation group to add
  33041. */
  33042. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33043. /**
  33044. * Adds the given multi-material to this scene
  33045. * @param newMultiMaterial The multi-material to add
  33046. */
  33047. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33048. /**
  33049. * Adds the given material to this scene
  33050. * @param newMaterial The material to add
  33051. */
  33052. addMaterial(newMaterial: Material): void;
  33053. /**
  33054. * Adds the given morph target to this scene
  33055. * @param newMorphTargetManager The morph target to add
  33056. */
  33057. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33058. /**
  33059. * Adds the given geometry to this scene
  33060. * @param newGeometry The geometry to add
  33061. */
  33062. addGeometry(newGeometry: Geometry): void;
  33063. /**
  33064. * Adds the given action manager to this scene
  33065. * @param newActionManager The action manager to add
  33066. */
  33067. addActionManager(newActionManager: AbstractActionManager): void;
  33068. /**
  33069. * Adds the given texture to this scene.
  33070. * @param newTexture The texture to add
  33071. */
  33072. addTexture(newTexture: BaseTexture): void;
  33073. /**
  33074. * Switch active camera
  33075. * @param newCamera defines the new active camera
  33076. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33077. */
  33078. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33079. /**
  33080. * sets the active camera of the scene using its ID
  33081. * @param id defines the camera's ID
  33082. * @return the new active camera or null if none found.
  33083. */
  33084. setActiveCameraByID(id: string): Nullable<Camera>;
  33085. /**
  33086. * sets the active camera of the scene using its name
  33087. * @param name defines the camera's name
  33088. * @returns the new active camera or null if none found.
  33089. */
  33090. setActiveCameraByName(name: string): Nullable<Camera>;
  33091. /**
  33092. * get an animation group using its name
  33093. * @param name defines the material's name
  33094. * @return the animation group or null if none found.
  33095. */
  33096. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33097. /**
  33098. * get a material using its id
  33099. * @param id defines the material's ID
  33100. * @return the material or null if none found.
  33101. */
  33102. getMaterialByID(id: string): Nullable<Material>;
  33103. /**
  33104. * Gets a material using its name
  33105. * @param name defines the material's name
  33106. * @return the material or null if none found.
  33107. */
  33108. getMaterialByName(name: string): Nullable<Material>;
  33109. /**
  33110. * Gets a camera using its id
  33111. * @param id defines the id to look for
  33112. * @returns the camera or null if not found
  33113. */
  33114. getCameraByID(id: string): Nullable<Camera>;
  33115. /**
  33116. * Gets a camera using its unique id
  33117. * @param uniqueId defines the unique id to look for
  33118. * @returns the camera or null if not found
  33119. */
  33120. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33121. /**
  33122. * Gets a camera using its name
  33123. * @param name defines the camera's name
  33124. * @return the camera or null if none found.
  33125. */
  33126. getCameraByName(name: string): Nullable<Camera>;
  33127. /**
  33128. * Gets a bone using its id
  33129. * @param id defines the bone's id
  33130. * @return the bone or null if not found
  33131. */
  33132. getBoneByID(id: string): Nullable<Bone>;
  33133. /**
  33134. * Gets a bone using its id
  33135. * @param name defines the bone's name
  33136. * @return the bone or null if not found
  33137. */
  33138. getBoneByName(name: string): Nullable<Bone>;
  33139. /**
  33140. * Gets a light node using its name
  33141. * @param name defines the the light's name
  33142. * @return the light or null if none found.
  33143. */
  33144. getLightByName(name: string): Nullable<Light>;
  33145. /**
  33146. * Gets a light node using its id
  33147. * @param id defines the light's id
  33148. * @return the light or null if none found.
  33149. */
  33150. getLightByID(id: string): Nullable<Light>;
  33151. /**
  33152. * Gets a light node using its scene-generated unique ID
  33153. * @param uniqueId defines the light's unique id
  33154. * @return the light or null if none found.
  33155. */
  33156. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33157. /**
  33158. * Gets a particle system by id
  33159. * @param id defines the particle system id
  33160. * @return the corresponding system or null if none found
  33161. */
  33162. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33163. /**
  33164. * Gets a geometry using its ID
  33165. * @param id defines the geometry's id
  33166. * @return the geometry or null if none found.
  33167. */
  33168. getGeometryByID(id: string): Nullable<Geometry>;
  33169. private _getGeometryByUniqueID;
  33170. /**
  33171. * Add a new geometry to this scene
  33172. * @param geometry defines the geometry to be added to the scene.
  33173. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33174. * @return a boolean defining if the geometry was added or not
  33175. */
  33176. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33177. /**
  33178. * Removes an existing geometry
  33179. * @param geometry defines the geometry to be removed from the scene
  33180. * @return a boolean defining if the geometry was removed or not
  33181. */
  33182. removeGeometry(geometry: Geometry): boolean;
  33183. /**
  33184. * Gets the list of geometries attached to the scene
  33185. * @returns an array of Geometry
  33186. */
  33187. getGeometries(): Geometry[];
  33188. /**
  33189. * Gets the first added mesh found of a given ID
  33190. * @param id defines the id to search for
  33191. * @return the mesh found or null if not found at all
  33192. */
  33193. getMeshByID(id: string): Nullable<AbstractMesh>;
  33194. /**
  33195. * Gets a list of meshes using their id
  33196. * @param id defines the id to search for
  33197. * @returns a list of meshes
  33198. */
  33199. getMeshesByID(id: string): Array<AbstractMesh>;
  33200. /**
  33201. * Gets the first added transform node found of a given ID
  33202. * @param id defines the id to search for
  33203. * @return the found transform node or null if not found at all.
  33204. */
  33205. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33206. /**
  33207. * Gets a list of transform nodes using their id
  33208. * @param id defines the id to search for
  33209. * @returns a list of transform nodes
  33210. */
  33211. getTransformNodesByID(id: string): Array<TransformNode>;
  33212. /**
  33213. * Gets a mesh with its auto-generated unique id
  33214. * @param uniqueId defines the unique id to search for
  33215. * @return the found mesh or null if not found at all.
  33216. */
  33217. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33218. /**
  33219. * Gets a the last added mesh using a given id
  33220. * @param id defines the id to search for
  33221. * @return the found mesh or null if not found at all.
  33222. */
  33223. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33224. /**
  33225. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33226. * @param id defines the id to search for
  33227. * @return the found node or null if not found at all
  33228. */
  33229. getLastEntryByID(id: string): Nullable<Node>;
  33230. /**
  33231. * Gets a node (Mesh, Camera, Light) using a given id
  33232. * @param id defines the id to search for
  33233. * @return the found node or null if not found at all
  33234. */
  33235. getNodeByID(id: string): Nullable<Node>;
  33236. /**
  33237. * Gets a node (Mesh, Camera, Light) using a given name
  33238. * @param name defines the name to search for
  33239. * @return the found node or null if not found at all.
  33240. */
  33241. getNodeByName(name: string): Nullable<Node>;
  33242. /**
  33243. * Gets a mesh using a given name
  33244. * @param name defines the name to search for
  33245. * @return the found mesh or null if not found at all.
  33246. */
  33247. getMeshByName(name: string): Nullable<AbstractMesh>;
  33248. /**
  33249. * Gets a transform node using a given name
  33250. * @param name defines the name to search for
  33251. * @return the found transform node or null if not found at all.
  33252. */
  33253. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33254. /**
  33255. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33256. * @param id defines the id to search for
  33257. * @return the found skeleton or null if not found at all.
  33258. */
  33259. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33260. /**
  33261. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33262. * @param id defines the id to search for
  33263. * @return the found skeleton or null if not found at all.
  33264. */
  33265. getSkeletonById(id: string): Nullable<Skeleton>;
  33266. /**
  33267. * Gets a skeleton using a given name
  33268. * @param name defines the name to search for
  33269. * @return the found skeleton or null if not found at all.
  33270. */
  33271. getSkeletonByName(name: string): Nullable<Skeleton>;
  33272. /**
  33273. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33274. * @param id defines the id to search for
  33275. * @return the found morph target manager or null if not found at all.
  33276. */
  33277. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33278. /**
  33279. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33280. * @param id defines the id to search for
  33281. * @return the found morph target or null if not found at all.
  33282. */
  33283. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33284. /**
  33285. * Gets a boolean indicating if the given mesh is active
  33286. * @param mesh defines the mesh to look for
  33287. * @returns true if the mesh is in the active list
  33288. */
  33289. isActiveMesh(mesh: AbstractMesh): boolean;
  33290. /**
  33291. * Return a unique id as a string which can serve as an identifier for the scene
  33292. */
  33293. readonly uid: string;
  33294. /**
  33295. * Add an externaly attached data from its key.
  33296. * This method call will fail and return false, if such key already exists.
  33297. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33298. * @param key the unique key that identifies the data
  33299. * @param data the data object to associate to the key for this Engine instance
  33300. * @return true if no such key were already present and the data was added successfully, false otherwise
  33301. */
  33302. addExternalData<T>(key: string, data: T): boolean;
  33303. /**
  33304. * Get an externaly attached data from its key
  33305. * @param key the unique key that identifies the data
  33306. * @return the associated data, if present (can be null), or undefined if not present
  33307. */
  33308. getExternalData<T>(key: string): Nullable<T>;
  33309. /**
  33310. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33311. * @param key the unique key that identifies the data
  33312. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33313. * @return the associated data, can be null if the factory returned null.
  33314. */
  33315. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33316. /**
  33317. * Remove an externaly attached data from the Engine instance
  33318. * @param key the unique key that identifies the data
  33319. * @return true if the data was successfully removed, false if it doesn't exist
  33320. */
  33321. removeExternalData(key: string): boolean;
  33322. private _evaluateSubMesh;
  33323. /**
  33324. * Clear the processed materials smart array preventing retention point in material dispose.
  33325. */
  33326. freeProcessedMaterials(): void;
  33327. private _preventFreeActiveMeshesAndRenderingGroups;
  33328. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33329. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33330. * when disposing several meshes in a row or a hierarchy of meshes.
  33331. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33332. */
  33333. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33334. /**
  33335. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33336. */
  33337. freeActiveMeshes(): void;
  33338. /**
  33339. * Clear the info related to rendering groups preventing retention points during dispose.
  33340. */
  33341. freeRenderingGroups(): void;
  33342. /** @hidden */
  33343. _isInIntermediateRendering(): boolean;
  33344. /**
  33345. * Lambda returning the list of potentially active meshes.
  33346. */
  33347. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33348. /**
  33349. * Lambda returning the list of potentially active sub meshes.
  33350. */
  33351. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33352. /**
  33353. * Lambda returning the list of potentially intersecting sub meshes.
  33354. */
  33355. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33356. /**
  33357. * Lambda returning the list of potentially colliding sub meshes.
  33358. */
  33359. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33360. private _activeMeshesFrozen;
  33361. /**
  33362. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33363. * @returns the current scene
  33364. */
  33365. freezeActiveMeshes(): Scene;
  33366. /**
  33367. * Use this function to restart evaluating active meshes on every frame
  33368. * @returns the current scene
  33369. */
  33370. unfreezeActiveMeshes(): Scene;
  33371. private _evaluateActiveMeshes;
  33372. private _activeMesh;
  33373. /**
  33374. * Update the transform matrix to update from the current active camera
  33375. * @param force defines a boolean used to force the update even if cache is up to date
  33376. */
  33377. updateTransformMatrix(force?: boolean): void;
  33378. /**
  33379. * 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)
  33380. * @param alternateCamera defines the camera to use
  33381. */
  33382. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33383. /** @hidden */
  33384. _allowPostProcessClearColor: boolean;
  33385. private _renderForCamera;
  33386. private _processSubCameras;
  33387. private _checkIntersections;
  33388. /** @hidden */
  33389. _advancePhysicsEngineStep(step: number): void;
  33390. /**
  33391. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33392. */
  33393. getDeterministicFrameTime: () => number;
  33394. /** @hidden */
  33395. _animate(): void;
  33396. /**
  33397. * Render the scene
  33398. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33399. */
  33400. render(updateCameras?: boolean): void;
  33401. /**
  33402. * Freeze all materials
  33403. * A frozen material will not be updatable but should be faster to render
  33404. */
  33405. freezeMaterials(): void;
  33406. /**
  33407. * Unfreeze all materials
  33408. * A frozen material will not be updatable but should be faster to render
  33409. */
  33410. unfreezeMaterials(): void;
  33411. /**
  33412. * Releases all held ressources
  33413. */
  33414. dispose(): void;
  33415. /**
  33416. * Gets if the scene is already disposed
  33417. */
  33418. readonly isDisposed: boolean;
  33419. /**
  33420. * Call this function to reduce memory footprint of the scene.
  33421. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33422. */
  33423. clearCachedVertexData(): void;
  33424. /**
  33425. * This function will remove the local cached buffer data from texture.
  33426. * It will save memory but will prevent the texture from being rebuilt
  33427. */
  33428. cleanCachedTextureBuffer(): void;
  33429. /**
  33430. * Get the world extend vectors with an optional filter
  33431. *
  33432. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33433. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33434. */
  33435. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33436. min: Vector3;
  33437. max: Vector3;
  33438. };
  33439. /**
  33440. * Creates a ray that can be used to pick in the scene
  33441. * @param x defines the x coordinate of the origin (on-screen)
  33442. * @param y defines the y coordinate of the origin (on-screen)
  33443. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33444. * @param camera defines the camera to use for the picking
  33445. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33446. * @returns a Ray
  33447. */
  33448. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33449. /**
  33450. * Creates a ray that can be used to pick in the scene
  33451. * @param x defines the x coordinate of the origin (on-screen)
  33452. * @param y defines the y coordinate of the origin (on-screen)
  33453. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33454. * @param result defines the ray where to store the picking ray
  33455. * @param camera defines the camera to use for the picking
  33456. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33457. * @returns the current scene
  33458. */
  33459. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33460. /**
  33461. * Creates a ray that can be used to pick in the scene
  33462. * @param x defines the x coordinate of the origin (on-screen)
  33463. * @param y defines the y coordinate of the origin (on-screen)
  33464. * @param camera defines the camera to use for the picking
  33465. * @returns a Ray
  33466. */
  33467. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33468. /**
  33469. * Creates a ray that can be used to pick in the scene
  33470. * @param x defines the x coordinate of the origin (on-screen)
  33471. * @param y defines the y coordinate of the origin (on-screen)
  33472. * @param result defines the ray where to store the picking ray
  33473. * @param camera defines the camera to use for the picking
  33474. * @returns the current scene
  33475. */
  33476. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33477. /** Launch a ray to try to pick a mesh in the scene
  33478. * @param x position on screen
  33479. * @param y position on screen
  33480. * @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
  33481. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33482. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33483. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33484. * @returns a PickingInfo
  33485. */
  33486. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33487. /** Use the given ray to pick a mesh in the scene
  33488. * @param ray The ray to use to pick meshes
  33489. * @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
  33490. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33492. * @returns a PickingInfo
  33493. */
  33494. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33495. /**
  33496. * Launch a ray to try to pick a mesh in the scene
  33497. * @param x X position on screen
  33498. * @param y Y position on screen
  33499. * @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
  33500. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33502. * @returns an array of PickingInfo
  33503. */
  33504. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33505. /**
  33506. * Launch a ray to try to pick a mesh in the scene
  33507. * @param ray Ray to use
  33508. * @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
  33509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33510. * @returns an array of PickingInfo
  33511. */
  33512. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33513. /**
  33514. * Force the value of meshUnderPointer
  33515. * @param mesh defines the mesh to use
  33516. */
  33517. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33518. /**
  33519. * Gets the mesh under the pointer
  33520. * @returns a Mesh or null if no mesh is under the pointer
  33521. */
  33522. getPointerOverMesh(): Nullable<AbstractMesh>;
  33523. /** @hidden */
  33524. _rebuildGeometries(): void;
  33525. /** @hidden */
  33526. _rebuildTextures(): void;
  33527. private _getByTags;
  33528. /**
  33529. * Get a list of meshes by tags
  33530. * @param tagsQuery defines the tags query to use
  33531. * @param forEach defines a predicate used to filter results
  33532. * @returns an array of Mesh
  33533. */
  33534. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33535. /**
  33536. * Get a list of cameras by tags
  33537. * @param tagsQuery defines the tags query to use
  33538. * @param forEach defines a predicate used to filter results
  33539. * @returns an array of Camera
  33540. */
  33541. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33542. /**
  33543. * Get a list of lights by tags
  33544. * @param tagsQuery defines the tags query to use
  33545. * @param forEach defines a predicate used to filter results
  33546. * @returns an array of Light
  33547. */
  33548. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33549. /**
  33550. * Get a list of materials by tags
  33551. * @param tagsQuery defines the tags query to use
  33552. * @param forEach defines a predicate used to filter results
  33553. * @returns an array of Material
  33554. */
  33555. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33556. /**
  33557. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33558. * This allowed control for front to back rendering or reversly depending of the special needs.
  33559. *
  33560. * @param renderingGroupId The rendering group id corresponding to its index
  33561. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33562. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33563. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33564. */
  33565. 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;
  33566. /**
  33567. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33568. *
  33569. * @param renderingGroupId The rendering group id corresponding to its index
  33570. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33571. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33572. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33573. */
  33574. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33575. /**
  33576. * Gets the current auto clear configuration for one rendering group of the rendering
  33577. * manager.
  33578. * @param index the rendering group index to get the information for
  33579. * @returns The auto clear setup for the requested rendering group
  33580. */
  33581. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33582. private _blockMaterialDirtyMechanism;
  33583. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33584. blockMaterialDirtyMechanism: boolean;
  33585. /**
  33586. * Will flag all materials as dirty to trigger new shader compilation
  33587. * @param flag defines the flag used to specify which material part must be marked as dirty
  33588. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33589. */
  33590. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33591. /** @hidden */
  33592. _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;
  33593. /** @hidden */
  33594. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33595. }
  33596. }
  33597. declare module "babylonjs/assetContainer" {
  33598. import { AbstractScene } from "babylonjs/abstractScene";
  33599. import { Scene } from "babylonjs/scene";
  33600. import { Mesh } from "babylonjs/Meshes/mesh";
  33601. /**
  33602. * Set of assets to keep when moving a scene into an asset container.
  33603. */
  33604. export class KeepAssets extends AbstractScene {
  33605. }
  33606. /**
  33607. * Container with a set of assets that can be added or removed from a scene.
  33608. */
  33609. export class AssetContainer extends AbstractScene {
  33610. /**
  33611. * The scene the AssetContainer belongs to.
  33612. */
  33613. scene: Scene;
  33614. /**
  33615. * Instantiates an AssetContainer.
  33616. * @param scene The scene the AssetContainer belongs to.
  33617. */
  33618. constructor(scene: Scene);
  33619. /**
  33620. * Adds all the assets from the container to the scene.
  33621. */
  33622. addAllToScene(): void;
  33623. /**
  33624. * Removes all the assets in the container from the scene
  33625. */
  33626. removeAllFromScene(): void;
  33627. /**
  33628. * Disposes all the assets in the container
  33629. */
  33630. dispose(): void;
  33631. private _moveAssets;
  33632. /**
  33633. * Removes all the assets contained in the scene and adds them to the container.
  33634. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33635. */
  33636. moveAllFromScene(keepAssets?: KeepAssets): void;
  33637. /**
  33638. * 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.
  33639. * @returns the root mesh
  33640. */
  33641. createRootMesh(): Mesh;
  33642. }
  33643. }
  33644. declare module "babylonjs/abstractScene" {
  33645. import { Scene } from "babylonjs/scene";
  33646. import { Nullable } from "babylonjs/types";
  33647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33648. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33649. import { Geometry } from "babylonjs/Meshes/geometry";
  33650. import { Skeleton } from "babylonjs/Bones/skeleton";
  33651. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33652. import { AssetContainer } from "babylonjs/assetContainer";
  33653. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33654. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33656. import { Material } from "babylonjs/Materials/material";
  33657. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33658. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33659. import { Camera } from "babylonjs/Cameras/camera";
  33660. import { Light } from "babylonjs/Lights/light";
  33661. import { Node } from "babylonjs/node";
  33662. import { Animation } from "babylonjs/Animations/animation";
  33663. /**
  33664. * Defines how the parser contract is defined.
  33665. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33666. */
  33667. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33668. /**
  33669. * Defines how the individual parser contract is defined.
  33670. * These parser can parse an individual asset
  33671. */
  33672. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33673. /**
  33674. * Base class of the scene acting as a container for the different elements composing a scene.
  33675. * This class is dynamically extended by the different components of the scene increasing
  33676. * flexibility and reducing coupling
  33677. */
  33678. export abstract class AbstractScene {
  33679. /**
  33680. * Stores the list of available parsers in the application.
  33681. */
  33682. private static _BabylonFileParsers;
  33683. /**
  33684. * Stores the list of available individual parsers in the application.
  33685. */
  33686. private static _IndividualBabylonFileParsers;
  33687. /**
  33688. * Adds a parser in the list of available ones
  33689. * @param name Defines the name of the parser
  33690. * @param parser Defines the parser to add
  33691. */
  33692. static AddParser(name: string, parser: BabylonFileParser): void;
  33693. /**
  33694. * Gets a general parser from the list of avaialble ones
  33695. * @param name Defines the name of the parser
  33696. * @returns the requested parser or null
  33697. */
  33698. static GetParser(name: string): Nullable<BabylonFileParser>;
  33699. /**
  33700. * Adds n individual parser in the list of available ones
  33701. * @param name Defines the name of the parser
  33702. * @param parser Defines the parser to add
  33703. */
  33704. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33705. /**
  33706. * Gets an individual parser from the list of avaialble ones
  33707. * @param name Defines the name of the parser
  33708. * @returns the requested parser or null
  33709. */
  33710. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33711. /**
  33712. * Parser json data and populate both a scene and its associated container object
  33713. * @param jsonData Defines the data to parse
  33714. * @param scene Defines the scene to parse the data for
  33715. * @param container Defines the container attached to the parsing sequence
  33716. * @param rootUrl Defines the root url of the data
  33717. */
  33718. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33719. /**
  33720. * Gets the list of root nodes (ie. nodes with no parent)
  33721. */
  33722. rootNodes: Node[];
  33723. /** All of the cameras added to this scene
  33724. * @see http://doc.babylonjs.com/babylon101/cameras
  33725. */
  33726. cameras: Camera[];
  33727. /**
  33728. * All of the lights added to this scene
  33729. * @see http://doc.babylonjs.com/babylon101/lights
  33730. */
  33731. lights: Light[];
  33732. /**
  33733. * All of the (abstract) meshes added to this scene
  33734. */
  33735. meshes: AbstractMesh[];
  33736. /**
  33737. * The list of skeletons added to the scene
  33738. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33739. */
  33740. skeletons: Skeleton[];
  33741. /**
  33742. * All of the particle systems added to this scene
  33743. * @see http://doc.babylonjs.com/babylon101/particles
  33744. */
  33745. particleSystems: IParticleSystem[];
  33746. /**
  33747. * Gets a list of Animations associated with the scene
  33748. */
  33749. animations: Animation[];
  33750. /**
  33751. * All of the animation groups added to this scene
  33752. * @see http://doc.babylonjs.com/how_to/group
  33753. */
  33754. animationGroups: AnimationGroup[];
  33755. /**
  33756. * All of the multi-materials added to this scene
  33757. * @see http://doc.babylonjs.com/how_to/multi_materials
  33758. */
  33759. multiMaterials: MultiMaterial[];
  33760. /**
  33761. * All of the materials 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 addMaterial and removeMAterial Scene methods.
  33764. * Note also that the order of the Material wihin the array is not significant and might change.
  33765. * @see http://doc.babylonjs.com/babylon101/materials
  33766. */
  33767. materials: Material[];
  33768. /**
  33769. * The list of morph target managers added to the scene
  33770. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33771. */
  33772. morphTargetManagers: MorphTargetManager[];
  33773. /**
  33774. * The list of geometries used in the scene.
  33775. */
  33776. geometries: Geometry[];
  33777. /**
  33778. * All of the tranform nodes added to this scene
  33779. * In the context of a Scene, it is not supposed to be modified manually.
  33780. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33781. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33782. * @see http://doc.babylonjs.com/how_to/transformnode
  33783. */
  33784. transformNodes: TransformNode[];
  33785. /**
  33786. * ActionManagers available on the scene.
  33787. */
  33788. actionManagers: AbstractActionManager[];
  33789. /**
  33790. * Textures to keep.
  33791. */
  33792. textures: BaseTexture[];
  33793. }
  33794. }
  33795. declare module "babylonjs/Audio/sound" {
  33796. import { Observable } from "babylonjs/Misc/observable";
  33797. import { Vector3 } from "babylonjs/Maths/math";
  33798. import { Nullable } from "babylonjs/types";
  33799. import { Scene } from "babylonjs/scene";
  33800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33801. /**
  33802. * Defines a sound that can be played in the application.
  33803. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33805. */
  33806. export class Sound {
  33807. /**
  33808. * The name of the sound in the scene.
  33809. */
  33810. name: string;
  33811. /**
  33812. * Does the sound autoplay once loaded.
  33813. */
  33814. autoplay: boolean;
  33815. /**
  33816. * Does the sound loop after it finishes playing once.
  33817. */
  33818. loop: boolean;
  33819. /**
  33820. * Does the sound use a custom attenuation curve to simulate the falloff
  33821. * happening when the source gets further away from the camera.
  33822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33823. */
  33824. useCustomAttenuation: boolean;
  33825. /**
  33826. * The sound track id this sound belongs to.
  33827. */
  33828. soundTrackId: number;
  33829. /**
  33830. * Is this sound currently played.
  33831. */
  33832. isPlaying: boolean;
  33833. /**
  33834. * Is this sound currently paused.
  33835. */
  33836. isPaused: boolean;
  33837. /**
  33838. * Does this sound enables spatial sound.
  33839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33840. */
  33841. spatialSound: boolean;
  33842. /**
  33843. * Define the reference distance the sound should be heard perfectly.
  33844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33845. */
  33846. refDistance: number;
  33847. /**
  33848. * Define the roll off factor of spatial sounds.
  33849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33850. */
  33851. rolloffFactor: number;
  33852. /**
  33853. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33855. */
  33856. maxDistance: number;
  33857. /**
  33858. * Define the distance attenuation model the sound will follow.
  33859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33860. */
  33861. distanceModel: string;
  33862. /**
  33863. * @hidden
  33864. * Back Compat
  33865. **/
  33866. onended: () => any;
  33867. /**
  33868. * Observable event when the current playing sound finishes.
  33869. */
  33870. onEndedObservable: Observable<Sound>;
  33871. private _panningModel;
  33872. private _playbackRate;
  33873. private _streaming;
  33874. private _startTime;
  33875. private _startOffset;
  33876. private _position;
  33877. /** @hidden */
  33878. _positionInEmitterSpace: boolean;
  33879. private _localDirection;
  33880. private _volume;
  33881. private _isReadyToPlay;
  33882. private _isDirectional;
  33883. private _readyToPlayCallback;
  33884. private _audioBuffer;
  33885. private _soundSource;
  33886. private _streamingSource;
  33887. private _soundPanner;
  33888. private _soundGain;
  33889. private _inputAudioNode;
  33890. private _outputAudioNode;
  33891. private _coneInnerAngle;
  33892. private _coneOuterAngle;
  33893. private _coneOuterGain;
  33894. private _scene;
  33895. private _connectedTransformNode;
  33896. private _customAttenuationFunction;
  33897. private _registerFunc;
  33898. private _isOutputConnected;
  33899. private _htmlAudioElement;
  33900. private _urlType;
  33901. /** @hidden */
  33902. static _SceneComponentInitialization: (scene: Scene) => void;
  33903. /**
  33904. * Create a sound and attach it to a scene
  33905. * @param name Name of your sound
  33906. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33907. * @param scene defines the scene the sound belongs to
  33908. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33909. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33910. */
  33911. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33912. /**
  33913. * Release the sound and its associated resources
  33914. */
  33915. dispose(): void;
  33916. /**
  33917. * Gets if the sounds is ready to be played or not.
  33918. * @returns true if ready, otherwise false
  33919. */
  33920. isReady(): boolean;
  33921. private _soundLoaded;
  33922. /**
  33923. * Sets the data of the sound from an audiobuffer
  33924. * @param audioBuffer The audioBuffer containing the data
  33925. */
  33926. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33927. /**
  33928. * Updates the current sounds options such as maxdistance, loop...
  33929. * @param options A JSON object containing values named as the object properties
  33930. */
  33931. updateOptions(options: any): void;
  33932. private _createSpatialParameters;
  33933. private _updateSpatialParameters;
  33934. /**
  33935. * Switch the panning model to HRTF:
  33936. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33938. */
  33939. switchPanningModelToHRTF(): void;
  33940. /**
  33941. * Switch the panning model to Equal Power:
  33942. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33944. */
  33945. switchPanningModelToEqualPower(): void;
  33946. private _switchPanningModel;
  33947. /**
  33948. * Connect this sound to a sound track audio node like gain...
  33949. * @param soundTrackAudioNode the sound track audio node to connect to
  33950. */
  33951. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33952. /**
  33953. * Transform this sound into a directional source
  33954. * @param coneInnerAngle Size of the inner cone in degree
  33955. * @param coneOuterAngle Size of the outer cone in degree
  33956. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33957. */
  33958. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33959. /**
  33960. * Gets or sets the inner angle for the directional cone.
  33961. */
  33962. /**
  33963. * Gets or sets the inner angle for the directional cone.
  33964. */
  33965. directionalConeInnerAngle: number;
  33966. /**
  33967. * Gets or sets the outer angle for the directional cone.
  33968. */
  33969. /**
  33970. * Gets or sets the outer angle for the directional cone.
  33971. */
  33972. directionalConeOuterAngle: number;
  33973. /**
  33974. * Sets the position of the emitter if spatial sound is enabled
  33975. * @param newPosition Defines the new posisiton
  33976. */
  33977. setPosition(newPosition: Vector3): void;
  33978. /**
  33979. * Sets the local direction of the emitter if spatial sound is enabled
  33980. * @param newLocalDirection Defines the new local direction
  33981. */
  33982. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33983. private _updateDirection;
  33984. /** @hidden */
  33985. updateDistanceFromListener(): void;
  33986. /**
  33987. * Sets a new custom attenuation function for the sound.
  33988. * @param callback Defines the function used for the attenuation
  33989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33990. */
  33991. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33992. /**
  33993. * Play the sound
  33994. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33995. * @param offset (optional) Start the sound setting it at a specific time
  33996. */
  33997. play(time?: number, offset?: number): void;
  33998. private _onended;
  33999. /**
  34000. * Stop the sound
  34001. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34002. */
  34003. stop(time?: number): void;
  34004. /**
  34005. * Put the sound in pause
  34006. */
  34007. pause(): void;
  34008. /**
  34009. * Sets a dedicated volume for this sounds
  34010. * @param newVolume Define the new volume of the sound
  34011. * @param time Define in how long the sound should be at this value
  34012. */
  34013. setVolume(newVolume: number, time?: number): void;
  34014. /**
  34015. * Set the sound play back rate
  34016. * @param newPlaybackRate Define the playback rate the sound should be played at
  34017. */
  34018. setPlaybackRate(newPlaybackRate: number): void;
  34019. /**
  34020. * Gets the volume of the sound.
  34021. * @returns the volume of the sound
  34022. */
  34023. getVolume(): number;
  34024. /**
  34025. * Attach the sound to a dedicated mesh
  34026. * @param transformNode The transform node to connect the sound with
  34027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34028. */
  34029. attachToMesh(transformNode: TransformNode): void;
  34030. /**
  34031. * Detach the sound from the previously attached mesh
  34032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34033. */
  34034. detachFromMesh(): void;
  34035. private _onRegisterAfterWorldMatrixUpdate;
  34036. /**
  34037. * Clone the current sound in the scene.
  34038. * @returns the new sound clone
  34039. */
  34040. clone(): Nullable<Sound>;
  34041. /**
  34042. * Gets the current underlying audio buffer containing the data
  34043. * @returns the audio buffer
  34044. */
  34045. getAudioBuffer(): Nullable<AudioBuffer>;
  34046. /**
  34047. * Serializes the Sound in a JSON representation
  34048. * @returns the JSON representation of the sound
  34049. */
  34050. serialize(): any;
  34051. /**
  34052. * Parse a JSON representation of a sound to innstantiate in a given scene
  34053. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34054. * @param scene Define the scene the new parsed sound should be created in
  34055. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34056. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34057. * @returns the newly parsed sound
  34058. */
  34059. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34060. }
  34061. }
  34062. declare module "babylonjs/Actions/directAudioActions" {
  34063. import { Action } from "babylonjs/Actions/action";
  34064. import { Condition } from "babylonjs/Actions/condition";
  34065. import { Sound } from "babylonjs/Audio/sound";
  34066. /**
  34067. * This defines an action helpful to play a defined sound on a triggered action.
  34068. */
  34069. export class PlaySoundAction extends Action {
  34070. private _sound;
  34071. /**
  34072. * Instantiate the action
  34073. * @param triggerOptions defines the trigger options
  34074. * @param sound defines the sound to play
  34075. * @param condition defines the trigger related conditions
  34076. */
  34077. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34078. /** @hidden */
  34079. _prepare(): void;
  34080. /**
  34081. * Execute the action and play the sound.
  34082. */
  34083. execute(): void;
  34084. /**
  34085. * Serializes the actions and its related information.
  34086. * @param parent defines the object to serialize in
  34087. * @returns the serialized object
  34088. */
  34089. serialize(parent: any): any;
  34090. }
  34091. /**
  34092. * This defines an action helpful to stop a defined sound on a triggered action.
  34093. */
  34094. export class StopSoundAction extends Action {
  34095. private _sound;
  34096. /**
  34097. * Instantiate the action
  34098. * @param triggerOptions defines the trigger options
  34099. * @param sound defines the sound to stop
  34100. * @param condition defines the trigger related conditions
  34101. */
  34102. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34103. /** @hidden */
  34104. _prepare(): void;
  34105. /**
  34106. * Execute the action and stop the sound.
  34107. */
  34108. execute(): void;
  34109. /**
  34110. * Serializes the actions and its related information.
  34111. * @param parent defines the object to serialize in
  34112. * @returns the serialized object
  34113. */
  34114. serialize(parent: any): any;
  34115. }
  34116. }
  34117. declare module "babylonjs/Actions/interpolateValueAction" {
  34118. import { Action } from "babylonjs/Actions/action";
  34119. import { Condition } from "babylonjs/Actions/condition";
  34120. import { Observable } from "babylonjs/Misc/observable";
  34121. /**
  34122. * This defines an action responsible to change the value of a property
  34123. * by interpolating between its current value and the newly set one once triggered.
  34124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34125. */
  34126. export class InterpolateValueAction extends Action {
  34127. /**
  34128. * Defines the path of the property where the value should be interpolated
  34129. */
  34130. propertyPath: string;
  34131. /**
  34132. * Defines the target value at the end of the interpolation.
  34133. */
  34134. value: any;
  34135. /**
  34136. * Defines the time it will take for the property to interpolate to the value.
  34137. */
  34138. duration: number;
  34139. /**
  34140. * Defines if the other scene animations should be stopped when the action has been triggered
  34141. */
  34142. stopOtherAnimations?: boolean;
  34143. /**
  34144. * Defines a callback raised once the interpolation animation has been done.
  34145. */
  34146. onInterpolationDone?: () => void;
  34147. /**
  34148. * Observable triggered once the interpolation animation has been done.
  34149. */
  34150. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34151. private _target;
  34152. private _effectiveTarget;
  34153. private _property;
  34154. /**
  34155. * Instantiate the action
  34156. * @param triggerOptions defines the trigger options
  34157. * @param target defines the object containing the value to interpolate
  34158. * @param propertyPath defines the path to the property in the target object
  34159. * @param value defines the target value at the end of the interpolation
  34160. * @param duration deines the time it will take for the property to interpolate to the value.
  34161. * @param condition defines the trigger related conditions
  34162. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34163. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34164. */
  34165. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34166. /** @hidden */
  34167. _prepare(): void;
  34168. /**
  34169. * Execute the action starts the value interpolation.
  34170. */
  34171. execute(): void;
  34172. /**
  34173. * Serializes the actions and its related information.
  34174. * @param parent defines the object to serialize in
  34175. * @returns the serialized object
  34176. */
  34177. serialize(parent: any): any;
  34178. }
  34179. }
  34180. declare module "babylonjs/Actions/index" {
  34181. export * from "babylonjs/Actions/action";
  34182. export * from "babylonjs/Actions/actionEvent";
  34183. export * from "babylonjs/Actions/actionManager";
  34184. export * from "babylonjs/Actions/condition";
  34185. export * from "babylonjs/Actions/directActions";
  34186. export * from "babylonjs/Actions/directAudioActions";
  34187. export * from "babylonjs/Actions/interpolateValueAction";
  34188. }
  34189. declare module "babylonjs/Animations/index" {
  34190. export * from "babylonjs/Animations/animatable";
  34191. export * from "babylonjs/Animations/animation";
  34192. export * from "babylonjs/Animations/animationGroup";
  34193. export * from "babylonjs/Animations/animationPropertiesOverride";
  34194. export * from "babylonjs/Animations/easing";
  34195. export * from "babylonjs/Animations/runtimeAnimation";
  34196. export * from "babylonjs/Animations/animationEvent";
  34197. export * from "babylonjs/Animations/animationGroup";
  34198. export * from "babylonjs/Animations/animationKey";
  34199. export * from "babylonjs/Animations/animationRange";
  34200. }
  34201. declare module "babylonjs/Audio/soundTrack" {
  34202. import { Sound } from "babylonjs/Audio/sound";
  34203. import { Analyser } from "babylonjs/Audio/analyser";
  34204. import { Scene } from "babylonjs/scene";
  34205. /**
  34206. * Options allowed during the creation of a sound track.
  34207. */
  34208. export interface ISoundTrackOptions {
  34209. /**
  34210. * The volume the sound track should take during creation
  34211. */
  34212. volume?: number;
  34213. /**
  34214. * Define if the sound track is the main sound track of the scene
  34215. */
  34216. mainTrack?: boolean;
  34217. }
  34218. /**
  34219. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34220. * It will be also used in a future release to apply effects on a specific track.
  34221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34222. */
  34223. export class SoundTrack {
  34224. /**
  34225. * The unique identifier of the sound track in the scene.
  34226. */
  34227. id: number;
  34228. /**
  34229. * The list of sounds included in the sound track.
  34230. */
  34231. soundCollection: Array<Sound>;
  34232. private _outputAudioNode;
  34233. private _scene;
  34234. private _isMainTrack;
  34235. private _connectedAnalyser;
  34236. private _options;
  34237. private _isInitialized;
  34238. /**
  34239. * Creates a new sound track.
  34240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34241. * @param scene Define the scene the sound track belongs to
  34242. * @param options
  34243. */
  34244. constructor(scene: Scene, options?: ISoundTrackOptions);
  34245. private _initializeSoundTrackAudioGraph;
  34246. /**
  34247. * Release the sound track and its associated resources
  34248. */
  34249. dispose(): void;
  34250. /**
  34251. * Adds a sound to this sound track
  34252. * @param sound define the cound to add
  34253. * @ignoreNaming
  34254. */
  34255. AddSound(sound: Sound): void;
  34256. /**
  34257. * Removes a sound to this sound track
  34258. * @param sound define the cound to remove
  34259. * @ignoreNaming
  34260. */
  34261. RemoveSound(sound: Sound): void;
  34262. /**
  34263. * Set a global volume for the full sound track.
  34264. * @param newVolume Define the new volume of the sound track
  34265. */
  34266. setVolume(newVolume: number): void;
  34267. /**
  34268. * Switch the panning model to HRTF:
  34269. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34271. */
  34272. switchPanningModelToHRTF(): void;
  34273. /**
  34274. * Switch the panning model to Equal Power:
  34275. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34277. */
  34278. switchPanningModelToEqualPower(): void;
  34279. /**
  34280. * Connect the sound track to an audio analyser allowing some amazing
  34281. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34283. * @param analyser The analyser to connect to the engine
  34284. */
  34285. connectToAnalyser(analyser: Analyser): void;
  34286. }
  34287. }
  34288. declare module "babylonjs/Audio/audioSceneComponent" {
  34289. import { Sound } from "babylonjs/Audio/sound";
  34290. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34291. import { Nullable } from "babylonjs/types";
  34292. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34293. import { Scene } from "babylonjs/scene";
  34294. import { AbstractScene } from "babylonjs/abstractScene";
  34295. module "babylonjs/abstractScene" {
  34296. interface AbstractScene {
  34297. /**
  34298. * The list of sounds used in the scene.
  34299. */
  34300. sounds: Nullable<Array<Sound>>;
  34301. }
  34302. }
  34303. module "babylonjs/scene" {
  34304. interface Scene {
  34305. /**
  34306. * @hidden
  34307. * Backing field
  34308. */
  34309. _mainSoundTrack: SoundTrack;
  34310. /**
  34311. * The main sound track played by the scene.
  34312. * It cotains your primary collection of sounds.
  34313. */
  34314. mainSoundTrack: SoundTrack;
  34315. /**
  34316. * The list of sound tracks added to the scene
  34317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34318. */
  34319. soundTracks: Nullable<Array<SoundTrack>>;
  34320. /**
  34321. * Gets a sound using a given name
  34322. * @param name defines the name to search for
  34323. * @return the found sound or null if not found at all.
  34324. */
  34325. getSoundByName(name: string): Nullable<Sound>;
  34326. /**
  34327. * Gets or sets if audio support is enabled
  34328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34329. */
  34330. audioEnabled: boolean;
  34331. /**
  34332. * Gets or sets if audio will be output to headphones
  34333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34334. */
  34335. headphone: boolean;
  34336. }
  34337. }
  34338. /**
  34339. * Defines the sound scene component responsible to manage any sounds
  34340. * in a given scene.
  34341. */
  34342. export class AudioSceneComponent implements ISceneSerializableComponent {
  34343. /**
  34344. * The component name helpfull to identify the component in the list of scene components.
  34345. */
  34346. readonly name: string;
  34347. /**
  34348. * The scene the component belongs to.
  34349. */
  34350. scene: Scene;
  34351. private _audioEnabled;
  34352. /**
  34353. * Gets whether audio is enabled or not.
  34354. * Please use related enable/disable method to switch state.
  34355. */
  34356. readonly audioEnabled: boolean;
  34357. private _headphone;
  34358. /**
  34359. * Gets whether audio is outputing to headphone or not.
  34360. * Please use the according Switch methods to change output.
  34361. */
  34362. readonly headphone: boolean;
  34363. /**
  34364. * Creates a new instance of the component for the given scene
  34365. * @param scene Defines the scene to register the component in
  34366. */
  34367. constructor(scene: Scene);
  34368. /**
  34369. * Registers the component in a given scene
  34370. */
  34371. register(): void;
  34372. /**
  34373. * Rebuilds the elements related to this component in case of
  34374. * context lost for instance.
  34375. */
  34376. rebuild(): void;
  34377. /**
  34378. * Serializes the component data to the specified json object
  34379. * @param serializationObject The object to serialize to
  34380. */
  34381. serialize(serializationObject: any): void;
  34382. /**
  34383. * Adds all the element from the container to the scene
  34384. * @param container the container holding the elements
  34385. */
  34386. addFromContainer(container: AbstractScene): void;
  34387. /**
  34388. * Removes all the elements in the container from the scene
  34389. * @param container contains the elements to remove
  34390. */
  34391. removeFromContainer(container: AbstractScene): void;
  34392. /**
  34393. * Disposes the component and the associated ressources.
  34394. */
  34395. dispose(): void;
  34396. /**
  34397. * Disables audio in the associated scene.
  34398. */
  34399. disableAudio(): void;
  34400. /**
  34401. * Enables audio in the associated scene.
  34402. */
  34403. enableAudio(): void;
  34404. /**
  34405. * Switch audio to headphone output.
  34406. */
  34407. switchAudioModeForHeadphones(): void;
  34408. /**
  34409. * Switch audio to normal speakers.
  34410. */
  34411. switchAudioModeForNormalSpeakers(): void;
  34412. private _afterRender;
  34413. }
  34414. }
  34415. declare module "babylonjs/Audio/weightedsound" {
  34416. import { Sound } from "babylonjs/Audio/sound";
  34417. /**
  34418. * Wraps one or more Sound objects and selects one with random weight for playback.
  34419. */
  34420. export class WeightedSound {
  34421. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34422. loop: boolean;
  34423. private _coneInnerAngle;
  34424. private _coneOuterAngle;
  34425. private _volume;
  34426. /** A Sound is currently playing. */
  34427. isPlaying: boolean;
  34428. /** A Sound is currently paused. */
  34429. isPaused: boolean;
  34430. private _sounds;
  34431. private _weights;
  34432. private _currentIndex?;
  34433. /**
  34434. * Creates a new WeightedSound from the list of sounds given.
  34435. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34436. * @param sounds Array of Sounds that will be selected from.
  34437. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34438. */
  34439. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34440. /**
  34441. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34442. */
  34443. /**
  34444. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34445. */
  34446. directionalConeInnerAngle: number;
  34447. /**
  34448. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34449. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34450. */
  34451. /**
  34452. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34453. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34454. */
  34455. directionalConeOuterAngle: number;
  34456. /**
  34457. * Playback volume.
  34458. */
  34459. /**
  34460. * Playback volume.
  34461. */
  34462. volume: number;
  34463. private _onended;
  34464. /**
  34465. * Suspend playback
  34466. */
  34467. pause(): void;
  34468. /**
  34469. * Stop playback
  34470. */
  34471. stop(): void;
  34472. /**
  34473. * Start playback.
  34474. * @param startOffset Position the clip head at a specific time in seconds.
  34475. */
  34476. play(startOffset?: number): void;
  34477. }
  34478. }
  34479. declare module "babylonjs/Audio/index" {
  34480. export * from "babylonjs/Audio/analyser";
  34481. export * from "babylonjs/Audio/audioEngine";
  34482. export * from "babylonjs/Audio/audioSceneComponent";
  34483. export * from "babylonjs/Audio/sound";
  34484. export * from "babylonjs/Audio/soundTrack";
  34485. export * from "babylonjs/Audio/weightedsound";
  34486. }
  34487. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34488. import { Behavior } from "babylonjs/Behaviors/behavior";
  34489. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34490. import { BackEase } from "babylonjs/Animations/easing";
  34491. /**
  34492. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34493. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34494. */
  34495. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34496. /**
  34497. * Gets the name of the behavior.
  34498. */
  34499. readonly name: string;
  34500. /**
  34501. * The easing function used by animations
  34502. */
  34503. static EasingFunction: BackEase;
  34504. /**
  34505. * The easing mode used by animations
  34506. */
  34507. static EasingMode: number;
  34508. /**
  34509. * The duration of the animation, in milliseconds
  34510. */
  34511. transitionDuration: number;
  34512. /**
  34513. * Length of the distance animated by the transition when lower radius is reached
  34514. */
  34515. lowerRadiusTransitionRange: number;
  34516. /**
  34517. * Length of the distance animated by the transition when upper radius is reached
  34518. */
  34519. upperRadiusTransitionRange: number;
  34520. private _autoTransitionRange;
  34521. /**
  34522. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34523. */
  34524. /**
  34525. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34526. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34527. */
  34528. autoTransitionRange: boolean;
  34529. private _attachedCamera;
  34530. private _onAfterCheckInputsObserver;
  34531. private _onMeshTargetChangedObserver;
  34532. /**
  34533. * Initializes the behavior.
  34534. */
  34535. init(): void;
  34536. /**
  34537. * Attaches the behavior to its arc rotate camera.
  34538. * @param camera Defines the camera to attach the behavior to
  34539. */
  34540. attach(camera: ArcRotateCamera): void;
  34541. /**
  34542. * Detaches the behavior from its current arc rotate camera.
  34543. */
  34544. detach(): void;
  34545. private _radiusIsAnimating;
  34546. private _radiusBounceTransition;
  34547. private _animatables;
  34548. private _cachedWheelPrecision;
  34549. /**
  34550. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34551. * @param radiusLimit The limit to check against.
  34552. * @return Bool to indicate if at limit.
  34553. */
  34554. private _isRadiusAtLimit;
  34555. /**
  34556. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34557. * @param radiusDelta The delta by which to animate to. Can be negative.
  34558. */
  34559. private _applyBoundRadiusAnimation;
  34560. /**
  34561. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34562. */
  34563. protected _clearAnimationLocks(): void;
  34564. /**
  34565. * Stops and removes all animations that have been applied to the camera
  34566. */
  34567. stopAllAnimations(): void;
  34568. }
  34569. }
  34570. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34571. import { Behavior } from "babylonjs/Behaviors/behavior";
  34572. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34573. import { ExponentialEase } from "babylonjs/Animations/easing";
  34574. import { Nullable } from "babylonjs/types";
  34575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34576. import { Vector3 } from "babylonjs/Maths/math";
  34577. /**
  34578. * 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.
  34579. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34580. */
  34581. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34582. /**
  34583. * Gets the name of the behavior.
  34584. */
  34585. readonly name: string;
  34586. private _mode;
  34587. private _radiusScale;
  34588. private _positionScale;
  34589. private _defaultElevation;
  34590. private _elevationReturnTime;
  34591. private _elevationReturnWaitTime;
  34592. private _zoomStopsAnimation;
  34593. private _framingTime;
  34594. /**
  34595. * The easing function used by animations
  34596. */
  34597. static EasingFunction: ExponentialEase;
  34598. /**
  34599. * The easing mode used by animations
  34600. */
  34601. static EasingMode: number;
  34602. /**
  34603. * Sets the current mode used by the behavior
  34604. */
  34605. /**
  34606. * Gets current mode used by the behavior.
  34607. */
  34608. mode: number;
  34609. /**
  34610. * Sets the scale applied to the radius (1 by default)
  34611. */
  34612. /**
  34613. * Gets the scale applied to the radius
  34614. */
  34615. radiusScale: number;
  34616. /**
  34617. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34618. */
  34619. /**
  34620. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34621. */
  34622. positionScale: number;
  34623. /**
  34624. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34625. * behaviour is triggered, in radians.
  34626. */
  34627. /**
  34628. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34629. * behaviour is triggered, in radians.
  34630. */
  34631. defaultElevation: number;
  34632. /**
  34633. * Sets the time (in milliseconds) taken to return to the default beta position.
  34634. * Negative value indicates camera should not return to default.
  34635. */
  34636. /**
  34637. * Gets the time (in milliseconds) taken to return to the default beta position.
  34638. * Negative value indicates camera should not return to default.
  34639. */
  34640. elevationReturnTime: number;
  34641. /**
  34642. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34643. */
  34644. /**
  34645. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34646. */
  34647. elevationReturnWaitTime: number;
  34648. /**
  34649. * Sets the flag that indicates if user zooming should stop animation.
  34650. */
  34651. /**
  34652. * Gets the flag that indicates if user zooming should stop animation.
  34653. */
  34654. zoomStopsAnimation: boolean;
  34655. /**
  34656. * Sets the transition time when framing the mesh, in milliseconds
  34657. */
  34658. /**
  34659. * Gets the transition time when framing the mesh, in milliseconds
  34660. */
  34661. framingTime: number;
  34662. /**
  34663. * Define if the behavior should automatically change the configured
  34664. * camera limits and sensibilities.
  34665. */
  34666. autoCorrectCameraLimitsAndSensibility: boolean;
  34667. private _onPrePointerObservableObserver;
  34668. private _onAfterCheckInputsObserver;
  34669. private _onMeshTargetChangedObserver;
  34670. private _attachedCamera;
  34671. private _isPointerDown;
  34672. private _lastInteractionTime;
  34673. /**
  34674. * Initializes the behavior.
  34675. */
  34676. init(): void;
  34677. /**
  34678. * Attaches the behavior to its arc rotate camera.
  34679. * @param camera Defines the camera to attach the behavior to
  34680. */
  34681. attach(camera: ArcRotateCamera): void;
  34682. /**
  34683. * Detaches the behavior from its current arc rotate camera.
  34684. */
  34685. detach(): void;
  34686. private _animatables;
  34687. private _betaIsAnimating;
  34688. private _betaTransition;
  34689. private _radiusTransition;
  34690. private _vectorTransition;
  34691. /**
  34692. * Targets the given mesh and updates zoom level accordingly.
  34693. * @param mesh The mesh to target.
  34694. * @param radius Optional. If a cached radius position already exists, overrides default.
  34695. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34696. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34697. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34698. */
  34699. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34700. /**
  34701. * Targets the given mesh with its children and updates zoom level accordingly.
  34702. * @param mesh The mesh to target.
  34703. * @param radius Optional. If a cached radius position already exists, overrides default.
  34704. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34709. /**
  34710. * Targets the given meshes with their children and updates zoom level accordingly.
  34711. * @param meshes The mesh to target.
  34712. * @param radius Optional. If a cached radius position already exists, overrides default.
  34713. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34714. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34715. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34716. */
  34717. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34718. /**
  34719. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34720. * @param minimumWorld Determines the smaller position of the bounding box extend
  34721. * @param maximumWorld Determines the bigger position of the bounding box extend
  34722. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34723. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34724. */
  34725. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34726. /**
  34727. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34728. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34729. * frustum width.
  34730. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34731. * to fully enclose the mesh in the viewing frustum.
  34732. */
  34733. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34734. /**
  34735. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34736. * is automatically returned to its default position (expected to be above ground plane).
  34737. */
  34738. private _maintainCameraAboveGround;
  34739. /**
  34740. * Returns the frustum slope based on the canvas ratio and camera FOV
  34741. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34742. */
  34743. private _getFrustumSlope;
  34744. /**
  34745. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34746. */
  34747. private _clearAnimationLocks;
  34748. /**
  34749. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34750. */
  34751. private _applyUserInteraction;
  34752. /**
  34753. * Stops and removes all animations that have been applied to the camera
  34754. */
  34755. stopAllAnimations(): void;
  34756. /**
  34757. * Gets a value indicating if the user is moving the camera
  34758. */
  34759. readonly isUserIsMoving: boolean;
  34760. /**
  34761. * The camera can move all the way towards the mesh.
  34762. */
  34763. static IgnoreBoundsSizeMode: number;
  34764. /**
  34765. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34766. */
  34767. static FitFrustumSidesMode: number;
  34768. }
  34769. }
  34770. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34771. import { Nullable } from "babylonjs/types";
  34772. import { Camera } from "babylonjs/Cameras/camera";
  34773. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34774. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34775. /**
  34776. * Base class for Camera Pointer Inputs.
  34777. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34778. * for example usage.
  34779. */
  34780. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34781. /**
  34782. * Defines the camera the input is attached to.
  34783. */
  34784. abstract camera: Camera;
  34785. /**
  34786. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34787. */
  34788. protected _altKey: boolean;
  34789. protected _ctrlKey: boolean;
  34790. protected _metaKey: boolean;
  34791. protected _shiftKey: boolean;
  34792. /**
  34793. * Which mouse buttons were pressed at time of last mouse event.
  34794. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34795. */
  34796. protected _buttonsPressed: number;
  34797. /**
  34798. * Defines the buttons associated with the input to handle camera move.
  34799. */
  34800. buttons: number[];
  34801. /**
  34802. * Attach the input controls to a specific dom element to get the input from.
  34803. * @param element Defines the element the controls should be listened from
  34804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34805. */
  34806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34807. /**
  34808. * Detach the current controls from the specified dom element.
  34809. * @param element Defines the element to stop listening the inputs from
  34810. */
  34811. detachControl(element: Nullable<HTMLElement>): void;
  34812. /**
  34813. * Gets the class name of the current input.
  34814. * @returns the class name
  34815. */
  34816. getClassName(): string;
  34817. /**
  34818. * Get the friendly name associated with the input class.
  34819. * @returns the input friendly name
  34820. */
  34821. getSimpleName(): string;
  34822. /**
  34823. * Called on pointer POINTERDOUBLETAP event.
  34824. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34825. */
  34826. protected onDoubleTap(type: string): void;
  34827. /**
  34828. * Called on pointer POINTERMOVE event if only a single touch is active.
  34829. * Override this method to provide functionality.
  34830. */
  34831. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34832. /**
  34833. * Called on pointer POINTERMOVE event if multiple touches are active.
  34834. * Override this method to provide functionality.
  34835. */
  34836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34837. /**
  34838. * Called on JS contextmenu event.
  34839. * Override this method to provide functionality.
  34840. */
  34841. protected onContextMenu(evt: PointerEvent): void;
  34842. /**
  34843. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34844. * press.
  34845. * Override this method to provide functionality.
  34846. */
  34847. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34848. /**
  34849. * Called each time a new POINTERUP event occurs. Ie, for each button
  34850. * release.
  34851. * Override this method to provide functionality.
  34852. */
  34853. protected onButtonUp(evt: PointerEvent): void;
  34854. /**
  34855. * Called when window becomes inactive.
  34856. * Override this method to provide functionality.
  34857. */
  34858. protected onLostFocus(): void;
  34859. private _pointerInput;
  34860. private _observer;
  34861. private _onLostFocus;
  34862. }
  34863. }
  34864. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34865. import { Nullable } from "babylonjs/types";
  34866. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34867. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34868. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34869. /**
  34870. * Manage the pointers inputs to control an arc rotate camera.
  34871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34872. */
  34873. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34874. /**
  34875. * Defines the camera the input is attached to.
  34876. */
  34877. camera: ArcRotateCamera;
  34878. /**
  34879. * Gets the class name of the current input.
  34880. * @returns the class name
  34881. */
  34882. getClassName(): string;
  34883. /**
  34884. * Defines the buttons associated with the input to handle camera move.
  34885. */
  34886. buttons: number[];
  34887. /**
  34888. * Defines the pointer angular sensibility along the X axis or how fast is
  34889. * the camera rotating.
  34890. */
  34891. angularSensibilityX: number;
  34892. /**
  34893. * Defines the pointer angular sensibility along the Y axis or how fast is
  34894. * the camera rotating.
  34895. */
  34896. angularSensibilityY: number;
  34897. /**
  34898. * Defines the pointer pinch precision or how fast is the camera zooming.
  34899. */
  34900. pinchPrecision: number;
  34901. /**
  34902. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34903. * from 0.
  34904. * It defines the percentage of current camera.radius to use as delta when
  34905. * pinch zoom is used.
  34906. */
  34907. pinchDeltaPercentage: number;
  34908. /**
  34909. * Defines the pointer panning sensibility or how fast is the camera moving.
  34910. */
  34911. panningSensibility: number;
  34912. /**
  34913. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34914. */
  34915. multiTouchPanning: boolean;
  34916. /**
  34917. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34918. * zoom (pinch) through multitouch.
  34919. */
  34920. multiTouchPanAndZoom: boolean;
  34921. /**
  34922. * Revers pinch action direction.
  34923. */
  34924. pinchInwards: boolean;
  34925. private _isPanClick;
  34926. private _twoFingerActivityCount;
  34927. private _isPinching;
  34928. /**
  34929. * Called on pointer POINTERMOVE event if only a single touch is active.
  34930. */
  34931. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34932. /**
  34933. * Called on pointer POINTERDOUBLETAP event.
  34934. */
  34935. protected onDoubleTap(type: string): void;
  34936. /**
  34937. * Called on pointer POINTERMOVE event if multiple touches are active.
  34938. */
  34939. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34940. /**
  34941. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34942. * press.
  34943. */
  34944. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34945. /**
  34946. * Called each time a new POINTERUP event occurs. Ie, for each button
  34947. * release.
  34948. */
  34949. protected onButtonUp(evt: PointerEvent): void;
  34950. /**
  34951. * Called when window becomes inactive.
  34952. */
  34953. protected onLostFocus(): void;
  34954. }
  34955. }
  34956. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34957. import { Nullable } from "babylonjs/types";
  34958. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34959. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34960. /**
  34961. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34963. */
  34964. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34965. /**
  34966. * Defines the camera the input is attached to.
  34967. */
  34968. camera: ArcRotateCamera;
  34969. /**
  34970. * Defines the list of key codes associated with the up action (increase alpha)
  34971. */
  34972. keysUp: number[];
  34973. /**
  34974. * Defines the list of key codes associated with the down action (decrease alpha)
  34975. */
  34976. keysDown: number[];
  34977. /**
  34978. * Defines the list of key codes associated with the left action (increase beta)
  34979. */
  34980. keysLeft: number[];
  34981. /**
  34982. * Defines the list of key codes associated with the right action (decrease beta)
  34983. */
  34984. keysRight: number[];
  34985. /**
  34986. * Defines the list of key codes associated with the reset action.
  34987. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34988. */
  34989. keysReset: number[];
  34990. /**
  34991. * Defines the panning sensibility of the inputs.
  34992. * (How fast is the camera paning)
  34993. */
  34994. panningSensibility: number;
  34995. /**
  34996. * Defines the zooming sensibility of the inputs.
  34997. * (How fast is the camera zooming)
  34998. */
  34999. zoomingSensibility: number;
  35000. /**
  35001. * Defines wether maintaining the alt key down switch the movement mode from
  35002. * orientation to zoom.
  35003. */
  35004. useAltToZoom: boolean;
  35005. /**
  35006. * Rotation speed of the camera
  35007. */
  35008. angularSpeed: number;
  35009. private _keys;
  35010. private _ctrlPressed;
  35011. private _altPressed;
  35012. private _onCanvasBlurObserver;
  35013. private _onKeyboardObserver;
  35014. private _engine;
  35015. private _scene;
  35016. /**
  35017. * Attach the input controls to a specific dom element to get the input from.
  35018. * @param element Defines the element the controls should be listened from
  35019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35020. */
  35021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35022. /**
  35023. * Detach the current controls from the specified dom element.
  35024. * @param element Defines the element to stop listening the inputs from
  35025. */
  35026. detachControl(element: Nullable<HTMLElement>): void;
  35027. /**
  35028. * Update the current camera state depending on the inputs that have been used this frame.
  35029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35030. */
  35031. checkInputs(): void;
  35032. /**
  35033. * Gets the class name of the current intput.
  35034. * @returns the class name
  35035. */
  35036. getClassName(): string;
  35037. /**
  35038. * Get the friendly name associated with the input class.
  35039. * @returns the input friendly name
  35040. */
  35041. getSimpleName(): string;
  35042. }
  35043. }
  35044. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35045. import { Nullable } from "babylonjs/types";
  35046. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35047. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35048. /**
  35049. * Manage the mouse wheel inputs to control an arc rotate camera.
  35050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35051. */
  35052. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35053. /**
  35054. * Defines the camera the input is attached to.
  35055. */
  35056. camera: ArcRotateCamera;
  35057. /**
  35058. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35059. */
  35060. wheelPrecision: number;
  35061. /**
  35062. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35063. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35064. */
  35065. wheelDeltaPercentage: number;
  35066. private _wheel;
  35067. private _observer;
  35068. /**
  35069. * Attach the input controls to a specific dom element to get the input from.
  35070. * @param element Defines the element the controls should be listened from
  35071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35072. */
  35073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35074. /**
  35075. * Detach the current controls from the specified dom element.
  35076. * @param element Defines the element to stop listening the inputs from
  35077. */
  35078. detachControl(element: Nullable<HTMLElement>): void;
  35079. /**
  35080. * Gets the class name of the current intput.
  35081. * @returns the class name
  35082. */
  35083. getClassName(): string;
  35084. /**
  35085. * Get the friendly name associated with the input class.
  35086. * @returns the input friendly name
  35087. */
  35088. getSimpleName(): string;
  35089. }
  35090. }
  35091. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35092. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35093. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35094. /**
  35095. * Default Inputs manager for the ArcRotateCamera.
  35096. * It groups all the default supported inputs for ease of use.
  35097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35098. */
  35099. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35100. /**
  35101. * Instantiates a new ArcRotateCameraInputsManager.
  35102. * @param camera Defines the camera the inputs belong to
  35103. */
  35104. constructor(camera: ArcRotateCamera);
  35105. /**
  35106. * Add mouse wheel input support to the input manager.
  35107. * @returns the current input manager
  35108. */
  35109. addMouseWheel(): ArcRotateCameraInputsManager;
  35110. /**
  35111. * Add pointers input support to the input manager.
  35112. * @returns the current input manager
  35113. */
  35114. addPointers(): ArcRotateCameraInputsManager;
  35115. /**
  35116. * Add keyboard input support to the input manager.
  35117. * @returns the current input manager
  35118. */
  35119. addKeyboard(): ArcRotateCameraInputsManager;
  35120. }
  35121. }
  35122. declare module "babylonjs/Cameras/arcRotateCamera" {
  35123. import { Observable } from "babylonjs/Misc/observable";
  35124. import { Nullable } from "babylonjs/types";
  35125. import { Scene } from "babylonjs/scene";
  35126. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35128. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35129. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35130. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35131. import { Camera } from "babylonjs/Cameras/camera";
  35132. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35133. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35134. import { Collider } from "babylonjs/Collisions/collider";
  35135. /**
  35136. * This represents an orbital type of camera.
  35137. *
  35138. * 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.
  35139. * 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.
  35140. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35141. */
  35142. export class ArcRotateCamera extends TargetCamera {
  35143. /**
  35144. * Defines the rotation angle of the camera along the longitudinal axis.
  35145. */
  35146. alpha: number;
  35147. /**
  35148. * Defines the rotation angle of the camera along the latitudinal axis.
  35149. */
  35150. beta: number;
  35151. /**
  35152. * Defines the radius of the camera from it s target point.
  35153. */
  35154. radius: number;
  35155. protected _target: Vector3;
  35156. protected _targetHost: Nullable<AbstractMesh>;
  35157. /**
  35158. * Defines the target point of the camera.
  35159. * The camera looks towards it form the radius distance.
  35160. */
  35161. target: Vector3;
  35162. /**
  35163. * Define the current local position of the camera in the scene
  35164. */
  35165. position: Vector3;
  35166. /**
  35167. * Current inertia value on the longitudinal axis.
  35168. * The bigger this number the longer it will take for the camera to stop.
  35169. */
  35170. inertialAlphaOffset: number;
  35171. /**
  35172. * Current inertia value on the latitudinal axis.
  35173. * The bigger this number the longer it will take for the camera to stop.
  35174. */
  35175. inertialBetaOffset: number;
  35176. /**
  35177. * Current inertia value on the radius axis.
  35178. * The bigger this number the longer it will take for the camera to stop.
  35179. */
  35180. inertialRadiusOffset: number;
  35181. /**
  35182. * Minimum allowed angle on the longitudinal axis.
  35183. * This can help limiting how the Camera is able to move in the scene.
  35184. */
  35185. lowerAlphaLimit: Nullable<number>;
  35186. /**
  35187. * Maximum allowed angle on the longitudinal axis.
  35188. * This can help limiting how the Camera is able to move in the scene.
  35189. */
  35190. upperAlphaLimit: Nullable<number>;
  35191. /**
  35192. * Minimum allowed angle on the latitudinal axis.
  35193. * This can help limiting how the Camera is able to move in the scene.
  35194. */
  35195. lowerBetaLimit: number;
  35196. /**
  35197. * Maximum allowed angle on the latitudinal axis.
  35198. * This can help limiting how the Camera is able to move in the scene.
  35199. */
  35200. upperBetaLimit: number;
  35201. /**
  35202. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35203. * This can help limiting how the Camera is able to move in the scene.
  35204. */
  35205. lowerRadiusLimit: Nullable<number>;
  35206. /**
  35207. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35208. * This can help limiting how the Camera is able to move in the scene.
  35209. */
  35210. upperRadiusLimit: Nullable<number>;
  35211. /**
  35212. * Defines the current inertia value used during panning of the camera along the X axis.
  35213. */
  35214. inertialPanningX: number;
  35215. /**
  35216. * Defines the current inertia value used during panning of the camera along the Y axis.
  35217. */
  35218. inertialPanningY: number;
  35219. /**
  35220. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35221. * Basically if your fingers moves away from more than this distance you will be considered
  35222. * in pinch mode.
  35223. */
  35224. pinchToPanMaxDistance: number;
  35225. /**
  35226. * Defines the maximum distance the camera can pan.
  35227. * This could help keeping the cammera always in your scene.
  35228. */
  35229. panningDistanceLimit: Nullable<number>;
  35230. /**
  35231. * Defines the target of the camera before paning.
  35232. */
  35233. panningOriginTarget: Vector3;
  35234. /**
  35235. * Defines the value of the inertia used during panning.
  35236. * 0 would mean stop inertia and one would mean no decelleration at all.
  35237. */
  35238. panningInertia: number;
  35239. /**
  35240. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35241. */
  35242. angularSensibilityX: number;
  35243. /**
  35244. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35245. */
  35246. angularSensibilityY: number;
  35247. /**
  35248. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35249. */
  35250. pinchPrecision: number;
  35251. /**
  35252. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35253. * It will be used instead of pinchDeltaPrecision if different from 0.
  35254. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35255. */
  35256. pinchDeltaPercentage: number;
  35257. /**
  35258. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35259. */
  35260. panningSensibility: number;
  35261. /**
  35262. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35263. */
  35264. keysUp: number[];
  35265. /**
  35266. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35267. */
  35268. keysDown: number[];
  35269. /**
  35270. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35271. */
  35272. keysLeft: number[];
  35273. /**
  35274. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35275. */
  35276. keysRight: number[];
  35277. /**
  35278. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35279. */
  35280. wheelPrecision: number;
  35281. /**
  35282. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35283. * It will be used instead of pinchDeltaPrecision if different from 0.
  35284. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35285. */
  35286. wheelDeltaPercentage: number;
  35287. /**
  35288. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35289. */
  35290. zoomOnFactor: number;
  35291. /**
  35292. * Defines a screen offset for the camera position.
  35293. */
  35294. targetScreenOffset: Vector2;
  35295. /**
  35296. * Allows the camera to be completely reversed.
  35297. * If false the camera can not arrive upside down.
  35298. */
  35299. allowUpsideDown: boolean;
  35300. /**
  35301. * Define if double tap/click is used to restore the previously saved state of the camera.
  35302. */
  35303. useInputToRestoreState: boolean;
  35304. /** @hidden */
  35305. _viewMatrix: Matrix;
  35306. /** @hidden */
  35307. _useCtrlForPanning: boolean;
  35308. /** @hidden */
  35309. _panningMouseButton: number;
  35310. /**
  35311. * Defines the input associated to the camera.
  35312. */
  35313. inputs: ArcRotateCameraInputsManager;
  35314. /** @hidden */
  35315. _reset: () => void;
  35316. /**
  35317. * Defines the allowed panning axis.
  35318. */
  35319. panningAxis: Vector3;
  35320. protected _localDirection: Vector3;
  35321. protected _transformedDirection: Vector3;
  35322. private _bouncingBehavior;
  35323. /**
  35324. * Gets the bouncing behavior of the camera if it has been enabled.
  35325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35326. */
  35327. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35328. /**
  35329. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35331. */
  35332. useBouncingBehavior: boolean;
  35333. private _framingBehavior;
  35334. /**
  35335. * Gets the framing behavior of the camera if it has been enabled.
  35336. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35337. */
  35338. readonly framingBehavior: Nullable<FramingBehavior>;
  35339. /**
  35340. * Defines if the framing behavior of the camera is enabled on the camera.
  35341. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35342. */
  35343. useFramingBehavior: boolean;
  35344. private _autoRotationBehavior;
  35345. /**
  35346. * Gets the auto rotation behavior of the camera if it has been enabled.
  35347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35348. */
  35349. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35350. /**
  35351. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35353. */
  35354. useAutoRotationBehavior: boolean;
  35355. /**
  35356. * Observable triggered when the mesh target has been changed on the camera.
  35357. */
  35358. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35359. /**
  35360. * Event raised when the camera is colliding with a mesh.
  35361. */
  35362. onCollide: (collidedMesh: AbstractMesh) => void;
  35363. /**
  35364. * Defines whether the camera should check collision with the objects oh the scene.
  35365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35366. */
  35367. checkCollisions: boolean;
  35368. /**
  35369. * Defines the collision radius of the camera.
  35370. * This simulates a sphere around the camera.
  35371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35372. */
  35373. collisionRadius: Vector3;
  35374. protected _collider: Collider;
  35375. protected _previousPosition: Vector3;
  35376. protected _collisionVelocity: Vector3;
  35377. protected _newPosition: Vector3;
  35378. protected _previousAlpha: number;
  35379. protected _previousBeta: number;
  35380. protected _previousRadius: number;
  35381. protected _collisionTriggered: boolean;
  35382. protected _targetBoundingCenter: Nullable<Vector3>;
  35383. private _computationVector;
  35384. private _tempAxisVector;
  35385. private _tempAxisRotationMatrix;
  35386. /**
  35387. * Instantiates a new ArcRotateCamera in a given scene
  35388. * @param name Defines the name of the camera
  35389. * @param alpha Defines the camera rotation along the logitudinal axis
  35390. * @param beta Defines the camera rotation along the latitudinal axis
  35391. * @param radius Defines the camera distance from its target
  35392. * @param target Defines the camera target
  35393. * @param scene Defines the scene the camera belongs to
  35394. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35395. */
  35396. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35397. /** @hidden */
  35398. _initCache(): void;
  35399. /** @hidden */
  35400. _updateCache(ignoreParentClass?: boolean): void;
  35401. protected _getTargetPosition(): Vector3;
  35402. private _storedAlpha;
  35403. private _storedBeta;
  35404. private _storedRadius;
  35405. private _storedTarget;
  35406. /**
  35407. * Stores the current state of the camera (alpha, beta, radius and target)
  35408. * @returns the camera itself
  35409. */
  35410. storeState(): Camera;
  35411. /**
  35412. * @hidden
  35413. * Restored camera state. You must call storeState() first
  35414. */
  35415. _restoreStateValues(): boolean;
  35416. /** @hidden */
  35417. _isSynchronizedViewMatrix(): boolean;
  35418. /**
  35419. * Attached controls to the current camera.
  35420. * @param element Defines the element the controls should be listened from
  35421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35422. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35423. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35424. */
  35425. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35426. /**
  35427. * Detach the current controls from the camera.
  35428. * The camera will stop reacting to inputs.
  35429. * @param element Defines the element to stop listening the inputs from
  35430. */
  35431. detachControl(element: HTMLElement): void;
  35432. /** @hidden */
  35433. _checkInputs(): void;
  35434. protected _checkLimits(): void;
  35435. /**
  35436. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35437. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35438. */
  35439. rebuildAnglesAndRadius(updateView?: boolean): void;
  35440. /**
  35441. * Use a position to define the current camera related information like aplha, beta and radius
  35442. * @param position Defines the position to set the camera at
  35443. */
  35444. setPosition(position: Vector3): void;
  35445. /**
  35446. * Defines the target the camera should look at.
  35447. * This will automatically adapt alpha beta and radius to fit within the new target.
  35448. * @param target Defines the new target as a Vector or a mesh
  35449. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35450. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35451. */
  35452. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35453. /** @hidden */
  35454. _getViewMatrix(): Matrix;
  35455. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35456. /**
  35457. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35458. * @param meshes Defines the mesh to zoom on
  35459. * @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)
  35460. */
  35461. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35462. /**
  35463. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35464. * The target will be changed but the radius
  35465. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35466. * @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)
  35467. */
  35468. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35469. min: Vector3;
  35470. max: Vector3;
  35471. distance: number;
  35472. }, doNotUpdateMaxZ?: boolean): void;
  35473. /**
  35474. * @override
  35475. * Override Camera.createRigCamera
  35476. */
  35477. createRigCamera(name: string, cameraIndex: number): Camera;
  35478. /**
  35479. * @hidden
  35480. * @override
  35481. * Override Camera._updateRigCameras
  35482. */
  35483. _updateRigCameras(): void;
  35484. /**
  35485. * Destroy the camera and release the current resources hold by it.
  35486. */
  35487. dispose(): void;
  35488. /**
  35489. * Gets the current object class name.
  35490. * @return the class name
  35491. */
  35492. getClassName(): string;
  35493. }
  35494. }
  35495. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35496. import { Behavior } from "babylonjs/Behaviors/behavior";
  35497. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35498. /**
  35499. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35500. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35501. */
  35502. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35503. /**
  35504. * Gets the name of the behavior.
  35505. */
  35506. readonly name: string;
  35507. private _zoomStopsAnimation;
  35508. private _idleRotationSpeed;
  35509. private _idleRotationWaitTime;
  35510. private _idleRotationSpinupTime;
  35511. /**
  35512. * Sets the flag that indicates if user zooming should stop animation.
  35513. */
  35514. /**
  35515. * Gets the flag that indicates if user zooming should stop animation.
  35516. */
  35517. zoomStopsAnimation: boolean;
  35518. /**
  35519. * Sets the default speed at which the camera rotates around the model.
  35520. */
  35521. /**
  35522. * Gets the default speed at which the camera rotates around the model.
  35523. */
  35524. idleRotationSpeed: number;
  35525. /**
  35526. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35527. */
  35528. /**
  35529. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35530. */
  35531. idleRotationWaitTime: number;
  35532. /**
  35533. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35534. */
  35535. /**
  35536. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35537. */
  35538. idleRotationSpinupTime: number;
  35539. /**
  35540. * Gets a value indicating if the camera is currently rotating because of this behavior
  35541. */
  35542. readonly rotationInProgress: boolean;
  35543. private _onPrePointerObservableObserver;
  35544. private _onAfterCheckInputsObserver;
  35545. private _attachedCamera;
  35546. private _isPointerDown;
  35547. private _lastFrameTime;
  35548. private _lastInteractionTime;
  35549. private _cameraRotationSpeed;
  35550. /**
  35551. * Initializes the behavior.
  35552. */
  35553. init(): void;
  35554. /**
  35555. * Attaches the behavior to its arc rotate camera.
  35556. * @param camera Defines the camera to attach the behavior to
  35557. */
  35558. attach(camera: ArcRotateCamera): void;
  35559. /**
  35560. * Detaches the behavior from its current arc rotate camera.
  35561. */
  35562. detach(): void;
  35563. /**
  35564. * Returns true if user is scrolling.
  35565. * @return true if user is scrolling.
  35566. */
  35567. private _userIsZooming;
  35568. private _lastFrameRadius;
  35569. private _shouldAnimationStopForInteraction;
  35570. /**
  35571. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35572. */
  35573. private _applyUserInteraction;
  35574. private _userIsMoving;
  35575. }
  35576. }
  35577. declare module "babylonjs/Behaviors/Cameras/index" {
  35578. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35579. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35580. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35581. }
  35582. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35583. import { Mesh } from "babylonjs/Meshes/mesh";
  35584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35585. import { Behavior } from "babylonjs/Behaviors/behavior";
  35586. /**
  35587. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35588. */
  35589. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35590. private ui;
  35591. /**
  35592. * The name of the behavior
  35593. */
  35594. name: string;
  35595. /**
  35596. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35597. */
  35598. distanceAwayFromFace: number;
  35599. /**
  35600. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35601. */
  35602. distanceAwayFromBottomOfFace: number;
  35603. private _faceVectors;
  35604. private _target;
  35605. private _scene;
  35606. private _onRenderObserver;
  35607. private _tmpMatrix;
  35608. private _tmpVector;
  35609. /**
  35610. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35611. * @param ui The transform node that should be attched to the mesh
  35612. */
  35613. constructor(ui: TransformNode);
  35614. /**
  35615. * Initializes the behavior
  35616. */
  35617. init(): void;
  35618. private _closestFace;
  35619. private _zeroVector;
  35620. private _lookAtTmpMatrix;
  35621. private _lookAtToRef;
  35622. /**
  35623. * Attaches the AttachToBoxBehavior to the passed in mesh
  35624. * @param target The mesh that the specified node will be attached to
  35625. */
  35626. attach(target: Mesh): void;
  35627. /**
  35628. * Detaches the behavior from the mesh
  35629. */
  35630. detach(): void;
  35631. }
  35632. }
  35633. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35634. import { Behavior } from "babylonjs/Behaviors/behavior";
  35635. import { Mesh } from "babylonjs/Meshes/mesh";
  35636. /**
  35637. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35638. */
  35639. export class FadeInOutBehavior implements Behavior<Mesh> {
  35640. /**
  35641. * Time in milliseconds to delay before fading in (Default: 0)
  35642. */
  35643. delay: number;
  35644. /**
  35645. * Time in milliseconds for the mesh to fade in (Default: 300)
  35646. */
  35647. fadeInTime: number;
  35648. private _millisecondsPerFrame;
  35649. private _hovered;
  35650. private _hoverValue;
  35651. private _ownerNode;
  35652. /**
  35653. * Instatiates the FadeInOutBehavior
  35654. */
  35655. constructor();
  35656. /**
  35657. * The name of the behavior
  35658. */
  35659. readonly name: string;
  35660. /**
  35661. * Initializes the behavior
  35662. */
  35663. init(): void;
  35664. /**
  35665. * Attaches the fade behavior on the passed in mesh
  35666. * @param ownerNode The mesh that will be faded in/out once attached
  35667. */
  35668. attach(ownerNode: Mesh): void;
  35669. /**
  35670. * Detaches the behavior from the mesh
  35671. */
  35672. detach(): void;
  35673. /**
  35674. * Triggers the mesh to begin fading in or out
  35675. * @param value if the object should fade in or out (true to fade in)
  35676. */
  35677. fadeIn(value: boolean): void;
  35678. private _update;
  35679. private _setAllVisibility;
  35680. }
  35681. }
  35682. declare module "babylonjs/Misc/pivotTools" {
  35683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35684. /**
  35685. * Class containing a set of static utilities functions for managing Pivots
  35686. * @hidden
  35687. */
  35688. export class PivotTools {
  35689. private static _PivotCached;
  35690. private static _OldPivotPoint;
  35691. private static _PivotTranslation;
  35692. private static _PivotTmpVector;
  35693. /** @hidden */
  35694. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35695. /** @hidden */
  35696. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35697. }
  35698. }
  35699. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35700. import { Scene } from "babylonjs/scene";
  35701. import { Vector4, Plane } from "babylonjs/Maths/math";
  35702. import { Mesh } from "babylonjs/Meshes/mesh";
  35703. /**
  35704. * Class containing static functions to help procedurally build meshes
  35705. */
  35706. export class PlaneBuilder {
  35707. /**
  35708. * Creates a plane mesh
  35709. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35710. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35711. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35713. * * If you create a double-sided mesh, you can choose what parts of 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
  35714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35715. * @param name defines the name of the mesh
  35716. * @param options defines the options used to create the mesh
  35717. * @param scene defines the hosting scene
  35718. * @returns the plane mesh
  35719. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35720. */
  35721. static CreatePlane(name: string, options: {
  35722. size?: number;
  35723. width?: number;
  35724. height?: number;
  35725. sideOrientation?: number;
  35726. frontUVs?: Vector4;
  35727. backUVs?: Vector4;
  35728. updatable?: boolean;
  35729. sourcePlane?: Plane;
  35730. }, scene: Scene): Mesh;
  35731. }
  35732. }
  35733. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35734. import { Behavior } from "babylonjs/Behaviors/behavior";
  35735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35736. import { Observable } from "babylonjs/Misc/observable";
  35737. import { Vector3 } from "babylonjs/Maths/math";
  35738. import { Ray } from "babylonjs/Culling/ray";
  35739. import "babylonjs/Meshes/Builders/planeBuilder";
  35740. /**
  35741. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35742. */
  35743. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35744. private static _AnyMouseID;
  35745. private _attachedNode;
  35746. private _dragPlane;
  35747. private _scene;
  35748. private _pointerObserver;
  35749. private _beforeRenderObserver;
  35750. private static _planeScene;
  35751. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35752. /**
  35753. * 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)
  35754. */
  35755. maxDragAngle: number;
  35756. /**
  35757. * @hidden
  35758. */
  35759. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35760. /**
  35761. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35762. */
  35763. currentDraggingPointerID: number;
  35764. /**
  35765. * The last position where the pointer hit the drag plane in world space
  35766. */
  35767. lastDragPosition: Vector3;
  35768. /**
  35769. * If the behavior is currently in a dragging state
  35770. */
  35771. dragging: boolean;
  35772. /**
  35773. * 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)
  35774. */
  35775. dragDeltaRatio: number;
  35776. /**
  35777. * If the drag plane orientation should be updated during the dragging (Default: true)
  35778. */
  35779. updateDragPlane: boolean;
  35780. private _debugMode;
  35781. private _moving;
  35782. /**
  35783. * Fires each time the attached mesh is dragged with the pointer
  35784. * * delta between last drag position and current drag position in world space
  35785. * * dragDistance along the drag axis
  35786. * * dragPlaneNormal normal of the current drag plane used during the drag
  35787. * * dragPlanePoint in world space where the drag intersects the drag plane
  35788. */
  35789. onDragObservable: Observable<{
  35790. delta: Vector3;
  35791. dragPlanePoint: Vector3;
  35792. dragPlaneNormal: Vector3;
  35793. dragDistance: number;
  35794. pointerId: number;
  35795. }>;
  35796. /**
  35797. * Fires each time a drag begins (eg. mouse down on mesh)
  35798. */
  35799. onDragStartObservable: Observable<{
  35800. dragPlanePoint: Vector3;
  35801. pointerId: number;
  35802. }>;
  35803. /**
  35804. * Fires each time a drag ends (eg. mouse release after drag)
  35805. */
  35806. onDragEndObservable: Observable<{
  35807. dragPlanePoint: Vector3;
  35808. pointerId: number;
  35809. }>;
  35810. /**
  35811. * If the attached mesh should be moved when dragged
  35812. */
  35813. moveAttached: boolean;
  35814. /**
  35815. * If the drag behavior will react to drag events (Default: true)
  35816. */
  35817. enabled: boolean;
  35818. /**
  35819. * If camera controls should be detached during the drag
  35820. */
  35821. detachCameraControls: boolean;
  35822. /**
  35823. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35824. */
  35825. useObjectOrienationForDragging: boolean;
  35826. private _options;
  35827. /**
  35828. * Creates a pointer drag behavior that can be attached to a mesh
  35829. * @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)
  35830. */
  35831. constructor(options?: {
  35832. dragAxis?: Vector3;
  35833. dragPlaneNormal?: Vector3;
  35834. });
  35835. /**
  35836. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35837. */
  35838. validateDrag: (targetPosition: Vector3) => boolean;
  35839. /**
  35840. * The name of the behavior
  35841. */
  35842. readonly name: string;
  35843. /**
  35844. * Initializes the behavior
  35845. */
  35846. init(): void;
  35847. private _tmpVector;
  35848. private _alternatePickedPoint;
  35849. private _worldDragAxis;
  35850. private _targetPosition;
  35851. private _attachedElement;
  35852. /**
  35853. * Attaches the drag behavior the passed in mesh
  35854. * @param ownerNode The mesh that will be dragged around once attached
  35855. */
  35856. attach(ownerNode: AbstractMesh): void;
  35857. /**
  35858. * Force relase the drag action by code.
  35859. */
  35860. releaseDrag(): void;
  35861. private _startDragRay;
  35862. private _lastPointerRay;
  35863. /**
  35864. * Simulates the start of a pointer drag event on the behavior
  35865. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35866. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35867. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35868. */
  35869. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35870. private _startDrag;
  35871. private _dragDelta;
  35872. private _moveDrag;
  35873. private _pickWithRayOnDragPlane;
  35874. private _pointA;
  35875. private _pointB;
  35876. private _pointC;
  35877. private _lineA;
  35878. private _lineB;
  35879. private _localAxis;
  35880. private _lookAt;
  35881. private _updateDragPlanePosition;
  35882. /**
  35883. * Detaches the behavior from the mesh
  35884. */
  35885. detach(): void;
  35886. }
  35887. }
  35888. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35889. import { Mesh } from "babylonjs/Meshes/mesh";
  35890. import { Behavior } from "babylonjs/Behaviors/behavior";
  35891. /**
  35892. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35893. */
  35894. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35895. private _dragBehaviorA;
  35896. private _dragBehaviorB;
  35897. private _startDistance;
  35898. private _initialScale;
  35899. private _targetScale;
  35900. private _ownerNode;
  35901. private _sceneRenderObserver;
  35902. /**
  35903. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35904. */
  35905. constructor();
  35906. /**
  35907. * The name of the behavior
  35908. */
  35909. readonly name: string;
  35910. /**
  35911. * Initializes the behavior
  35912. */
  35913. init(): void;
  35914. private _getCurrentDistance;
  35915. /**
  35916. * Attaches the scale behavior the passed in mesh
  35917. * @param ownerNode The mesh that will be scaled around once attached
  35918. */
  35919. attach(ownerNode: Mesh): void;
  35920. /**
  35921. * Detaches the behavior from the mesh
  35922. */
  35923. detach(): void;
  35924. }
  35925. }
  35926. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35927. import { Behavior } from "babylonjs/Behaviors/behavior";
  35928. import { Mesh } from "babylonjs/Meshes/mesh";
  35929. import { Observable } from "babylonjs/Misc/observable";
  35930. /**
  35931. * 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
  35932. */
  35933. export class SixDofDragBehavior implements Behavior<Mesh> {
  35934. private static _virtualScene;
  35935. private _ownerNode;
  35936. private _sceneRenderObserver;
  35937. private _scene;
  35938. private _targetPosition;
  35939. private _virtualOriginMesh;
  35940. private _virtualDragMesh;
  35941. private _pointerObserver;
  35942. private _moving;
  35943. private _startingOrientation;
  35944. /**
  35945. * 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)
  35946. */
  35947. private zDragFactor;
  35948. /**
  35949. * If the object should rotate to face the drag origin
  35950. */
  35951. rotateDraggedObject: boolean;
  35952. /**
  35953. * If the behavior is currently in a dragging state
  35954. */
  35955. dragging: boolean;
  35956. /**
  35957. * 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)
  35958. */
  35959. dragDeltaRatio: number;
  35960. /**
  35961. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35962. */
  35963. currentDraggingPointerID: number;
  35964. /**
  35965. * If camera controls should be detached during the drag
  35966. */
  35967. detachCameraControls: boolean;
  35968. /**
  35969. * Fires each time a drag starts
  35970. */
  35971. onDragStartObservable: Observable<{}>;
  35972. /**
  35973. * Fires each time a drag ends (eg. mouse release after drag)
  35974. */
  35975. onDragEndObservable: Observable<{}>;
  35976. /**
  35977. * 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
  35978. */
  35979. constructor();
  35980. /**
  35981. * The name of the behavior
  35982. */
  35983. readonly name: string;
  35984. /**
  35985. * Initializes the behavior
  35986. */
  35987. init(): void;
  35988. /**
  35989. * Attaches the scale behavior the passed in mesh
  35990. * @param ownerNode The mesh that will be scaled around once attached
  35991. */
  35992. attach(ownerNode: Mesh): void;
  35993. /**
  35994. * Detaches the behavior from the mesh
  35995. */
  35996. detach(): void;
  35997. }
  35998. }
  35999. declare module "babylonjs/Behaviors/Meshes/index" {
  36000. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36001. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36002. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36003. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36004. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36005. }
  36006. declare module "babylonjs/Behaviors/index" {
  36007. export * from "babylonjs/Behaviors/behavior";
  36008. export * from "babylonjs/Behaviors/Cameras/index";
  36009. export * from "babylonjs/Behaviors/Meshes/index";
  36010. }
  36011. declare module "babylonjs/Bones/boneIKController" {
  36012. import { Bone } from "babylonjs/Bones/bone";
  36013. import { Vector3 } from "babylonjs/Maths/math";
  36014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36015. import { Nullable } from "babylonjs/types";
  36016. /**
  36017. * Class used to apply inverse kinematics to bones
  36018. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36019. */
  36020. export class BoneIKController {
  36021. private static _tmpVecs;
  36022. private static _tmpQuat;
  36023. private static _tmpMats;
  36024. /**
  36025. * Gets or sets the target mesh
  36026. */
  36027. targetMesh: AbstractMesh;
  36028. /** Gets or sets the mesh used as pole */
  36029. poleTargetMesh: AbstractMesh;
  36030. /**
  36031. * Gets or sets the bone used as pole
  36032. */
  36033. poleTargetBone: Nullable<Bone>;
  36034. /**
  36035. * Gets or sets the target position
  36036. */
  36037. targetPosition: Vector3;
  36038. /**
  36039. * Gets or sets the pole target position
  36040. */
  36041. poleTargetPosition: Vector3;
  36042. /**
  36043. * Gets or sets the pole target local offset
  36044. */
  36045. poleTargetLocalOffset: Vector3;
  36046. /**
  36047. * Gets or sets the pole angle
  36048. */
  36049. poleAngle: number;
  36050. /**
  36051. * Gets or sets the mesh associated with the controller
  36052. */
  36053. mesh: AbstractMesh;
  36054. /**
  36055. * 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)
  36056. */
  36057. slerpAmount: number;
  36058. private _bone1Quat;
  36059. private _bone1Mat;
  36060. private _bone2Ang;
  36061. private _bone1;
  36062. private _bone2;
  36063. private _bone1Length;
  36064. private _bone2Length;
  36065. private _maxAngle;
  36066. private _maxReach;
  36067. private _rightHandedSystem;
  36068. private _bendAxis;
  36069. private _slerping;
  36070. private _adjustRoll;
  36071. /**
  36072. * Gets or sets maximum allowed angle
  36073. */
  36074. maxAngle: number;
  36075. /**
  36076. * Creates a new BoneIKController
  36077. * @param mesh defines the mesh to control
  36078. * @param bone defines the bone to control
  36079. * @param options defines options to set up the controller
  36080. */
  36081. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36082. targetMesh?: AbstractMesh;
  36083. poleTargetMesh?: AbstractMesh;
  36084. poleTargetBone?: Bone;
  36085. poleTargetLocalOffset?: Vector3;
  36086. poleAngle?: number;
  36087. bendAxis?: Vector3;
  36088. maxAngle?: number;
  36089. slerpAmount?: number;
  36090. });
  36091. private _setMaxAngle;
  36092. /**
  36093. * Force the controller to update the bones
  36094. */
  36095. update(): void;
  36096. }
  36097. }
  36098. declare module "babylonjs/Bones/boneLookController" {
  36099. import { Vector3, Space } from "babylonjs/Maths/math";
  36100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36101. import { Bone } from "babylonjs/Bones/bone";
  36102. /**
  36103. * Class used to make a bone look toward a point in space
  36104. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36105. */
  36106. export class BoneLookController {
  36107. private static _tmpVecs;
  36108. private static _tmpQuat;
  36109. private static _tmpMats;
  36110. /**
  36111. * The target Vector3 that the bone will look at
  36112. */
  36113. target: Vector3;
  36114. /**
  36115. * The mesh that the bone is attached to
  36116. */
  36117. mesh: AbstractMesh;
  36118. /**
  36119. * The bone that will be looking to the target
  36120. */
  36121. bone: Bone;
  36122. /**
  36123. * The up axis of the coordinate system that is used when the bone is rotated
  36124. */
  36125. upAxis: Vector3;
  36126. /**
  36127. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36128. */
  36129. upAxisSpace: Space;
  36130. /**
  36131. * Used to make an adjustment to the yaw of the bone
  36132. */
  36133. adjustYaw: number;
  36134. /**
  36135. * Used to make an adjustment to the pitch of the bone
  36136. */
  36137. adjustPitch: number;
  36138. /**
  36139. * Used to make an adjustment to the roll of the bone
  36140. */
  36141. adjustRoll: number;
  36142. /**
  36143. * 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)
  36144. */
  36145. slerpAmount: number;
  36146. private _minYaw;
  36147. private _maxYaw;
  36148. private _minPitch;
  36149. private _maxPitch;
  36150. private _minYawSin;
  36151. private _minYawCos;
  36152. private _maxYawSin;
  36153. private _maxYawCos;
  36154. private _midYawConstraint;
  36155. private _minPitchTan;
  36156. private _maxPitchTan;
  36157. private _boneQuat;
  36158. private _slerping;
  36159. private _transformYawPitch;
  36160. private _transformYawPitchInv;
  36161. private _firstFrameSkipped;
  36162. private _yawRange;
  36163. private _fowardAxis;
  36164. /**
  36165. * Gets or sets the minimum yaw angle that the bone can look to
  36166. */
  36167. minYaw: number;
  36168. /**
  36169. * Gets or sets the maximum yaw angle that the bone can look to
  36170. */
  36171. maxYaw: number;
  36172. /**
  36173. * Gets or sets the minimum pitch angle that the bone can look to
  36174. */
  36175. minPitch: number;
  36176. /**
  36177. * Gets or sets the maximum pitch angle that the bone can look to
  36178. */
  36179. maxPitch: number;
  36180. /**
  36181. * Create a BoneLookController
  36182. * @param mesh the mesh that the bone belongs to
  36183. * @param bone the bone that will be looking to the target
  36184. * @param target the target Vector3 to look at
  36185. * @param options optional settings:
  36186. * * maxYaw: the maximum angle the bone will yaw to
  36187. * * minYaw: the minimum angle the bone will yaw to
  36188. * * maxPitch: the maximum angle the bone will pitch to
  36189. * * minPitch: the minimum angle the bone will yaw to
  36190. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36191. * * upAxis: the up axis of the coordinate system
  36192. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36193. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36194. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36195. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36196. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36197. * * adjustRoll: used to make an adjustment to the roll of the bone
  36198. **/
  36199. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36200. maxYaw?: number;
  36201. minYaw?: number;
  36202. maxPitch?: number;
  36203. minPitch?: number;
  36204. slerpAmount?: number;
  36205. upAxis?: Vector3;
  36206. upAxisSpace?: Space;
  36207. yawAxis?: Vector3;
  36208. pitchAxis?: Vector3;
  36209. adjustYaw?: number;
  36210. adjustPitch?: number;
  36211. adjustRoll?: number;
  36212. });
  36213. /**
  36214. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36215. */
  36216. update(): void;
  36217. private _getAngleDiff;
  36218. private _getAngleBetween;
  36219. private _isAngleBetween;
  36220. }
  36221. }
  36222. declare module "babylonjs/Bones/index" {
  36223. export * from "babylonjs/Bones/bone";
  36224. export * from "babylonjs/Bones/boneIKController";
  36225. export * from "babylonjs/Bones/boneLookController";
  36226. export * from "babylonjs/Bones/skeleton";
  36227. }
  36228. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36229. import { Nullable } from "babylonjs/types";
  36230. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36231. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36232. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36233. /**
  36234. * Manage the gamepad inputs to control an arc rotate camera.
  36235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36236. */
  36237. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36238. /**
  36239. * Defines the camera the input is attached to.
  36240. */
  36241. camera: ArcRotateCamera;
  36242. /**
  36243. * Defines the gamepad the input is gathering event from.
  36244. */
  36245. gamepad: Nullable<Gamepad>;
  36246. /**
  36247. * Defines the gamepad rotation sensiblity.
  36248. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36249. */
  36250. gamepadRotationSensibility: number;
  36251. /**
  36252. * Defines the gamepad move sensiblity.
  36253. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36254. */
  36255. gamepadMoveSensibility: number;
  36256. private _onGamepadConnectedObserver;
  36257. private _onGamepadDisconnectedObserver;
  36258. /**
  36259. * Attach the input controls to a specific dom element to get the input from.
  36260. * @param element Defines the element the controls should be listened from
  36261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36262. */
  36263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36264. /**
  36265. * Detach the current controls from the specified dom element.
  36266. * @param element Defines the element to stop listening the inputs from
  36267. */
  36268. detachControl(element: Nullable<HTMLElement>): void;
  36269. /**
  36270. * Update the current camera state depending on the inputs that have been used this frame.
  36271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36272. */
  36273. checkInputs(): void;
  36274. /**
  36275. * Gets the class name of the current intput.
  36276. * @returns the class name
  36277. */
  36278. getClassName(): string;
  36279. /**
  36280. * Get the friendly name associated with the input class.
  36281. * @returns the input friendly name
  36282. */
  36283. getSimpleName(): string;
  36284. }
  36285. }
  36286. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36287. import { Nullable } from "babylonjs/types";
  36288. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36289. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36290. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36291. interface ArcRotateCameraInputsManager {
  36292. /**
  36293. * Add orientation input support to the input manager.
  36294. * @returns the current input manager
  36295. */
  36296. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36297. }
  36298. }
  36299. /**
  36300. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36302. */
  36303. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36304. /**
  36305. * Defines the camera the input is attached to.
  36306. */
  36307. camera: ArcRotateCamera;
  36308. /**
  36309. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36310. */
  36311. alphaCorrection: number;
  36312. /**
  36313. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36314. */
  36315. gammaCorrection: number;
  36316. private _alpha;
  36317. private _gamma;
  36318. private _dirty;
  36319. private _deviceOrientationHandler;
  36320. /**
  36321. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36322. */
  36323. constructor();
  36324. /**
  36325. * Attach the input controls to a specific dom element to get the input from.
  36326. * @param element Defines the element the controls should be listened from
  36327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36328. */
  36329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36330. /** @hidden */
  36331. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36332. /**
  36333. * Update the current camera state depending on the inputs that have been used this frame.
  36334. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36335. */
  36336. checkInputs(): void;
  36337. /**
  36338. * Detach the current controls from the specified dom element.
  36339. * @param element Defines the element to stop listening the inputs from
  36340. */
  36341. detachControl(element: Nullable<HTMLElement>): void;
  36342. /**
  36343. * Gets the class name of the current intput.
  36344. * @returns the class name
  36345. */
  36346. getClassName(): string;
  36347. /**
  36348. * Get the friendly name associated with the input class.
  36349. * @returns the input friendly name
  36350. */
  36351. getSimpleName(): string;
  36352. }
  36353. }
  36354. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36355. import { Nullable } from "babylonjs/types";
  36356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36357. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36358. /**
  36359. * Listen to mouse events to control the camera.
  36360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36361. */
  36362. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36363. /**
  36364. * Defines the camera the input is attached to.
  36365. */
  36366. camera: FlyCamera;
  36367. /**
  36368. * Defines if touch is enabled. (Default is true.)
  36369. */
  36370. touchEnabled: boolean;
  36371. /**
  36372. * Defines the buttons associated with the input to handle camera rotation.
  36373. */
  36374. buttons: number[];
  36375. /**
  36376. * Assign buttons for Yaw control.
  36377. */
  36378. buttonsYaw: number[];
  36379. /**
  36380. * Assign buttons for Pitch control.
  36381. */
  36382. buttonsPitch: number[];
  36383. /**
  36384. * Assign buttons for Roll control.
  36385. */
  36386. buttonsRoll: number[];
  36387. /**
  36388. * Detect if any button is being pressed while mouse is moved.
  36389. * -1 = Mouse locked.
  36390. * 0 = Left button.
  36391. * 1 = Middle Button.
  36392. * 2 = Right Button.
  36393. */
  36394. activeButton: number;
  36395. /**
  36396. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36397. * Higher values reduce its sensitivity.
  36398. */
  36399. angularSensibility: number;
  36400. private _mousemoveCallback;
  36401. private _observer;
  36402. private _rollObserver;
  36403. private previousPosition;
  36404. private noPreventDefault;
  36405. private element;
  36406. /**
  36407. * Listen to mouse events to control the camera.
  36408. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36410. */
  36411. constructor(touchEnabled?: boolean);
  36412. /**
  36413. * Attach the mouse control to the HTML DOM element.
  36414. * @param element Defines the element that listens to the input events.
  36415. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36416. */
  36417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36418. /**
  36419. * Detach the current controls from the specified dom element.
  36420. * @param element Defines the element to stop listening the inputs from
  36421. */
  36422. detachControl(element: Nullable<HTMLElement>): void;
  36423. /**
  36424. * Gets the class name of the current input.
  36425. * @returns the class name.
  36426. */
  36427. getClassName(): string;
  36428. /**
  36429. * Get the friendly name associated with the input class.
  36430. * @returns the input's friendly name.
  36431. */
  36432. getSimpleName(): string;
  36433. private _pointerInput;
  36434. private _onMouseMove;
  36435. /**
  36436. * Rotate camera by mouse offset.
  36437. */
  36438. private rotateCamera;
  36439. }
  36440. }
  36441. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36443. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36444. /**
  36445. * Default Inputs manager for the FlyCamera.
  36446. * It groups all the default supported inputs for ease of use.
  36447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36448. */
  36449. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36450. /**
  36451. * Instantiates a new FlyCameraInputsManager.
  36452. * @param camera Defines the camera the inputs belong to.
  36453. */
  36454. constructor(camera: FlyCamera);
  36455. /**
  36456. * Add keyboard input support to the input manager.
  36457. * @returns the new FlyCameraKeyboardMoveInput().
  36458. */
  36459. addKeyboard(): FlyCameraInputsManager;
  36460. /**
  36461. * Add mouse input support to the input manager.
  36462. * @param touchEnabled Enable touch screen support.
  36463. * @returns the new FlyCameraMouseInput().
  36464. */
  36465. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36466. }
  36467. }
  36468. declare module "babylonjs/Cameras/flyCamera" {
  36469. import { Scene } from "babylonjs/scene";
  36470. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36472. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36473. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36474. /**
  36475. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36476. * such as in a 3D Space Shooter or a Flight Simulator.
  36477. */
  36478. export class FlyCamera extends TargetCamera {
  36479. /**
  36480. * Define the collision ellipsoid of the camera.
  36481. * This is helpful for simulating a camera body, like a player's body.
  36482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36483. */
  36484. ellipsoid: Vector3;
  36485. /**
  36486. * Define an offset for the position of the ellipsoid around the camera.
  36487. * This can be helpful if the camera is attached away from the player's body center,
  36488. * such as at its head.
  36489. */
  36490. ellipsoidOffset: Vector3;
  36491. /**
  36492. * Enable or disable collisions of the camera with the rest of the scene objects.
  36493. */
  36494. checkCollisions: boolean;
  36495. /**
  36496. * Enable or disable gravity on the camera.
  36497. */
  36498. applyGravity: boolean;
  36499. /**
  36500. * Define the current direction the camera is moving to.
  36501. */
  36502. cameraDirection: Vector3;
  36503. /**
  36504. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36505. * This overrides and empties cameraRotation.
  36506. */
  36507. rotationQuaternion: Quaternion;
  36508. /**
  36509. * Track Roll to maintain the wanted Rolling when looking around.
  36510. */
  36511. _trackRoll: number;
  36512. /**
  36513. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36514. */
  36515. rollCorrect: number;
  36516. /**
  36517. * Mimic a banked turn, Rolling the camera when Yawing.
  36518. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36519. */
  36520. bankedTurn: boolean;
  36521. /**
  36522. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36523. */
  36524. bankedTurnLimit: number;
  36525. /**
  36526. * Value of 0 disables the banked Roll.
  36527. * Value of 1 is equal to the Yaw angle in radians.
  36528. */
  36529. bankedTurnMultiplier: number;
  36530. /**
  36531. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36532. */
  36533. inputs: FlyCameraInputsManager;
  36534. /**
  36535. * Gets the input sensibility for mouse input.
  36536. * Higher values reduce sensitivity.
  36537. */
  36538. /**
  36539. * Sets the input sensibility for a mouse input.
  36540. * Higher values reduce sensitivity.
  36541. */
  36542. angularSensibility: number;
  36543. /**
  36544. * Get the keys for camera movement forward.
  36545. */
  36546. /**
  36547. * Set the keys for camera movement forward.
  36548. */
  36549. keysForward: number[];
  36550. /**
  36551. * Get the keys for camera movement backward.
  36552. */
  36553. keysBackward: number[];
  36554. /**
  36555. * Get the keys for camera movement up.
  36556. */
  36557. /**
  36558. * Set the keys for camera movement up.
  36559. */
  36560. keysUp: number[];
  36561. /**
  36562. * Get the keys for camera movement down.
  36563. */
  36564. /**
  36565. * Set the keys for camera movement down.
  36566. */
  36567. keysDown: number[];
  36568. /**
  36569. * Get the keys for camera movement left.
  36570. */
  36571. /**
  36572. * Set the keys for camera movement left.
  36573. */
  36574. keysLeft: number[];
  36575. /**
  36576. * Set the keys for camera movement right.
  36577. */
  36578. /**
  36579. * Set the keys for camera movement right.
  36580. */
  36581. keysRight: number[];
  36582. /**
  36583. * Event raised when the camera collides with a mesh in the scene.
  36584. */
  36585. onCollide: (collidedMesh: AbstractMesh) => void;
  36586. private _collider;
  36587. private _needMoveForGravity;
  36588. private _oldPosition;
  36589. private _diffPosition;
  36590. private _newPosition;
  36591. /** @hidden */
  36592. _localDirection: Vector3;
  36593. /** @hidden */
  36594. _transformedDirection: Vector3;
  36595. /**
  36596. * Instantiates a FlyCamera.
  36597. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36598. * such as in a 3D Space Shooter or a Flight Simulator.
  36599. * @param name Define the name of the camera in the scene.
  36600. * @param position Define the starting position of the camera in the scene.
  36601. * @param scene Define the scene the camera belongs to.
  36602. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36603. */
  36604. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36605. /**
  36606. * Attach a control to the HTML DOM element.
  36607. * @param element Defines the element that listens to the input events.
  36608. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36609. */
  36610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36611. /**
  36612. * Detach a control from the HTML DOM element.
  36613. * The camera will stop reacting to that input.
  36614. * @param element Defines the element that listens to the input events.
  36615. */
  36616. detachControl(element: HTMLElement): void;
  36617. private _collisionMask;
  36618. /**
  36619. * Get the mask that the camera ignores in collision events.
  36620. */
  36621. /**
  36622. * Set the mask that the camera ignores in collision events.
  36623. */
  36624. collisionMask: number;
  36625. /** @hidden */
  36626. _collideWithWorld(displacement: Vector3): void;
  36627. /** @hidden */
  36628. private _onCollisionPositionChange;
  36629. /** @hidden */
  36630. _checkInputs(): void;
  36631. /** @hidden */
  36632. _decideIfNeedsToMove(): boolean;
  36633. /** @hidden */
  36634. _updatePosition(): void;
  36635. /**
  36636. * Restore the Roll to its target value at the rate specified.
  36637. * @param rate - Higher means slower restoring.
  36638. * @hidden
  36639. */
  36640. restoreRoll(rate: number): void;
  36641. /**
  36642. * Destroy the camera and release the current resources held by it.
  36643. */
  36644. dispose(): void;
  36645. /**
  36646. * Get the current object class name.
  36647. * @returns the class name.
  36648. */
  36649. getClassName(): string;
  36650. }
  36651. }
  36652. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36653. import { Nullable } from "babylonjs/types";
  36654. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36655. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36656. /**
  36657. * Listen to keyboard events to control the camera.
  36658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36659. */
  36660. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36661. /**
  36662. * Defines the camera the input is attached to.
  36663. */
  36664. camera: FlyCamera;
  36665. /**
  36666. * The list of keyboard keys used to control the forward move of the camera.
  36667. */
  36668. keysForward: number[];
  36669. /**
  36670. * The list of keyboard keys used to control the backward move of the camera.
  36671. */
  36672. keysBackward: number[];
  36673. /**
  36674. * The list of keyboard keys used to control the forward move of the camera.
  36675. */
  36676. keysUp: number[];
  36677. /**
  36678. * The list of keyboard keys used to control the backward move of the camera.
  36679. */
  36680. keysDown: number[];
  36681. /**
  36682. * The list of keyboard keys used to control the right strafe move of the camera.
  36683. */
  36684. keysRight: number[];
  36685. /**
  36686. * The list of keyboard keys used to control the left strafe move of the camera.
  36687. */
  36688. keysLeft: number[];
  36689. private _keys;
  36690. private _onCanvasBlurObserver;
  36691. private _onKeyboardObserver;
  36692. private _engine;
  36693. private _scene;
  36694. /**
  36695. * Attach the input controls to a specific dom element to get the input from.
  36696. * @param element Defines the element the controls should be listened from
  36697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36698. */
  36699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36700. /**
  36701. * Detach the current controls from the specified dom element.
  36702. * @param element Defines the element to stop listening the inputs from
  36703. */
  36704. detachControl(element: Nullable<HTMLElement>): void;
  36705. /**
  36706. * Gets the class name of the current intput.
  36707. * @returns the class name
  36708. */
  36709. getClassName(): string;
  36710. /** @hidden */
  36711. _onLostFocus(e: FocusEvent): void;
  36712. /**
  36713. * Get the friendly name associated with the input class.
  36714. * @returns the input friendly name
  36715. */
  36716. getSimpleName(): string;
  36717. /**
  36718. * Update the current camera state depending on the inputs that have been used this frame.
  36719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36720. */
  36721. checkInputs(): void;
  36722. }
  36723. }
  36724. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36725. import { Nullable } from "babylonjs/types";
  36726. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36728. /**
  36729. * Manage the mouse wheel inputs to control a follow camera.
  36730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36731. */
  36732. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36733. /**
  36734. * Defines the camera the input is attached to.
  36735. */
  36736. camera: FollowCamera;
  36737. /**
  36738. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36739. */
  36740. axisControlRadius: boolean;
  36741. /**
  36742. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36743. */
  36744. axisControlHeight: boolean;
  36745. /**
  36746. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36747. */
  36748. axisControlRotation: boolean;
  36749. /**
  36750. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36751. * relation to mouseWheel events.
  36752. */
  36753. wheelPrecision: number;
  36754. /**
  36755. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36756. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36757. */
  36758. wheelDeltaPercentage: number;
  36759. private _wheel;
  36760. private _observer;
  36761. /**
  36762. * Attach the input controls to a specific dom element to get the input from.
  36763. * @param element Defines the element the controls should be listened from
  36764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36765. */
  36766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36767. /**
  36768. * Detach the current controls from the specified dom element.
  36769. * @param element Defines the element to stop listening the inputs from
  36770. */
  36771. detachControl(element: Nullable<HTMLElement>): void;
  36772. /**
  36773. * Gets the class name of the current intput.
  36774. * @returns the class name
  36775. */
  36776. getClassName(): string;
  36777. /**
  36778. * Get the friendly name associated with the input class.
  36779. * @returns the input friendly name
  36780. */
  36781. getSimpleName(): string;
  36782. }
  36783. }
  36784. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36785. import { Nullable } from "babylonjs/types";
  36786. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36787. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36788. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36789. /**
  36790. * Manage the pointers inputs to control an follow camera.
  36791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36792. */
  36793. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36794. /**
  36795. * Defines the camera the input is attached to.
  36796. */
  36797. camera: FollowCamera;
  36798. /**
  36799. * Gets the class name of the current input.
  36800. * @returns the class name
  36801. */
  36802. getClassName(): string;
  36803. /**
  36804. * Defines the pointer angular sensibility along the X axis or how fast is
  36805. * the camera rotating.
  36806. * A negative number will reverse the axis direction.
  36807. */
  36808. angularSensibilityX: number;
  36809. /**
  36810. * Defines the pointer angular sensibility along the Y axis or how fast is
  36811. * the camera rotating.
  36812. * A negative number will reverse the axis direction.
  36813. */
  36814. angularSensibilityY: number;
  36815. /**
  36816. * Defines the pointer pinch precision or how fast is the camera zooming.
  36817. * A negative number will reverse the axis direction.
  36818. */
  36819. pinchPrecision: number;
  36820. /**
  36821. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36822. * from 0.
  36823. * It defines the percentage of current camera.radius to use as delta when
  36824. * pinch zoom is used.
  36825. */
  36826. pinchDeltaPercentage: number;
  36827. /**
  36828. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36829. */
  36830. axisXControlRadius: boolean;
  36831. /**
  36832. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36833. */
  36834. axisXControlHeight: boolean;
  36835. /**
  36836. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36837. */
  36838. axisXControlRotation: boolean;
  36839. /**
  36840. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36841. */
  36842. axisYControlRadius: boolean;
  36843. /**
  36844. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36845. */
  36846. axisYControlHeight: boolean;
  36847. /**
  36848. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36849. */
  36850. axisYControlRotation: boolean;
  36851. /**
  36852. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36853. */
  36854. axisPinchControlRadius: boolean;
  36855. /**
  36856. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36857. */
  36858. axisPinchControlHeight: boolean;
  36859. /**
  36860. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36861. */
  36862. axisPinchControlRotation: boolean;
  36863. /**
  36864. * Log error messages if basic misconfiguration has occurred.
  36865. */
  36866. warningEnable: boolean;
  36867. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36868. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36869. private _warningCounter;
  36870. private _warning;
  36871. }
  36872. }
  36873. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36874. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36875. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36876. /**
  36877. * Default Inputs manager for the FollowCamera.
  36878. * It groups all the default supported inputs for ease of use.
  36879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36880. */
  36881. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36882. /**
  36883. * Instantiates a new FollowCameraInputsManager.
  36884. * @param camera Defines the camera the inputs belong to
  36885. */
  36886. constructor(camera: FollowCamera);
  36887. /**
  36888. * Add keyboard input support to the input manager.
  36889. * @returns the current input manager
  36890. */
  36891. addKeyboard(): FollowCameraInputsManager;
  36892. /**
  36893. * Add mouse wheel input support to the input manager.
  36894. * @returns the current input manager
  36895. */
  36896. addMouseWheel(): FollowCameraInputsManager;
  36897. /**
  36898. * Add pointers input support to the input manager.
  36899. * @returns the current input manager
  36900. */
  36901. addPointers(): FollowCameraInputsManager;
  36902. /**
  36903. * Add orientation input support to the input manager.
  36904. * @returns the current input manager
  36905. */
  36906. addVRDeviceOrientation(): FollowCameraInputsManager;
  36907. }
  36908. }
  36909. declare module "babylonjs/Cameras/followCamera" {
  36910. import { Nullable } from "babylonjs/types";
  36911. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36912. import { Scene } from "babylonjs/scene";
  36913. import { Vector3 } from "babylonjs/Maths/math";
  36914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36915. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36916. /**
  36917. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36918. * an arc rotate version arcFollowCamera are available.
  36919. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36920. */
  36921. export class FollowCamera extends TargetCamera {
  36922. /**
  36923. * Distance the follow camera should follow an object at
  36924. */
  36925. radius: number;
  36926. /**
  36927. * Minimum allowed distance of the camera to the axis of rotation
  36928. * (The camera can not get closer).
  36929. * This can help limiting how the Camera is able to move in the scene.
  36930. */
  36931. lowerRadiusLimit: Nullable<number>;
  36932. /**
  36933. * Maximum allowed distance of the camera to the axis of rotation
  36934. * (The camera can not get further).
  36935. * This can help limiting how the Camera is able to move in the scene.
  36936. */
  36937. upperRadiusLimit: Nullable<number>;
  36938. /**
  36939. * Define a rotation offset between the camera and the object it follows
  36940. */
  36941. rotationOffset: number;
  36942. /**
  36943. * Minimum allowed angle to camera position relative to target object.
  36944. * This can help limiting how the Camera is able to move in the scene.
  36945. */
  36946. lowerRotationOffsetLimit: Nullable<number>;
  36947. /**
  36948. * Maximum allowed angle to camera position relative to target object.
  36949. * This can help limiting how the Camera is able to move in the scene.
  36950. */
  36951. upperRotationOffsetLimit: Nullable<number>;
  36952. /**
  36953. * Define a height offset between the camera and the object it follows.
  36954. * It can help following an object from the top (like a car chaing a plane)
  36955. */
  36956. heightOffset: number;
  36957. /**
  36958. * Minimum allowed height of camera position relative to target object.
  36959. * This can help limiting how the Camera is able to move in the scene.
  36960. */
  36961. lowerHeightOffsetLimit: Nullable<number>;
  36962. /**
  36963. * Maximum allowed height of camera position relative to target object.
  36964. * This can help limiting how the Camera is able to move in the scene.
  36965. */
  36966. upperHeightOffsetLimit: Nullable<number>;
  36967. /**
  36968. * Define how fast the camera can accelerate to follow it s target.
  36969. */
  36970. cameraAcceleration: number;
  36971. /**
  36972. * Define the speed limit of the camera following an object.
  36973. */
  36974. maxCameraSpeed: number;
  36975. /**
  36976. * Define the target of the camera.
  36977. */
  36978. lockedTarget: Nullable<AbstractMesh>;
  36979. /**
  36980. * Defines the input associated with the camera.
  36981. */
  36982. inputs: FollowCameraInputsManager;
  36983. /**
  36984. * Instantiates the follow camera.
  36985. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36986. * @param name Define the name of the camera in the scene
  36987. * @param position Define the position of the camera
  36988. * @param scene Define the scene the camera belong to
  36989. * @param lockedTarget Define the target of the camera
  36990. */
  36991. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36992. private _follow;
  36993. /**
  36994. * Attached controls to the current camera.
  36995. * @param element Defines the element the controls should be listened from
  36996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36997. */
  36998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36999. /**
  37000. * Detach the current controls from the camera.
  37001. * The camera will stop reacting to inputs.
  37002. * @param element Defines the element to stop listening the inputs from
  37003. */
  37004. detachControl(element: HTMLElement): void;
  37005. /** @hidden */
  37006. _checkInputs(): void;
  37007. private _checkLimits;
  37008. /**
  37009. * Gets the camera class name.
  37010. * @returns the class name
  37011. */
  37012. getClassName(): string;
  37013. }
  37014. /**
  37015. * Arc Rotate version of the follow camera.
  37016. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37017. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37018. */
  37019. export class ArcFollowCamera extends TargetCamera {
  37020. /** The longitudinal angle of the camera */
  37021. alpha: number;
  37022. /** The latitudinal angle of the camera */
  37023. beta: number;
  37024. /** The radius of the camera from its target */
  37025. radius: number;
  37026. /** Define the camera target (the messh it should follow) */
  37027. target: Nullable<AbstractMesh>;
  37028. private _cartesianCoordinates;
  37029. /**
  37030. * Instantiates a new ArcFollowCamera
  37031. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37032. * @param name Define the name of the camera
  37033. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37034. * @param beta Define the rotation angle of the camera around the elevation axis
  37035. * @param radius Define the radius of the camera from its target point
  37036. * @param target Define the target of the camera
  37037. * @param scene Define the scene the camera belongs to
  37038. */
  37039. constructor(name: string,
  37040. /** The longitudinal angle of the camera */
  37041. alpha: number,
  37042. /** The latitudinal angle of the camera */
  37043. beta: number,
  37044. /** The radius of the camera from its target */
  37045. radius: number,
  37046. /** Define the camera target (the messh it should follow) */
  37047. target: Nullable<AbstractMesh>, scene: Scene);
  37048. private _follow;
  37049. /** @hidden */
  37050. _checkInputs(): void;
  37051. /**
  37052. * Returns the class name of the object.
  37053. * It is mostly used internally for serialization purposes.
  37054. */
  37055. getClassName(): string;
  37056. }
  37057. }
  37058. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37059. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37060. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37061. import { Nullable } from "babylonjs/types";
  37062. /**
  37063. * Manage the keyboard inputs to control the movement of a follow camera.
  37064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37065. */
  37066. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37067. /**
  37068. * Defines the camera the input is attached to.
  37069. */
  37070. camera: FollowCamera;
  37071. /**
  37072. * Defines the list of key codes associated with the up action (increase heightOffset)
  37073. */
  37074. keysHeightOffsetIncr: number[];
  37075. /**
  37076. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37077. */
  37078. keysHeightOffsetDecr: number[];
  37079. /**
  37080. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37081. */
  37082. keysHeightOffsetModifierAlt: boolean;
  37083. /**
  37084. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37085. */
  37086. keysHeightOffsetModifierCtrl: boolean;
  37087. /**
  37088. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37089. */
  37090. keysHeightOffsetModifierShift: boolean;
  37091. /**
  37092. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37093. */
  37094. keysRotationOffsetIncr: number[];
  37095. /**
  37096. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37097. */
  37098. keysRotationOffsetDecr: number[];
  37099. /**
  37100. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37101. */
  37102. keysRotationOffsetModifierAlt: boolean;
  37103. /**
  37104. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37105. */
  37106. keysRotationOffsetModifierCtrl: boolean;
  37107. /**
  37108. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37109. */
  37110. keysRotationOffsetModifierShift: boolean;
  37111. /**
  37112. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37113. */
  37114. keysRadiusIncr: number[];
  37115. /**
  37116. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37117. */
  37118. keysRadiusDecr: number[];
  37119. /**
  37120. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37121. */
  37122. keysRadiusModifierAlt: boolean;
  37123. /**
  37124. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37125. */
  37126. keysRadiusModifierCtrl: boolean;
  37127. /**
  37128. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37129. */
  37130. keysRadiusModifierShift: boolean;
  37131. /**
  37132. * Defines the rate of change of heightOffset.
  37133. */
  37134. heightSensibility: number;
  37135. /**
  37136. * Defines the rate of change of rotationOffset.
  37137. */
  37138. rotationSensibility: number;
  37139. /**
  37140. * Defines the rate of change of radius.
  37141. */
  37142. radiusSensibility: number;
  37143. private _keys;
  37144. private _ctrlPressed;
  37145. private _altPressed;
  37146. private _shiftPressed;
  37147. private _onCanvasBlurObserver;
  37148. private _onKeyboardObserver;
  37149. private _engine;
  37150. private _scene;
  37151. /**
  37152. * Attach the input controls to a specific dom element to get the input from.
  37153. * @param element Defines the element the controls should be listened from
  37154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37155. */
  37156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37157. /**
  37158. * Detach the current controls from the specified dom element.
  37159. * @param element Defines the element to stop listening the inputs from
  37160. */
  37161. detachControl(element: Nullable<HTMLElement>): void;
  37162. /**
  37163. * Update the current camera state depending on the inputs that have been used this frame.
  37164. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37165. */
  37166. checkInputs(): void;
  37167. /**
  37168. * Gets the class name of the current input.
  37169. * @returns the class name
  37170. */
  37171. getClassName(): string;
  37172. /**
  37173. * Get the friendly name associated with the input class.
  37174. * @returns the input friendly name
  37175. */
  37176. getSimpleName(): string;
  37177. /**
  37178. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37179. * allow modification of the heightOffset value.
  37180. */
  37181. private _modifierHeightOffset;
  37182. /**
  37183. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37184. * allow modification of the rotationOffset value.
  37185. */
  37186. private _modifierRotationOffset;
  37187. /**
  37188. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37189. * allow modification of the radius value.
  37190. */
  37191. private _modifierRadius;
  37192. }
  37193. }
  37194. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37195. import { Nullable } from "babylonjs/types";
  37196. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37197. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37198. module "babylonjs/Cameras/freeCameraInputsManager" {
  37199. interface FreeCameraInputsManager {
  37200. /**
  37201. * Add orientation input support to the input manager.
  37202. * @returns the current input manager
  37203. */
  37204. addDeviceOrientation(): FreeCameraInputsManager;
  37205. }
  37206. }
  37207. /**
  37208. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37209. * Screen rotation is taken into account.
  37210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37211. */
  37212. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37213. private _camera;
  37214. private _screenOrientationAngle;
  37215. private _constantTranform;
  37216. private _screenQuaternion;
  37217. private _alpha;
  37218. private _beta;
  37219. private _gamma;
  37220. /**
  37221. * Instantiates a new input
  37222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37223. */
  37224. constructor();
  37225. /**
  37226. * Define the camera controlled by the input.
  37227. */
  37228. camera: FreeCamera;
  37229. /**
  37230. * Attach the input controls to a specific dom element to get the input from.
  37231. * @param element Defines the element the controls should be listened from
  37232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37233. */
  37234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37235. private _orientationChanged;
  37236. private _deviceOrientation;
  37237. /**
  37238. * Detach the current controls from the specified dom element.
  37239. * @param element Defines the element to stop listening the inputs from
  37240. */
  37241. detachControl(element: Nullable<HTMLElement>): void;
  37242. /**
  37243. * Update the current camera state depending on the inputs that have been used this frame.
  37244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37245. */
  37246. checkInputs(): void;
  37247. /**
  37248. * Gets the class name of the current intput.
  37249. * @returns the class name
  37250. */
  37251. getClassName(): string;
  37252. /**
  37253. * Get the friendly name associated with the input class.
  37254. * @returns the input friendly name
  37255. */
  37256. getSimpleName(): string;
  37257. }
  37258. }
  37259. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37260. import { Nullable } from "babylonjs/types";
  37261. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37262. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37263. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37264. /**
  37265. * Manage the gamepad inputs to control a free camera.
  37266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37267. */
  37268. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37269. /**
  37270. * Define the camera the input is attached to.
  37271. */
  37272. camera: FreeCamera;
  37273. /**
  37274. * Define the Gamepad controlling the input
  37275. */
  37276. gamepad: Nullable<Gamepad>;
  37277. /**
  37278. * Defines the gamepad rotation sensiblity.
  37279. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37280. */
  37281. gamepadAngularSensibility: number;
  37282. /**
  37283. * Defines the gamepad move sensiblity.
  37284. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37285. */
  37286. gamepadMoveSensibility: number;
  37287. private _onGamepadConnectedObserver;
  37288. private _onGamepadDisconnectedObserver;
  37289. private _cameraTransform;
  37290. private _deltaTransform;
  37291. private _vector3;
  37292. private _vector2;
  37293. /**
  37294. * Attach the input controls to a specific dom element to get the input from.
  37295. * @param element Defines the element the controls should be listened from
  37296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37297. */
  37298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37299. /**
  37300. * Detach the current controls from the specified dom element.
  37301. * @param element Defines the element to stop listening the inputs from
  37302. */
  37303. detachControl(element: Nullable<HTMLElement>): void;
  37304. /**
  37305. * Update the current camera state depending on the inputs that have been used this frame.
  37306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37307. */
  37308. checkInputs(): void;
  37309. /**
  37310. * Gets the class name of the current intput.
  37311. * @returns the class name
  37312. */
  37313. getClassName(): string;
  37314. /**
  37315. * Get the friendly name associated with the input class.
  37316. * @returns the input friendly name
  37317. */
  37318. getSimpleName(): string;
  37319. }
  37320. }
  37321. declare module "babylonjs/Misc/virtualJoystick" {
  37322. import { Nullable } from "babylonjs/types";
  37323. import { Vector3 } from "babylonjs/Maths/math";
  37324. /**
  37325. * Defines the potential axis of a Joystick
  37326. */
  37327. export enum JoystickAxis {
  37328. /** X axis */
  37329. X = 0,
  37330. /** Y axis */
  37331. Y = 1,
  37332. /** Z axis */
  37333. Z = 2
  37334. }
  37335. /**
  37336. * Class used to define virtual joystick (used in touch mode)
  37337. */
  37338. export class VirtualJoystick {
  37339. /**
  37340. * Gets or sets a boolean indicating that left and right values must be inverted
  37341. */
  37342. reverseLeftRight: boolean;
  37343. /**
  37344. * Gets or sets a boolean indicating that up and down values must be inverted
  37345. */
  37346. reverseUpDown: boolean;
  37347. /**
  37348. * Gets the offset value for the position (ie. the change of the position value)
  37349. */
  37350. deltaPosition: Vector3;
  37351. /**
  37352. * Gets a boolean indicating if the virtual joystick was pressed
  37353. */
  37354. pressed: boolean;
  37355. /**
  37356. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37357. */
  37358. static Canvas: Nullable<HTMLCanvasElement>;
  37359. private static _globalJoystickIndex;
  37360. private static vjCanvasContext;
  37361. private static vjCanvasWidth;
  37362. private static vjCanvasHeight;
  37363. private static halfWidth;
  37364. private _action;
  37365. private _axisTargetedByLeftAndRight;
  37366. private _axisTargetedByUpAndDown;
  37367. private _joystickSensibility;
  37368. private _inversedSensibility;
  37369. private _joystickPointerID;
  37370. private _joystickColor;
  37371. private _joystickPointerPos;
  37372. private _joystickPreviousPointerPos;
  37373. private _joystickPointerStartPos;
  37374. private _deltaJoystickVector;
  37375. private _leftJoystick;
  37376. private _touches;
  37377. private _onPointerDownHandlerRef;
  37378. private _onPointerMoveHandlerRef;
  37379. private _onPointerUpHandlerRef;
  37380. private _onResize;
  37381. /**
  37382. * Creates a new virtual joystick
  37383. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37384. */
  37385. constructor(leftJoystick?: boolean);
  37386. /**
  37387. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37388. * @param newJoystickSensibility defines the new sensibility
  37389. */
  37390. setJoystickSensibility(newJoystickSensibility: number): void;
  37391. private _onPointerDown;
  37392. private _onPointerMove;
  37393. private _onPointerUp;
  37394. /**
  37395. * Change the color of the virtual joystick
  37396. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37397. */
  37398. setJoystickColor(newColor: string): void;
  37399. /**
  37400. * Defines a callback to call when the joystick is touched
  37401. * @param action defines the callback
  37402. */
  37403. setActionOnTouch(action: () => any): void;
  37404. /**
  37405. * Defines which axis you'd like to control for left & right
  37406. * @param axis defines the axis to use
  37407. */
  37408. setAxisForLeftRight(axis: JoystickAxis): void;
  37409. /**
  37410. * Defines which axis you'd like to control for up & down
  37411. * @param axis defines the axis to use
  37412. */
  37413. setAxisForUpDown(axis: JoystickAxis): void;
  37414. private _drawVirtualJoystick;
  37415. /**
  37416. * Release internal HTML canvas
  37417. */
  37418. releaseCanvas(): void;
  37419. }
  37420. }
  37421. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37422. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37423. import { Nullable } from "babylonjs/types";
  37424. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37425. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37426. module "babylonjs/Cameras/freeCameraInputsManager" {
  37427. interface FreeCameraInputsManager {
  37428. /**
  37429. * Add virtual joystick input support to the input manager.
  37430. * @returns the current input manager
  37431. */
  37432. addVirtualJoystick(): FreeCameraInputsManager;
  37433. }
  37434. }
  37435. /**
  37436. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37438. */
  37439. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37440. /**
  37441. * Defines the camera the input is attached to.
  37442. */
  37443. camera: FreeCamera;
  37444. private _leftjoystick;
  37445. private _rightjoystick;
  37446. /**
  37447. * Gets the left stick of the virtual joystick.
  37448. * @returns The virtual Joystick
  37449. */
  37450. getLeftJoystick(): VirtualJoystick;
  37451. /**
  37452. * Gets the right stick of the virtual joystick.
  37453. * @returns The virtual Joystick
  37454. */
  37455. getRightJoystick(): VirtualJoystick;
  37456. /**
  37457. * Update the current camera state depending on the inputs that have been used this frame.
  37458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37459. */
  37460. checkInputs(): void;
  37461. /**
  37462. * Attach the input controls to a specific dom element to get the input from.
  37463. * @param element Defines the element the controls should be listened from
  37464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37465. */
  37466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37467. /**
  37468. * Detach the current controls from the specified dom element.
  37469. * @param element Defines the element to stop listening the inputs from
  37470. */
  37471. detachControl(element: Nullable<HTMLElement>): void;
  37472. /**
  37473. * Gets the class name of the current intput.
  37474. * @returns the class name
  37475. */
  37476. getClassName(): string;
  37477. /**
  37478. * Get the friendly name associated with the input class.
  37479. * @returns the input friendly name
  37480. */
  37481. getSimpleName(): string;
  37482. }
  37483. }
  37484. declare module "babylonjs/Cameras/Inputs/index" {
  37485. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37486. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37487. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37488. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37489. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37490. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37491. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37492. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37493. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37494. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37495. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37496. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37497. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37498. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37499. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37500. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37501. }
  37502. declare module "babylonjs/Cameras/touchCamera" {
  37503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37504. import { Scene } from "babylonjs/scene";
  37505. import { Vector3 } from "babylonjs/Maths/math";
  37506. /**
  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. */
  37511. export class TouchCamera extends FreeCamera {
  37512. /**
  37513. * Defines the touch sensibility for rotation.
  37514. * The higher the faster.
  37515. */
  37516. touchAngularSensibility: number;
  37517. /**
  37518. * Defines the touch sensibility for move.
  37519. * The higher the faster.
  37520. */
  37521. touchMoveSensibility: number;
  37522. /**
  37523. * Instantiates a new touch camera.
  37524. * This represents a FPS type of camera controlled by touch.
  37525. * This is like a universal camera minus the Gamepad controls.
  37526. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37527. * @param name Define the name of the camera in the scene
  37528. * @param position Define the start position of the camera in the scene
  37529. * @param scene Define the scene the camera belongs to
  37530. */
  37531. constructor(name: string, position: Vector3, scene: Scene);
  37532. /**
  37533. * Gets the current object class name.
  37534. * @return the class name
  37535. */
  37536. getClassName(): string;
  37537. /** @hidden */
  37538. _setupInputs(): void;
  37539. }
  37540. }
  37541. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37542. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37543. import { Scene } from "babylonjs/scene";
  37544. import { Vector3, Axis } from "babylonjs/Maths/math";
  37545. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37546. /**
  37547. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37548. * being tilted forward or back and left or right.
  37549. */
  37550. export class DeviceOrientationCamera extends FreeCamera {
  37551. private _initialQuaternion;
  37552. private _quaternionCache;
  37553. /**
  37554. * Creates a new device orientation camera
  37555. * @param name The name of the camera
  37556. * @param position The start position camera
  37557. * @param scene The scene the camera belongs to
  37558. */
  37559. constructor(name: string, position: Vector3, scene: Scene);
  37560. /**
  37561. * Gets the current instance class name ("DeviceOrientationCamera").
  37562. * This helps avoiding instanceof at run time.
  37563. * @returns the class name
  37564. */
  37565. getClassName(): string;
  37566. /**
  37567. * @hidden
  37568. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37569. */
  37570. _checkInputs(): void;
  37571. /**
  37572. * Reset the camera to its default orientation on the specified axis only.
  37573. * @param axis The axis to reset
  37574. */
  37575. resetToCurrentRotation(axis?: Axis): void;
  37576. }
  37577. }
  37578. declare module "babylonjs/Cameras/universalCamera" {
  37579. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37580. import { Scene } from "babylonjs/scene";
  37581. import { Vector3 } from "babylonjs/Maths/math";
  37582. /**
  37583. * 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,
  37584. * which still works and will still be found in many Playgrounds.
  37585. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37586. */
  37587. export class UniversalCamera extends TouchCamera {
  37588. /**
  37589. * Defines the gamepad rotation sensiblity.
  37590. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37591. */
  37592. gamepadAngularSensibility: number;
  37593. /**
  37594. * Defines the gamepad move sensiblity.
  37595. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37596. */
  37597. gamepadMoveSensibility: number;
  37598. /**
  37599. * 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,
  37600. * which still works and will still be found in many Playgrounds.
  37601. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37602. * @param name Define the name of the camera in the scene
  37603. * @param position Define the start position of the camera in the scene
  37604. * @param scene Define the scene the camera belongs to
  37605. */
  37606. constructor(name: string, position: Vector3, scene: Scene);
  37607. /**
  37608. * Gets the current object class name.
  37609. * @return the class name
  37610. */
  37611. getClassName(): string;
  37612. }
  37613. }
  37614. declare module "babylonjs/Cameras/gamepadCamera" {
  37615. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37616. import { Scene } from "babylonjs/scene";
  37617. import { Vector3 } from "babylonjs/Maths/math";
  37618. /**
  37619. * This represents a FPS type of camera. This is only here for back compat purpose.
  37620. * Please use the UniversalCamera instead as both are identical.
  37621. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37622. */
  37623. export class GamepadCamera extends UniversalCamera {
  37624. /**
  37625. * Instantiates a new Gamepad Camera
  37626. * This represents a FPS type of camera. This is only here for back compat purpose.
  37627. * Please use the UniversalCamera instead as both are identical.
  37628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37629. * @param name Define the name of the camera in the scene
  37630. * @param position Define the start position of the camera in the scene
  37631. * @param scene Define the scene the camera belongs to
  37632. */
  37633. constructor(name: string, position: Vector3, scene: Scene);
  37634. /**
  37635. * Gets the current object class name.
  37636. * @return the class name
  37637. */
  37638. getClassName(): string;
  37639. }
  37640. }
  37641. declare module "babylonjs/Shaders/pass.fragment" {
  37642. /** @hidden */
  37643. export var passPixelShader: {
  37644. name: string;
  37645. shader: string;
  37646. };
  37647. }
  37648. declare module "babylonjs/Shaders/passCube.fragment" {
  37649. /** @hidden */
  37650. export var passCubePixelShader: {
  37651. name: string;
  37652. shader: string;
  37653. };
  37654. }
  37655. declare module "babylonjs/PostProcesses/passPostProcess" {
  37656. import { Nullable } from "babylonjs/types";
  37657. import { Camera } from "babylonjs/Cameras/camera";
  37658. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37659. import { Engine } from "babylonjs/Engines/engine";
  37660. import "babylonjs/Shaders/pass.fragment";
  37661. import "babylonjs/Shaders/passCube.fragment";
  37662. /**
  37663. * PassPostProcess which produces an output the same as it's input
  37664. */
  37665. export class PassPostProcess extends PostProcess {
  37666. /**
  37667. * Creates the PassPostProcess
  37668. * @param name The name of the effect.
  37669. * @param options The required width/height ratio to downsize to before computing the render pass.
  37670. * @param camera The camera to apply the render pass to.
  37671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37672. * @param engine The engine which the post process will be applied. (default: current engine)
  37673. * @param reusable If the post process can be reused on the same frame. (default: false)
  37674. * @param textureType The type of texture to be used when performing the post processing.
  37675. * @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)
  37676. */
  37677. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37678. }
  37679. /**
  37680. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37681. */
  37682. export class PassCubePostProcess extends PostProcess {
  37683. private _face;
  37684. /**
  37685. * Gets or sets the cube face to display.
  37686. * * 0 is +X
  37687. * * 1 is -X
  37688. * * 2 is +Y
  37689. * * 3 is -Y
  37690. * * 4 is +Z
  37691. * * 5 is -Z
  37692. */
  37693. face: number;
  37694. /**
  37695. * Creates the PassCubePostProcess
  37696. * @param name The name of the effect.
  37697. * @param options The required width/height ratio to downsize to before computing the render pass.
  37698. * @param camera The camera to apply the render pass to.
  37699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37700. * @param engine The engine which the post process will be applied. (default: current engine)
  37701. * @param reusable If the post process can be reused on the same frame. (default: false)
  37702. * @param textureType The type of texture to be used when performing the post processing.
  37703. * @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)
  37704. */
  37705. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37706. }
  37707. }
  37708. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37709. /** @hidden */
  37710. export var anaglyphPixelShader: {
  37711. name: string;
  37712. shader: string;
  37713. };
  37714. }
  37715. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37716. import { Engine } from "babylonjs/Engines/engine";
  37717. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37718. import { Camera } from "babylonjs/Cameras/camera";
  37719. import "babylonjs/Shaders/anaglyph.fragment";
  37720. /**
  37721. * Postprocess used to generate anaglyphic rendering
  37722. */
  37723. export class AnaglyphPostProcess extends PostProcess {
  37724. private _passedProcess;
  37725. /**
  37726. * Creates a new AnaglyphPostProcess
  37727. * @param name defines postprocess name
  37728. * @param options defines creation options or target ratio scale
  37729. * @param rigCameras defines cameras using this postprocess
  37730. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37731. * @param engine defines hosting engine
  37732. * @param reusable defines if the postprocess will be reused multiple times per frame
  37733. */
  37734. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37735. }
  37736. }
  37737. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37738. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37739. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37740. import { Scene } from "babylonjs/scene";
  37741. import { Vector3 } from "babylonjs/Maths/math";
  37742. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37743. /**
  37744. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37746. */
  37747. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37748. /**
  37749. * Creates a new AnaglyphArcRotateCamera
  37750. * @param name defines camera name
  37751. * @param alpha defines alpha angle (in radians)
  37752. * @param beta defines beta angle (in radians)
  37753. * @param radius defines radius
  37754. * @param target defines camera target
  37755. * @param interaxialDistance defines distance between each color axis
  37756. * @param scene defines the hosting scene
  37757. */
  37758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37759. /**
  37760. * Gets camera class name
  37761. * @returns AnaglyphArcRotateCamera
  37762. */
  37763. getClassName(): string;
  37764. }
  37765. }
  37766. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37768. import { Scene } from "babylonjs/scene";
  37769. import { Vector3 } from "babylonjs/Maths/math";
  37770. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37771. /**
  37772. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37773. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37774. */
  37775. export class AnaglyphFreeCamera extends FreeCamera {
  37776. /**
  37777. * Creates a new AnaglyphFreeCamera
  37778. * @param name defines camera name
  37779. * @param position defines initial position
  37780. * @param interaxialDistance defines distance between each color axis
  37781. * @param scene defines the hosting scene
  37782. */
  37783. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37784. /**
  37785. * Gets camera class name
  37786. * @returns AnaglyphFreeCamera
  37787. */
  37788. getClassName(): string;
  37789. }
  37790. }
  37791. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37792. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37793. import { Scene } from "babylonjs/scene";
  37794. import { Vector3 } from "babylonjs/Maths/math";
  37795. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37796. /**
  37797. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37798. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37799. */
  37800. export class AnaglyphGamepadCamera extends GamepadCamera {
  37801. /**
  37802. * Creates a new AnaglyphGamepadCamera
  37803. * @param name defines camera name
  37804. * @param position defines initial position
  37805. * @param interaxialDistance defines distance between each color axis
  37806. * @param scene defines the hosting scene
  37807. */
  37808. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37809. /**
  37810. * Gets camera class name
  37811. * @returns AnaglyphGamepadCamera
  37812. */
  37813. getClassName(): string;
  37814. }
  37815. }
  37816. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37817. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37818. import { Scene } from "babylonjs/scene";
  37819. import { Vector3 } from "babylonjs/Maths/math";
  37820. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37821. /**
  37822. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37823. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37824. */
  37825. export class AnaglyphUniversalCamera extends UniversalCamera {
  37826. /**
  37827. * Creates a new AnaglyphUniversalCamera
  37828. * @param name defines camera name
  37829. * @param position defines initial position
  37830. * @param interaxialDistance defines distance between each color axis
  37831. * @param scene defines the hosting scene
  37832. */
  37833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37834. /**
  37835. * Gets camera class name
  37836. * @returns AnaglyphUniversalCamera
  37837. */
  37838. getClassName(): string;
  37839. }
  37840. }
  37841. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37842. /** @hidden */
  37843. export var stereoscopicInterlacePixelShader: {
  37844. name: string;
  37845. shader: string;
  37846. };
  37847. }
  37848. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37849. import { Camera } from "babylonjs/Cameras/camera";
  37850. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37851. import { Engine } from "babylonjs/Engines/engine";
  37852. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37853. /**
  37854. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37855. */
  37856. export class StereoscopicInterlacePostProcess extends PostProcess {
  37857. private _stepSize;
  37858. private _passedProcess;
  37859. /**
  37860. * Initializes a StereoscopicInterlacePostProcess
  37861. * @param name The name of the effect.
  37862. * @param rigCameras The rig cameras to be appled to the post process
  37863. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37865. * @param engine The engine which the post process will be applied. (default: current engine)
  37866. * @param reusable If the post process can be reused on the same frame. (default: false)
  37867. */
  37868. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37869. }
  37870. }
  37871. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37872. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37873. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37874. import { Scene } from "babylonjs/scene";
  37875. import { Vector3 } from "babylonjs/Maths/math";
  37876. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37877. /**
  37878. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37879. * @see http://doc.babylonjs.com/features/cameras
  37880. */
  37881. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37882. /**
  37883. * Creates a new StereoscopicArcRotateCamera
  37884. * @param name defines camera name
  37885. * @param alpha defines alpha angle (in radians)
  37886. * @param beta defines beta angle (in radians)
  37887. * @param radius defines radius
  37888. * @param target defines camera target
  37889. * @param interaxialDistance defines distance between each color axis
  37890. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37891. * @param scene defines the hosting scene
  37892. */
  37893. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37894. /**
  37895. * Gets camera class name
  37896. * @returns StereoscopicArcRotateCamera
  37897. */
  37898. getClassName(): string;
  37899. }
  37900. }
  37901. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37902. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37903. import { Scene } from "babylonjs/scene";
  37904. import { Vector3 } from "babylonjs/Maths/math";
  37905. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37906. /**
  37907. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37908. * @see http://doc.babylonjs.com/features/cameras
  37909. */
  37910. export class StereoscopicFreeCamera extends FreeCamera {
  37911. /**
  37912. * Creates a new StereoscopicFreeCamera
  37913. * @param name defines camera name
  37914. * @param position defines initial position
  37915. * @param interaxialDistance defines distance between each color axis
  37916. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37917. * @param scene defines the hosting scene
  37918. */
  37919. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37920. /**
  37921. * Gets camera class name
  37922. * @returns StereoscopicFreeCamera
  37923. */
  37924. getClassName(): string;
  37925. }
  37926. }
  37927. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37928. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37929. import { Scene } from "babylonjs/scene";
  37930. import { Vector3 } from "babylonjs/Maths/math";
  37931. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37932. /**
  37933. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37934. * @see http://doc.babylonjs.com/features/cameras
  37935. */
  37936. export class StereoscopicGamepadCamera extends GamepadCamera {
  37937. /**
  37938. * Creates a new StereoscopicGamepadCamera
  37939. * @param name defines camera name
  37940. * @param position defines initial position
  37941. * @param interaxialDistance defines distance between each color axis
  37942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37943. * @param scene defines the hosting scene
  37944. */
  37945. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37946. /**
  37947. * Gets camera class name
  37948. * @returns StereoscopicGamepadCamera
  37949. */
  37950. getClassName(): string;
  37951. }
  37952. }
  37953. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37954. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37955. import { Scene } from "babylonjs/scene";
  37956. import { Vector3 } from "babylonjs/Maths/math";
  37957. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37958. /**
  37959. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37960. * @see http://doc.babylonjs.com/features/cameras
  37961. */
  37962. export class StereoscopicUniversalCamera extends UniversalCamera {
  37963. /**
  37964. * Creates a new StereoscopicUniversalCamera
  37965. * @param name defines camera name
  37966. * @param position defines initial position
  37967. * @param interaxialDistance defines distance between each color axis
  37968. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37969. * @param scene defines the hosting scene
  37970. */
  37971. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37972. /**
  37973. * Gets camera class name
  37974. * @returns StereoscopicUniversalCamera
  37975. */
  37976. getClassName(): string;
  37977. }
  37978. }
  37979. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37980. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37981. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37982. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37983. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37984. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37985. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37986. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37987. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37988. }
  37989. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37990. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37991. import { Scene } from "babylonjs/scene";
  37992. import { Vector3 } from "babylonjs/Maths/math";
  37993. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37994. /**
  37995. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37996. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37997. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37998. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37999. */
  38000. export class VirtualJoysticksCamera extends FreeCamera {
  38001. /**
  38002. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38003. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38004. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38005. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38006. * @param name Define the name of the camera in the scene
  38007. * @param position Define the start position of the camera in the scene
  38008. * @param scene Define the scene the camera belongs to
  38009. */
  38010. constructor(name: string, position: Vector3, scene: Scene);
  38011. /**
  38012. * Gets the current object class name.
  38013. * @return the class name
  38014. */
  38015. getClassName(): string;
  38016. }
  38017. }
  38018. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38019. import { Matrix } from "babylonjs/Maths/math";
  38020. /**
  38021. * This represents all the required metrics to create a VR camera.
  38022. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38023. */
  38024. export class VRCameraMetrics {
  38025. /**
  38026. * Define the horizontal resolution off the screen.
  38027. */
  38028. hResolution: number;
  38029. /**
  38030. * Define the vertical resolution off the screen.
  38031. */
  38032. vResolution: number;
  38033. /**
  38034. * Define the horizontal screen size.
  38035. */
  38036. hScreenSize: number;
  38037. /**
  38038. * Define the vertical screen size.
  38039. */
  38040. vScreenSize: number;
  38041. /**
  38042. * Define the vertical screen center position.
  38043. */
  38044. vScreenCenter: number;
  38045. /**
  38046. * Define the distance of the eyes to the screen.
  38047. */
  38048. eyeToScreenDistance: number;
  38049. /**
  38050. * Define the distance between both lenses
  38051. */
  38052. lensSeparationDistance: number;
  38053. /**
  38054. * Define the distance between both viewer's eyes.
  38055. */
  38056. interpupillaryDistance: number;
  38057. /**
  38058. * Define the distortion factor of the VR postprocess.
  38059. * Please, touch with care.
  38060. */
  38061. distortionK: number[];
  38062. /**
  38063. * Define the chromatic aberration correction factors for the VR post process.
  38064. */
  38065. chromaAbCorrection: number[];
  38066. /**
  38067. * Define the scale factor of the post process.
  38068. * The smaller the better but the slower.
  38069. */
  38070. postProcessScaleFactor: number;
  38071. /**
  38072. * Define an offset for the lens center.
  38073. */
  38074. lensCenterOffset: number;
  38075. /**
  38076. * Define if the current vr camera should compensate the distortion of the lense or not.
  38077. */
  38078. compensateDistortion: boolean;
  38079. /**
  38080. * Gets the rendering aspect ratio based on the provided resolutions.
  38081. */
  38082. readonly aspectRatio: number;
  38083. /**
  38084. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38085. */
  38086. readonly aspectRatioFov: number;
  38087. /**
  38088. * @hidden
  38089. */
  38090. readonly leftHMatrix: Matrix;
  38091. /**
  38092. * @hidden
  38093. */
  38094. readonly rightHMatrix: Matrix;
  38095. /**
  38096. * @hidden
  38097. */
  38098. readonly leftPreViewMatrix: Matrix;
  38099. /**
  38100. * @hidden
  38101. */
  38102. readonly rightPreViewMatrix: Matrix;
  38103. /**
  38104. * Get the default VRMetrics based on the most generic setup.
  38105. * @returns the default vr metrics
  38106. */
  38107. static GetDefault(): VRCameraMetrics;
  38108. }
  38109. }
  38110. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38111. /** @hidden */
  38112. export var vrDistortionCorrectionPixelShader: {
  38113. name: string;
  38114. shader: string;
  38115. };
  38116. }
  38117. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38118. import { Camera } from "babylonjs/Cameras/camera";
  38119. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38120. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38121. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38122. /**
  38123. * VRDistortionCorrectionPostProcess used for mobile VR
  38124. */
  38125. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38126. private _isRightEye;
  38127. private _distortionFactors;
  38128. private _postProcessScaleFactor;
  38129. private _lensCenterOffset;
  38130. private _scaleIn;
  38131. private _scaleFactor;
  38132. private _lensCenter;
  38133. /**
  38134. * Initializes the VRDistortionCorrectionPostProcess
  38135. * @param name The name of the effect.
  38136. * @param camera The camera to apply the render pass to.
  38137. * @param isRightEye If this is for the right eye distortion
  38138. * @param vrMetrics All the required metrics for the VR camera
  38139. */
  38140. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38141. }
  38142. }
  38143. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38144. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38145. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38146. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38147. import { Scene } from "babylonjs/scene";
  38148. import { Vector3 } from "babylonjs/Maths/math";
  38149. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38150. import "babylonjs/Cameras/RigModes/vrRigMode";
  38151. /**
  38152. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38153. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38154. */
  38155. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38156. /**
  38157. * Creates a new VRDeviceOrientationArcRotateCamera
  38158. * @param name defines camera name
  38159. * @param alpha defines the camera rotation along the logitudinal axis
  38160. * @param beta defines the camera rotation along the latitudinal axis
  38161. * @param radius defines the camera distance from its target
  38162. * @param target defines the camera target
  38163. * @param scene defines the scene the camera belongs to
  38164. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38165. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38166. */
  38167. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38168. /**
  38169. * Gets camera class name
  38170. * @returns VRDeviceOrientationArcRotateCamera
  38171. */
  38172. getClassName(): string;
  38173. }
  38174. }
  38175. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38176. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38177. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38178. import { Scene } from "babylonjs/scene";
  38179. import { Vector3 } from "babylonjs/Maths/math";
  38180. import "babylonjs/Cameras/RigModes/vrRigMode";
  38181. /**
  38182. * Camera used to simulate VR rendering (based on FreeCamera)
  38183. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38184. */
  38185. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38186. /**
  38187. * Creates a new VRDeviceOrientationFreeCamera
  38188. * @param name defines camera name
  38189. * @param position defines the start position of the camera
  38190. * @param scene defines the scene the camera belongs to
  38191. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38192. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38193. */
  38194. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38195. /**
  38196. * Gets camera class name
  38197. * @returns VRDeviceOrientationFreeCamera
  38198. */
  38199. getClassName(): string;
  38200. }
  38201. }
  38202. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38203. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38204. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38205. import { Scene } from "babylonjs/scene";
  38206. import { Vector3 } from "babylonjs/Maths/math";
  38207. /**
  38208. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38209. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38210. */
  38211. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38212. /**
  38213. * Creates a new VRDeviceOrientationGamepadCamera
  38214. * @param name defines camera name
  38215. * @param position defines the start position of the camera
  38216. * @param scene defines the scene the camera belongs to
  38217. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38218. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38219. */
  38220. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38221. /**
  38222. * Gets camera class name
  38223. * @returns VRDeviceOrientationGamepadCamera
  38224. */
  38225. getClassName(): string;
  38226. }
  38227. }
  38228. declare module "babylonjs/Gamepads/xboxGamepad" {
  38229. import { Observable } from "babylonjs/Misc/observable";
  38230. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38231. /**
  38232. * Defines supported buttons for XBox360 compatible gamepads
  38233. */
  38234. export enum Xbox360Button {
  38235. /** A */
  38236. A = 0,
  38237. /** B */
  38238. B = 1,
  38239. /** X */
  38240. X = 2,
  38241. /** Y */
  38242. Y = 3,
  38243. /** Start */
  38244. Start = 4,
  38245. /** Back */
  38246. Back = 5,
  38247. /** Left button */
  38248. LB = 6,
  38249. /** Right button */
  38250. RB = 7,
  38251. /** Left stick */
  38252. LeftStick = 8,
  38253. /** Right stick */
  38254. RightStick = 9
  38255. }
  38256. /** Defines values for XBox360 DPad */
  38257. export enum Xbox360Dpad {
  38258. /** Up */
  38259. Up = 0,
  38260. /** Down */
  38261. Down = 1,
  38262. /** Left */
  38263. Left = 2,
  38264. /** Right */
  38265. Right = 3
  38266. }
  38267. /**
  38268. * Defines a XBox360 gamepad
  38269. */
  38270. export class Xbox360Pad extends Gamepad {
  38271. private _leftTrigger;
  38272. private _rightTrigger;
  38273. private _onlefttriggerchanged;
  38274. private _onrighttriggerchanged;
  38275. private _onbuttondown;
  38276. private _onbuttonup;
  38277. private _ondpaddown;
  38278. private _ondpadup;
  38279. /** Observable raised when a button is pressed */
  38280. onButtonDownObservable: Observable<Xbox360Button>;
  38281. /** Observable raised when a button is released */
  38282. onButtonUpObservable: Observable<Xbox360Button>;
  38283. /** Observable raised when a pad is pressed */
  38284. onPadDownObservable: Observable<Xbox360Dpad>;
  38285. /** Observable raised when a pad is released */
  38286. onPadUpObservable: Observable<Xbox360Dpad>;
  38287. private _buttonA;
  38288. private _buttonB;
  38289. private _buttonX;
  38290. private _buttonY;
  38291. private _buttonBack;
  38292. private _buttonStart;
  38293. private _buttonLB;
  38294. private _buttonRB;
  38295. private _buttonLeftStick;
  38296. private _buttonRightStick;
  38297. private _dPadUp;
  38298. private _dPadDown;
  38299. private _dPadLeft;
  38300. private _dPadRight;
  38301. private _isXboxOnePad;
  38302. /**
  38303. * Creates a new XBox360 gamepad object
  38304. * @param id defines the id of this gamepad
  38305. * @param index defines its index
  38306. * @param gamepad defines the internal HTML gamepad object
  38307. * @param xboxOne defines if it is a XBox One gamepad
  38308. */
  38309. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38310. /**
  38311. * Defines the callback to call when left trigger is pressed
  38312. * @param callback defines the callback to use
  38313. */
  38314. onlefttriggerchanged(callback: (value: number) => void): void;
  38315. /**
  38316. * Defines the callback to call when right trigger is pressed
  38317. * @param callback defines the callback to use
  38318. */
  38319. onrighttriggerchanged(callback: (value: number) => void): void;
  38320. /**
  38321. * Gets the left trigger value
  38322. */
  38323. /**
  38324. * Sets the left trigger value
  38325. */
  38326. leftTrigger: number;
  38327. /**
  38328. * Gets the right trigger value
  38329. */
  38330. /**
  38331. * Sets the right trigger value
  38332. */
  38333. rightTrigger: number;
  38334. /**
  38335. * Defines the callback to call when a button is pressed
  38336. * @param callback defines the callback to use
  38337. */
  38338. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38339. /**
  38340. * Defines the callback to call when a button is released
  38341. * @param callback defines the callback to use
  38342. */
  38343. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38344. /**
  38345. * Defines the callback to call when a pad is pressed
  38346. * @param callback defines the callback to use
  38347. */
  38348. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38349. /**
  38350. * Defines the callback to call when a pad is released
  38351. * @param callback defines the callback to use
  38352. */
  38353. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38354. private _setButtonValue;
  38355. private _setDPadValue;
  38356. /**
  38357. * Gets the value of the `A` button
  38358. */
  38359. /**
  38360. * Sets the value of the `A` button
  38361. */
  38362. buttonA: number;
  38363. /**
  38364. * Gets the value of the `B` button
  38365. */
  38366. /**
  38367. * Sets the value of the `B` button
  38368. */
  38369. buttonB: number;
  38370. /**
  38371. * Gets the value of the `X` button
  38372. */
  38373. /**
  38374. * Sets the value of the `X` button
  38375. */
  38376. buttonX: number;
  38377. /**
  38378. * Gets the value of the `Y` button
  38379. */
  38380. /**
  38381. * Sets the value of the `Y` button
  38382. */
  38383. buttonY: number;
  38384. /**
  38385. * Gets the value of the `Start` button
  38386. */
  38387. /**
  38388. * Sets the value of the `Start` button
  38389. */
  38390. buttonStart: number;
  38391. /**
  38392. * Gets the value of the `Back` button
  38393. */
  38394. /**
  38395. * Sets the value of the `Back` button
  38396. */
  38397. buttonBack: number;
  38398. /**
  38399. * Gets the value of the `Left` button
  38400. */
  38401. /**
  38402. * Sets the value of the `Left` button
  38403. */
  38404. buttonLB: number;
  38405. /**
  38406. * Gets the value of the `Right` button
  38407. */
  38408. /**
  38409. * Sets the value of the `Right` button
  38410. */
  38411. buttonRB: number;
  38412. /**
  38413. * Gets the value of the Left joystick
  38414. */
  38415. /**
  38416. * Sets the value of the Left joystick
  38417. */
  38418. buttonLeftStick: number;
  38419. /**
  38420. * Gets the value of the Right joystick
  38421. */
  38422. /**
  38423. * Sets the value of the Right joystick
  38424. */
  38425. buttonRightStick: number;
  38426. /**
  38427. * Gets the value of D-pad up
  38428. */
  38429. /**
  38430. * Sets the value of D-pad up
  38431. */
  38432. dPadUp: number;
  38433. /**
  38434. * Gets the value of D-pad down
  38435. */
  38436. /**
  38437. * Sets the value of D-pad down
  38438. */
  38439. dPadDown: number;
  38440. /**
  38441. * Gets the value of D-pad left
  38442. */
  38443. /**
  38444. * Sets the value of D-pad left
  38445. */
  38446. dPadLeft: number;
  38447. /**
  38448. * Gets the value of D-pad right
  38449. */
  38450. /**
  38451. * Sets the value of D-pad right
  38452. */
  38453. dPadRight: number;
  38454. /**
  38455. * Force the gamepad to synchronize with device values
  38456. */
  38457. update(): void;
  38458. /**
  38459. * Disposes the gamepad
  38460. */
  38461. dispose(): void;
  38462. }
  38463. }
  38464. declare module "babylonjs/Materials/pushMaterial" {
  38465. import { Nullable } from "babylonjs/types";
  38466. import { Scene } from "babylonjs/scene";
  38467. import { Matrix } from "babylonjs/Maths/math";
  38468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38469. import { Mesh } from "babylonjs/Meshes/mesh";
  38470. import { Material } from "babylonjs/Materials/material";
  38471. import { Effect } from "babylonjs/Materials/effect";
  38472. /**
  38473. * Base class of materials working in push mode in babylon JS
  38474. * @hidden
  38475. */
  38476. export class PushMaterial extends Material {
  38477. protected _activeEffect: Effect;
  38478. protected _normalMatrix: Matrix;
  38479. /**
  38480. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38481. * This means that the material can keep using a previous shader while a new one is being compiled.
  38482. * This is mostly used when shader parallel compilation is supported (true by default)
  38483. */
  38484. allowShaderHotSwapping: boolean;
  38485. constructor(name: string, scene: Scene);
  38486. getEffect(): Effect;
  38487. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38488. /**
  38489. * Binds the given world matrix to the active effect
  38490. *
  38491. * @param world the matrix to bind
  38492. */
  38493. bindOnlyWorldMatrix(world: Matrix): void;
  38494. /**
  38495. * Binds the given normal matrix to the active effect
  38496. *
  38497. * @param normalMatrix the matrix to bind
  38498. */
  38499. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38500. bind(world: Matrix, mesh?: Mesh): void;
  38501. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38502. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38503. }
  38504. }
  38505. declare module "babylonjs/Materials/materialFlags" {
  38506. /**
  38507. * This groups all the flags used to control the materials channel.
  38508. */
  38509. export class MaterialFlags {
  38510. private static _DiffuseTextureEnabled;
  38511. /**
  38512. * Are diffuse textures enabled in the application.
  38513. */
  38514. static DiffuseTextureEnabled: boolean;
  38515. private static _AmbientTextureEnabled;
  38516. /**
  38517. * Are ambient textures enabled in the application.
  38518. */
  38519. static AmbientTextureEnabled: boolean;
  38520. private static _OpacityTextureEnabled;
  38521. /**
  38522. * Are opacity textures enabled in the application.
  38523. */
  38524. static OpacityTextureEnabled: boolean;
  38525. private static _ReflectionTextureEnabled;
  38526. /**
  38527. * Are reflection textures enabled in the application.
  38528. */
  38529. static ReflectionTextureEnabled: boolean;
  38530. private static _EmissiveTextureEnabled;
  38531. /**
  38532. * Are emissive textures enabled in the application.
  38533. */
  38534. static EmissiveTextureEnabled: boolean;
  38535. private static _SpecularTextureEnabled;
  38536. /**
  38537. * Are specular textures enabled in the application.
  38538. */
  38539. static SpecularTextureEnabled: boolean;
  38540. private static _BumpTextureEnabled;
  38541. /**
  38542. * Are bump textures enabled in the application.
  38543. */
  38544. static BumpTextureEnabled: boolean;
  38545. private static _LightmapTextureEnabled;
  38546. /**
  38547. * Are lightmap textures enabled in the application.
  38548. */
  38549. static LightmapTextureEnabled: boolean;
  38550. private static _RefractionTextureEnabled;
  38551. /**
  38552. * Are refraction textures enabled in the application.
  38553. */
  38554. static RefractionTextureEnabled: boolean;
  38555. private static _ColorGradingTextureEnabled;
  38556. /**
  38557. * Are color grading textures enabled in the application.
  38558. */
  38559. static ColorGradingTextureEnabled: boolean;
  38560. private static _FresnelEnabled;
  38561. /**
  38562. * Are fresnels enabled in the application.
  38563. */
  38564. static FresnelEnabled: boolean;
  38565. private static _ClearCoatTextureEnabled;
  38566. /**
  38567. * Are clear coat textures enabled in the application.
  38568. */
  38569. static ClearCoatTextureEnabled: boolean;
  38570. private static _ClearCoatBumpTextureEnabled;
  38571. /**
  38572. * Are clear coat bump textures enabled in the application.
  38573. */
  38574. static ClearCoatBumpTextureEnabled: boolean;
  38575. private static _ClearCoatTintTextureEnabled;
  38576. /**
  38577. * Are clear coat tint textures enabled in the application.
  38578. */
  38579. static ClearCoatTintTextureEnabled: boolean;
  38580. private static _SheenTextureEnabled;
  38581. /**
  38582. * Are sheen textures enabled in the application.
  38583. */
  38584. static SheenTextureEnabled: boolean;
  38585. private static _AnisotropicTextureEnabled;
  38586. /**
  38587. * Are anisotropic textures enabled in the application.
  38588. */
  38589. static AnisotropicTextureEnabled: boolean;
  38590. }
  38591. }
  38592. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38593. /** @hidden */
  38594. export var defaultFragmentDeclaration: {
  38595. name: string;
  38596. shader: string;
  38597. };
  38598. }
  38599. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38600. /** @hidden */
  38601. export var defaultUboDeclaration: {
  38602. name: string;
  38603. shader: string;
  38604. };
  38605. }
  38606. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38607. /** @hidden */
  38608. export var lightFragmentDeclaration: {
  38609. name: string;
  38610. shader: string;
  38611. };
  38612. }
  38613. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38614. /** @hidden */
  38615. export var lightUboDeclaration: {
  38616. name: string;
  38617. shader: string;
  38618. };
  38619. }
  38620. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38621. /** @hidden */
  38622. export var lightsFragmentFunctions: {
  38623. name: string;
  38624. shader: string;
  38625. };
  38626. }
  38627. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38628. /** @hidden */
  38629. export var shadowsFragmentFunctions: {
  38630. name: string;
  38631. shader: string;
  38632. };
  38633. }
  38634. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38635. /** @hidden */
  38636. export var fresnelFunction: {
  38637. name: string;
  38638. shader: string;
  38639. };
  38640. }
  38641. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38642. /** @hidden */
  38643. export var reflectionFunction: {
  38644. name: string;
  38645. shader: string;
  38646. };
  38647. }
  38648. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38649. /** @hidden */
  38650. export var bumpFragmentFunctions: {
  38651. name: string;
  38652. shader: string;
  38653. };
  38654. }
  38655. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38656. /** @hidden */
  38657. export var logDepthDeclaration: {
  38658. name: string;
  38659. shader: string;
  38660. };
  38661. }
  38662. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38663. /** @hidden */
  38664. export var bumpFragment: {
  38665. name: string;
  38666. shader: string;
  38667. };
  38668. }
  38669. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38670. /** @hidden */
  38671. export var depthPrePass: {
  38672. name: string;
  38673. shader: string;
  38674. };
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38677. /** @hidden */
  38678. export var lightFragment: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38684. /** @hidden */
  38685. export var logDepthFragment: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/default.fragment" {
  38691. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38692. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38693. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38694. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38695. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38696. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38697. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38698. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38699. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38700. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38701. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38702. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38704. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38705. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38706. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38707. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38708. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38709. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38710. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38711. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38712. /** @hidden */
  38713. export var defaultPixelShader: {
  38714. name: string;
  38715. shader: string;
  38716. };
  38717. }
  38718. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38719. /** @hidden */
  38720. export var defaultVertexDeclaration: {
  38721. name: string;
  38722. shader: string;
  38723. };
  38724. }
  38725. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38726. /** @hidden */
  38727. export var bumpVertexDeclaration: {
  38728. name: string;
  38729. shader: string;
  38730. };
  38731. }
  38732. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38733. /** @hidden */
  38734. export var bumpVertex: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38740. /** @hidden */
  38741. export var fogVertex: {
  38742. name: string;
  38743. shader: string;
  38744. };
  38745. }
  38746. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38747. /** @hidden */
  38748. export var shadowsVertex: {
  38749. name: string;
  38750. shader: string;
  38751. };
  38752. }
  38753. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38754. /** @hidden */
  38755. export var pointCloudVertex: {
  38756. name: string;
  38757. shader: string;
  38758. };
  38759. }
  38760. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38761. /** @hidden */
  38762. export var logDepthVertex: {
  38763. name: string;
  38764. shader: string;
  38765. };
  38766. }
  38767. declare module "babylonjs/Shaders/default.vertex" {
  38768. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38769. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38770. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38771. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38772. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38773. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38775. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38776. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38777. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38780. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38782. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38783. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38784. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38785. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38786. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38787. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38788. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38789. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38790. /** @hidden */
  38791. export var defaultVertexShader: {
  38792. name: string;
  38793. shader: string;
  38794. };
  38795. }
  38796. declare module "babylonjs/Materials/standardMaterial" {
  38797. import { SmartArray } from "babylonjs/Misc/smartArray";
  38798. import { IAnimatable } from "babylonjs/Misc/tools";
  38799. import { Nullable } from "babylonjs/types";
  38800. import { Scene } from "babylonjs/scene";
  38801. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38802. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38804. import { Mesh } from "babylonjs/Meshes/mesh";
  38805. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38806. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38807. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38808. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38809. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38812. import "babylonjs/Shaders/default.fragment";
  38813. import "babylonjs/Shaders/default.vertex";
  38814. /** @hidden */
  38815. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38816. MAINUV1: boolean;
  38817. MAINUV2: boolean;
  38818. DIFFUSE: boolean;
  38819. DIFFUSEDIRECTUV: number;
  38820. AMBIENT: boolean;
  38821. AMBIENTDIRECTUV: number;
  38822. OPACITY: boolean;
  38823. OPACITYDIRECTUV: number;
  38824. OPACITYRGB: boolean;
  38825. REFLECTION: boolean;
  38826. EMISSIVE: boolean;
  38827. EMISSIVEDIRECTUV: number;
  38828. SPECULAR: boolean;
  38829. SPECULARDIRECTUV: number;
  38830. BUMP: boolean;
  38831. BUMPDIRECTUV: number;
  38832. PARALLAX: boolean;
  38833. PARALLAXOCCLUSION: boolean;
  38834. SPECULAROVERALPHA: boolean;
  38835. CLIPPLANE: boolean;
  38836. CLIPPLANE2: boolean;
  38837. CLIPPLANE3: boolean;
  38838. CLIPPLANE4: boolean;
  38839. ALPHATEST: boolean;
  38840. DEPTHPREPASS: boolean;
  38841. ALPHAFROMDIFFUSE: boolean;
  38842. POINTSIZE: boolean;
  38843. FOG: boolean;
  38844. SPECULARTERM: boolean;
  38845. DIFFUSEFRESNEL: boolean;
  38846. OPACITYFRESNEL: boolean;
  38847. REFLECTIONFRESNEL: boolean;
  38848. REFRACTIONFRESNEL: boolean;
  38849. EMISSIVEFRESNEL: boolean;
  38850. FRESNEL: boolean;
  38851. NORMAL: boolean;
  38852. UV1: boolean;
  38853. UV2: boolean;
  38854. VERTEXCOLOR: boolean;
  38855. VERTEXALPHA: boolean;
  38856. NUM_BONE_INFLUENCERS: number;
  38857. BonesPerMesh: number;
  38858. BONETEXTURE: boolean;
  38859. INSTANCES: boolean;
  38860. GLOSSINESS: boolean;
  38861. ROUGHNESS: boolean;
  38862. EMISSIVEASILLUMINATION: boolean;
  38863. LINKEMISSIVEWITHDIFFUSE: boolean;
  38864. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38865. LIGHTMAP: boolean;
  38866. LIGHTMAPDIRECTUV: number;
  38867. OBJECTSPACE_NORMALMAP: boolean;
  38868. USELIGHTMAPASSHADOWMAP: boolean;
  38869. REFLECTIONMAP_3D: boolean;
  38870. REFLECTIONMAP_SPHERICAL: boolean;
  38871. REFLECTIONMAP_PLANAR: boolean;
  38872. REFLECTIONMAP_CUBIC: boolean;
  38873. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38874. REFLECTIONMAP_PROJECTION: boolean;
  38875. REFLECTIONMAP_SKYBOX: boolean;
  38876. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38877. REFLECTIONMAP_EXPLICIT: boolean;
  38878. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38879. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38880. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38881. INVERTCUBICMAP: boolean;
  38882. LOGARITHMICDEPTH: boolean;
  38883. REFRACTION: boolean;
  38884. REFRACTIONMAP_3D: boolean;
  38885. REFLECTIONOVERALPHA: boolean;
  38886. TWOSIDEDLIGHTING: boolean;
  38887. SHADOWFLOAT: boolean;
  38888. MORPHTARGETS: boolean;
  38889. MORPHTARGETS_NORMAL: boolean;
  38890. MORPHTARGETS_TANGENT: boolean;
  38891. NUM_MORPH_INFLUENCERS: number;
  38892. NONUNIFORMSCALING: boolean;
  38893. PREMULTIPLYALPHA: boolean;
  38894. IMAGEPROCESSING: boolean;
  38895. VIGNETTE: boolean;
  38896. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38897. VIGNETTEBLENDMODEOPAQUE: boolean;
  38898. TONEMAPPING: boolean;
  38899. TONEMAPPING_ACES: boolean;
  38900. CONTRAST: boolean;
  38901. COLORCURVES: boolean;
  38902. COLORGRADING: boolean;
  38903. COLORGRADING3D: boolean;
  38904. SAMPLER3DGREENDEPTH: boolean;
  38905. SAMPLER3DBGRMAP: boolean;
  38906. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38907. /**
  38908. * If the reflection texture on this material is in linear color space
  38909. * @hidden
  38910. */
  38911. IS_REFLECTION_LINEAR: boolean;
  38912. /**
  38913. * If the refraction texture on this material is in linear color space
  38914. * @hidden
  38915. */
  38916. IS_REFRACTION_LINEAR: boolean;
  38917. EXPOSURE: boolean;
  38918. constructor();
  38919. setReflectionMode(modeToEnable: string): void;
  38920. }
  38921. /**
  38922. * This is the default material used in Babylon. It is the best trade off between quality
  38923. * and performances.
  38924. * @see http://doc.babylonjs.com/babylon101/materials
  38925. */
  38926. export class StandardMaterial extends PushMaterial {
  38927. private _diffuseTexture;
  38928. /**
  38929. * The basic texture of the material as viewed under a light.
  38930. */
  38931. diffuseTexture: Nullable<BaseTexture>;
  38932. private _ambientTexture;
  38933. /**
  38934. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38935. */
  38936. ambientTexture: Nullable<BaseTexture>;
  38937. private _opacityTexture;
  38938. /**
  38939. * Define the transparency of the material from a texture.
  38940. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38941. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38942. */
  38943. opacityTexture: Nullable<BaseTexture>;
  38944. private _reflectionTexture;
  38945. /**
  38946. * Define the texture used to display the reflection.
  38947. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38948. */
  38949. reflectionTexture: Nullable<BaseTexture>;
  38950. private _emissiveTexture;
  38951. /**
  38952. * Define texture of the material as if self lit.
  38953. * This will be mixed in the final result even in the absence of light.
  38954. */
  38955. emissiveTexture: Nullable<BaseTexture>;
  38956. private _specularTexture;
  38957. /**
  38958. * Define how the color and intensity of the highlight given by the light in the material.
  38959. */
  38960. specularTexture: Nullable<BaseTexture>;
  38961. private _bumpTexture;
  38962. /**
  38963. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38964. * 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.
  38965. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38966. */
  38967. bumpTexture: Nullable<BaseTexture>;
  38968. private _lightmapTexture;
  38969. /**
  38970. * Complex lighting can be computationally expensive to compute at runtime.
  38971. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38972. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38973. */
  38974. lightmapTexture: Nullable<BaseTexture>;
  38975. private _refractionTexture;
  38976. /**
  38977. * Define the texture used to display the refraction.
  38978. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38979. */
  38980. refractionTexture: Nullable<BaseTexture>;
  38981. /**
  38982. * The color of the material lit by the environmental background lighting.
  38983. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38984. */
  38985. ambientColor: Color3;
  38986. /**
  38987. * The basic color of the material as viewed under a light.
  38988. */
  38989. diffuseColor: Color3;
  38990. /**
  38991. * Define how the color and intensity of the highlight given by the light in the material.
  38992. */
  38993. specularColor: Color3;
  38994. /**
  38995. * Define the color of the material as if self lit.
  38996. * This will be mixed in the final result even in the absence of light.
  38997. */
  38998. emissiveColor: Color3;
  38999. /**
  39000. * Defines how sharp are the highlights in the material.
  39001. * The bigger the value the sharper giving a more glossy feeling to the result.
  39002. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39003. */
  39004. specularPower: number;
  39005. private _useAlphaFromDiffuseTexture;
  39006. /**
  39007. * Does the transparency come from the diffuse texture alpha channel.
  39008. */
  39009. useAlphaFromDiffuseTexture: boolean;
  39010. private _useEmissiveAsIllumination;
  39011. /**
  39012. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39013. */
  39014. useEmissiveAsIllumination: boolean;
  39015. private _linkEmissiveWithDiffuse;
  39016. /**
  39017. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39018. * the emissive level when the final color is close to one.
  39019. */
  39020. linkEmissiveWithDiffuse: boolean;
  39021. private _useSpecularOverAlpha;
  39022. /**
  39023. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39024. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39025. */
  39026. useSpecularOverAlpha: boolean;
  39027. private _useReflectionOverAlpha;
  39028. /**
  39029. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39030. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39031. */
  39032. useReflectionOverAlpha: boolean;
  39033. private _disableLighting;
  39034. /**
  39035. * Does lights from the scene impacts this material.
  39036. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39037. */
  39038. disableLighting: boolean;
  39039. private _useObjectSpaceNormalMap;
  39040. /**
  39041. * Allows using an object space normal map (instead of tangent space).
  39042. */
  39043. useObjectSpaceNormalMap: boolean;
  39044. private _useParallax;
  39045. /**
  39046. * Is parallax enabled or not.
  39047. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39048. */
  39049. useParallax: boolean;
  39050. private _useParallaxOcclusion;
  39051. /**
  39052. * Is parallax occlusion enabled or not.
  39053. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39054. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39055. */
  39056. useParallaxOcclusion: boolean;
  39057. /**
  39058. * 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.
  39059. */
  39060. parallaxScaleBias: number;
  39061. private _roughness;
  39062. /**
  39063. * Helps to define how blurry the reflections should appears in the material.
  39064. */
  39065. roughness: number;
  39066. /**
  39067. * In case of refraction, define the value of the indice of refraction.
  39068. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39069. */
  39070. indexOfRefraction: number;
  39071. /**
  39072. * Invert the refraction texture alongside the y axis.
  39073. * It can be useful with procedural textures or probe for instance.
  39074. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39075. */
  39076. invertRefractionY: boolean;
  39077. /**
  39078. * Defines the alpha limits in alpha test mode.
  39079. */
  39080. alphaCutOff: number;
  39081. private _useLightmapAsShadowmap;
  39082. /**
  39083. * In case of light mapping, define whether the map contains light or shadow informations.
  39084. */
  39085. useLightmapAsShadowmap: boolean;
  39086. private _diffuseFresnelParameters;
  39087. /**
  39088. * Define the diffuse fresnel parameters of the material.
  39089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39090. */
  39091. diffuseFresnelParameters: FresnelParameters;
  39092. private _opacityFresnelParameters;
  39093. /**
  39094. * Define the opacity fresnel parameters of the material.
  39095. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39096. */
  39097. opacityFresnelParameters: FresnelParameters;
  39098. private _reflectionFresnelParameters;
  39099. /**
  39100. * Define the reflection fresnel parameters of the material.
  39101. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39102. */
  39103. reflectionFresnelParameters: FresnelParameters;
  39104. private _refractionFresnelParameters;
  39105. /**
  39106. * Define the refraction fresnel parameters of the material.
  39107. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39108. */
  39109. refractionFresnelParameters: FresnelParameters;
  39110. private _emissiveFresnelParameters;
  39111. /**
  39112. * Define the emissive fresnel parameters of the material.
  39113. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39114. */
  39115. emissiveFresnelParameters: FresnelParameters;
  39116. private _useReflectionFresnelFromSpecular;
  39117. /**
  39118. * If true automatically deducts the fresnels values from the material specularity.
  39119. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39120. */
  39121. useReflectionFresnelFromSpecular: boolean;
  39122. private _useGlossinessFromSpecularMapAlpha;
  39123. /**
  39124. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39125. */
  39126. useGlossinessFromSpecularMapAlpha: boolean;
  39127. private _maxSimultaneousLights;
  39128. /**
  39129. * Defines the maximum number of lights that can be used in the material
  39130. */
  39131. maxSimultaneousLights: number;
  39132. private _invertNormalMapX;
  39133. /**
  39134. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39135. */
  39136. invertNormalMapX: boolean;
  39137. private _invertNormalMapY;
  39138. /**
  39139. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39140. */
  39141. invertNormalMapY: boolean;
  39142. private _twoSidedLighting;
  39143. /**
  39144. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39145. */
  39146. twoSidedLighting: boolean;
  39147. /**
  39148. * Default configuration related to image processing available in the standard Material.
  39149. */
  39150. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39151. /**
  39152. * Gets the image processing configuration used either in this material.
  39153. */
  39154. /**
  39155. * Sets the Default image processing configuration used either in the this material.
  39156. *
  39157. * If sets to null, the scene one is in use.
  39158. */
  39159. imageProcessingConfiguration: ImageProcessingConfiguration;
  39160. /**
  39161. * Keep track of the image processing observer to allow dispose and replace.
  39162. */
  39163. private _imageProcessingObserver;
  39164. /**
  39165. * Attaches a new image processing configuration to the Standard Material.
  39166. * @param configuration
  39167. */
  39168. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39169. /**
  39170. * Gets wether the color curves effect is enabled.
  39171. */
  39172. /**
  39173. * Sets wether the color curves effect is enabled.
  39174. */
  39175. cameraColorCurvesEnabled: boolean;
  39176. /**
  39177. * Gets wether the color grading effect is enabled.
  39178. */
  39179. /**
  39180. * Gets wether the color grading effect is enabled.
  39181. */
  39182. cameraColorGradingEnabled: boolean;
  39183. /**
  39184. * Gets wether tonemapping is enabled or not.
  39185. */
  39186. /**
  39187. * Sets wether tonemapping is enabled or not
  39188. */
  39189. cameraToneMappingEnabled: boolean;
  39190. /**
  39191. * The camera exposure used on this material.
  39192. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39193. * This corresponds to a photographic exposure.
  39194. */
  39195. /**
  39196. * The camera exposure used on this material.
  39197. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39198. * This corresponds to a photographic exposure.
  39199. */
  39200. cameraExposure: number;
  39201. /**
  39202. * Gets The camera contrast used on this material.
  39203. */
  39204. /**
  39205. * Sets The camera contrast used on this material.
  39206. */
  39207. cameraContrast: number;
  39208. /**
  39209. * Gets the Color Grading 2D Lookup Texture.
  39210. */
  39211. /**
  39212. * Sets the Color Grading 2D Lookup Texture.
  39213. */
  39214. cameraColorGradingTexture: Nullable<BaseTexture>;
  39215. /**
  39216. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39217. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39218. * 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;
  39219. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39220. */
  39221. /**
  39222. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39223. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39224. * 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;
  39225. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39226. */
  39227. cameraColorCurves: Nullable<ColorCurves>;
  39228. /**
  39229. * Custom callback helping to override the default shader used in the material.
  39230. */
  39231. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39232. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39233. protected _worldViewProjectionMatrix: Matrix;
  39234. protected _globalAmbientColor: Color3;
  39235. protected _useLogarithmicDepth: boolean;
  39236. /**
  39237. * Instantiates a new standard material.
  39238. * This is the default material used in Babylon. It is the best trade off between quality
  39239. * and performances.
  39240. * @see http://doc.babylonjs.com/babylon101/materials
  39241. * @param name Define the name of the material in the scene
  39242. * @param scene Define the scene the material belong to
  39243. */
  39244. constructor(name: string, scene: Scene);
  39245. /**
  39246. * Gets a boolean indicating that current material needs to register RTT
  39247. */
  39248. readonly hasRenderTargetTextures: boolean;
  39249. /**
  39250. * Gets the current class name of the material e.g. "StandardMaterial"
  39251. * Mainly use in serialization.
  39252. * @returns the class name
  39253. */
  39254. getClassName(): string;
  39255. /**
  39256. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39257. * You can try switching to logarithmic depth.
  39258. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39259. */
  39260. useLogarithmicDepth: boolean;
  39261. /**
  39262. * Specifies if the material will require alpha blending
  39263. * @returns a boolean specifying if alpha blending is needed
  39264. */
  39265. needAlphaBlending(): boolean;
  39266. /**
  39267. * Specifies if this material should be rendered in alpha test mode
  39268. * @returns a boolean specifying if an alpha test is needed.
  39269. */
  39270. needAlphaTesting(): boolean;
  39271. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39272. /**
  39273. * Get the texture used for alpha test purpose.
  39274. * @returns the diffuse texture in case of the standard material.
  39275. */
  39276. getAlphaTestTexture(): Nullable<BaseTexture>;
  39277. /**
  39278. * Get if the submesh is ready to be used and all its information available.
  39279. * Child classes can use it to update shaders
  39280. * @param mesh defines the mesh to check
  39281. * @param subMesh defines which submesh to check
  39282. * @param useInstances specifies that instances should be used
  39283. * @returns a boolean indicating that the submesh is ready or not
  39284. */
  39285. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39286. /**
  39287. * Builds the material UBO layouts.
  39288. * Used internally during the effect preparation.
  39289. */
  39290. buildUniformLayout(): void;
  39291. /**
  39292. * Unbinds the material from the mesh
  39293. */
  39294. unbind(): void;
  39295. /**
  39296. * Binds the submesh to this material by preparing the effect and shader to draw
  39297. * @param world defines the world transformation matrix
  39298. * @param mesh defines the mesh containing the submesh
  39299. * @param subMesh defines the submesh to bind the material to
  39300. */
  39301. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39302. /**
  39303. * Get the list of animatables in the material.
  39304. * @returns the list of animatables object used in the material
  39305. */
  39306. getAnimatables(): IAnimatable[];
  39307. /**
  39308. * Gets the active textures from the material
  39309. * @returns an array of textures
  39310. */
  39311. getActiveTextures(): BaseTexture[];
  39312. /**
  39313. * Specifies if the material uses a texture
  39314. * @param texture defines the texture to check against the material
  39315. * @returns a boolean specifying if the material uses the texture
  39316. */
  39317. hasTexture(texture: BaseTexture): boolean;
  39318. /**
  39319. * Disposes the material
  39320. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39321. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39322. */
  39323. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39324. /**
  39325. * Makes a duplicate of the material, and gives it a new name
  39326. * @param name defines the new name for the duplicated material
  39327. * @returns the cloned material
  39328. */
  39329. clone(name: string): StandardMaterial;
  39330. /**
  39331. * Serializes this material in a JSON representation
  39332. * @returns the serialized material object
  39333. */
  39334. serialize(): any;
  39335. /**
  39336. * Creates a standard material from parsed material data
  39337. * @param source defines the JSON representation of the material
  39338. * @param scene defines the hosting scene
  39339. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39340. * @returns a new standard material
  39341. */
  39342. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39343. /**
  39344. * Are diffuse textures enabled in the application.
  39345. */
  39346. static DiffuseTextureEnabled: boolean;
  39347. /**
  39348. * Are ambient textures enabled in the application.
  39349. */
  39350. static AmbientTextureEnabled: boolean;
  39351. /**
  39352. * Are opacity textures enabled in the application.
  39353. */
  39354. static OpacityTextureEnabled: boolean;
  39355. /**
  39356. * Are reflection textures enabled in the application.
  39357. */
  39358. static ReflectionTextureEnabled: boolean;
  39359. /**
  39360. * Are emissive textures enabled in the application.
  39361. */
  39362. static EmissiveTextureEnabled: boolean;
  39363. /**
  39364. * Are specular textures enabled in the application.
  39365. */
  39366. static SpecularTextureEnabled: boolean;
  39367. /**
  39368. * Are bump textures enabled in the application.
  39369. */
  39370. static BumpTextureEnabled: boolean;
  39371. /**
  39372. * Are lightmap textures enabled in the application.
  39373. */
  39374. static LightmapTextureEnabled: boolean;
  39375. /**
  39376. * Are refraction textures enabled in the application.
  39377. */
  39378. static RefractionTextureEnabled: boolean;
  39379. /**
  39380. * Are color grading textures enabled in the application.
  39381. */
  39382. static ColorGradingTextureEnabled: boolean;
  39383. /**
  39384. * Are fresnels enabled in the application.
  39385. */
  39386. static FresnelEnabled: boolean;
  39387. }
  39388. }
  39389. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39390. import { Scene } from "babylonjs/scene";
  39391. import { Texture } from "babylonjs/Materials/Textures/texture";
  39392. /**
  39393. * A class extending Texture allowing drawing on a texture
  39394. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39395. */
  39396. export class DynamicTexture extends Texture {
  39397. private _generateMipMaps;
  39398. private _canvas;
  39399. private _context;
  39400. private _engine;
  39401. /**
  39402. * Creates a DynamicTexture
  39403. * @param name defines the name of the texture
  39404. * @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
  39405. * @param scene defines the scene where you want the texture
  39406. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39407. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39408. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39409. */
  39410. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39411. /**
  39412. * Get the current class name of the texture useful for serialization or dynamic coding.
  39413. * @returns "DynamicTexture"
  39414. */
  39415. getClassName(): string;
  39416. /**
  39417. * Gets the current state of canRescale
  39418. */
  39419. readonly canRescale: boolean;
  39420. private _recreate;
  39421. /**
  39422. * Scales the texture
  39423. * @param ratio the scale factor to apply to both width and height
  39424. */
  39425. scale(ratio: number): void;
  39426. /**
  39427. * Resizes the texture
  39428. * @param width the new width
  39429. * @param height the new height
  39430. */
  39431. scaleTo(width: number, height: number): void;
  39432. /**
  39433. * Gets the context of the canvas used by the texture
  39434. * @returns the canvas context of the dynamic texture
  39435. */
  39436. getContext(): CanvasRenderingContext2D;
  39437. /**
  39438. * Clears the texture
  39439. */
  39440. clear(): void;
  39441. /**
  39442. * Updates the texture
  39443. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39444. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39445. */
  39446. update(invertY?: boolean, premulAlpha?: boolean): void;
  39447. /**
  39448. * Draws text onto the texture
  39449. * @param text defines the text to be drawn
  39450. * @param x defines the placement of the text from the left
  39451. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39452. * @param font defines the font to be used with font-style, font-size, font-name
  39453. * @param color defines the color used for the text
  39454. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39455. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39456. * @param update defines whether texture is immediately update (default is true)
  39457. */
  39458. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39459. /**
  39460. * Clones the texture
  39461. * @returns the clone of the texture.
  39462. */
  39463. clone(): DynamicTexture;
  39464. /**
  39465. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39466. * @returns a serialized dynamic texture object
  39467. */
  39468. serialize(): any;
  39469. /** @hidden */
  39470. _rebuild(): void;
  39471. }
  39472. }
  39473. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39474. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39476. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39477. /** @hidden */
  39478. export var imageProcessingPixelShader: {
  39479. name: string;
  39480. shader: string;
  39481. };
  39482. }
  39483. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39484. import { Nullable } from "babylonjs/types";
  39485. import { Color4 } from "babylonjs/Maths/math";
  39486. import { Camera } from "babylonjs/Cameras/camera";
  39487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39488. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39489. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39490. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39491. import { Engine } from "babylonjs/Engines/engine";
  39492. import "babylonjs/Shaders/imageProcessing.fragment";
  39493. import "babylonjs/Shaders/postprocess.vertex";
  39494. /**
  39495. * ImageProcessingPostProcess
  39496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39497. */
  39498. export class ImageProcessingPostProcess extends PostProcess {
  39499. /**
  39500. * Default configuration related to image processing available in the PBR Material.
  39501. */
  39502. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39503. /**
  39504. * Gets the image processing configuration used either in this material.
  39505. */
  39506. /**
  39507. * Sets the Default image processing configuration used either in the this material.
  39508. *
  39509. * If sets to null, the scene one is in use.
  39510. */
  39511. imageProcessingConfiguration: ImageProcessingConfiguration;
  39512. /**
  39513. * Keep track of the image processing observer to allow dispose and replace.
  39514. */
  39515. private _imageProcessingObserver;
  39516. /**
  39517. * Attaches a new image processing configuration to the PBR Material.
  39518. * @param configuration
  39519. */
  39520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39521. /**
  39522. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39523. */
  39524. /**
  39525. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39526. */
  39527. colorCurves: Nullable<ColorCurves>;
  39528. /**
  39529. * Gets wether the color curves effect is enabled.
  39530. */
  39531. /**
  39532. * Sets wether the color curves effect is enabled.
  39533. */
  39534. colorCurvesEnabled: boolean;
  39535. /**
  39536. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39537. */
  39538. /**
  39539. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39540. */
  39541. colorGradingTexture: Nullable<BaseTexture>;
  39542. /**
  39543. * Gets wether the color grading effect is enabled.
  39544. */
  39545. /**
  39546. * Gets wether the color grading effect is enabled.
  39547. */
  39548. colorGradingEnabled: boolean;
  39549. /**
  39550. * Gets exposure used in the effect.
  39551. */
  39552. /**
  39553. * Sets exposure used in the effect.
  39554. */
  39555. exposure: number;
  39556. /**
  39557. * Gets wether tonemapping is enabled or not.
  39558. */
  39559. /**
  39560. * Sets wether tonemapping is enabled or not
  39561. */
  39562. toneMappingEnabled: boolean;
  39563. /**
  39564. * Gets the type of tone mapping effect.
  39565. */
  39566. /**
  39567. * Sets the type of tone mapping effect.
  39568. */
  39569. toneMappingType: number;
  39570. /**
  39571. * Gets contrast used in the effect.
  39572. */
  39573. /**
  39574. * Sets contrast used in the effect.
  39575. */
  39576. contrast: number;
  39577. /**
  39578. * Gets Vignette stretch size.
  39579. */
  39580. /**
  39581. * Sets Vignette stretch size.
  39582. */
  39583. vignetteStretch: number;
  39584. /**
  39585. * Gets Vignette centre X Offset.
  39586. */
  39587. /**
  39588. * Sets Vignette centre X Offset.
  39589. */
  39590. vignetteCentreX: number;
  39591. /**
  39592. * Gets Vignette centre Y Offset.
  39593. */
  39594. /**
  39595. * Sets Vignette centre Y Offset.
  39596. */
  39597. vignetteCentreY: number;
  39598. /**
  39599. * Gets Vignette weight or intensity of the vignette effect.
  39600. */
  39601. /**
  39602. * Sets Vignette weight or intensity of the vignette effect.
  39603. */
  39604. vignetteWeight: number;
  39605. /**
  39606. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39607. * if vignetteEnabled is set to true.
  39608. */
  39609. /**
  39610. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39611. * if vignetteEnabled is set to true.
  39612. */
  39613. vignetteColor: Color4;
  39614. /**
  39615. * Gets Camera field of view used by the Vignette effect.
  39616. */
  39617. /**
  39618. * Sets Camera field of view used by the Vignette effect.
  39619. */
  39620. vignetteCameraFov: number;
  39621. /**
  39622. * Gets the vignette blend mode allowing different kind of effect.
  39623. */
  39624. /**
  39625. * Sets the vignette blend mode allowing different kind of effect.
  39626. */
  39627. vignetteBlendMode: number;
  39628. /**
  39629. * Gets wether the vignette effect is enabled.
  39630. */
  39631. /**
  39632. * Sets wether the vignette effect is enabled.
  39633. */
  39634. vignetteEnabled: boolean;
  39635. private _fromLinearSpace;
  39636. /**
  39637. * Gets wether the input of the processing is in Gamma or Linear Space.
  39638. */
  39639. /**
  39640. * Sets wether the input of the processing is in Gamma or Linear Space.
  39641. */
  39642. fromLinearSpace: boolean;
  39643. /**
  39644. * Defines cache preventing GC.
  39645. */
  39646. private _defines;
  39647. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39648. /**
  39649. * "ImageProcessingPostProcess"
  39650. * @returns "ImageProcessingPostProcess"
  39651. */
  39652. getClassName(): string;
  39653. protected _updateParameters(): void;
  39654. dispose(camera?: Camera): void;
  39655. }
  39656. }
  39657. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39658. import { Scene } from "babylonjs/scene";
  39659. import { Color3 } from "babylonjs/Maths/math";
  39660. import { Mesh } from "babylonjs/Meshes/mesh";
  39661. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39662. /**
  39663. * Class containing static functions to help procedurally build meshes
  39664. */
  39665. export class GroundBuilder {
  39666. /**
  39667. * Creates a ground mesh
  39668. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39669. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39671. * @param name defines the name of the mesh
  39672. * @param options defines the options used to create the mesh
  39673. * @param scene defines the hosting scene
  39674. * @returns the ground mesh
  39675. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39676. */
  39677. static CreateGround(name: string, options: {
  39678. width?: number;
  39679. height?: number;
  39680. subdivisions?: number;
  39681. subdivisionsX?: number;
  39682. subdivisionsY?: number;
  39683. updatable?: boolean;
  39684. }, scene: any): Mesh;
  39685. /**
  39686. * Creates a tiled ground mesh
  39687. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39688. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39689. * * 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
  39690. * * 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
  39691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39692. * @param name defines the name of the mesh
  39693. * @param options defines the options used to create the mesh
  39694. * @param scene defines the hosting scene
  39695. * @returns the tiled ground mesh
  39696. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39697. */
  39698. static CreateTiledGround(name: string, options: {
  39699. xmin: number;
  39700. zmin: number;
  39701. xmax: number;
  39702. zmax: number;
  39703. subdivisions?: {
  39704. w: number;
  39705. h: number;
  39706. };
  39707. precision?: {
  39708. w: number;
  39709. h: number;
  39710. };
  39711. updatable?: boolean;
  39712. }, scene: Scene): Mesh;
  39713. /**
  39714. * Creates a ground mesh from a height map
  39715. * * The parameter `url` sets the URL of the height map image resource.
  39716. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39717. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39718. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39719. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39720. * * 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.
  39721. * * 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).
  39722. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39724. * @param name defines the name of the mesh
  39725. * @param url defines the url to the height map
  39726. * @param options defines the options used to create the mesh
  39727. * @param scene defines the hosting scene
  39728. * @returns the ground mesh
  39729. * @see https://doc.babylonjs.com/babylon101/height_map
  39730. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39731. */
  39732. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39733. width?: number;
  39734. height?: number;
  39735. subdivisions?: number;
  39736. minHeight?: number;
  39737. maxHeight?: number;
  39738. colorFilter?: Color3;
  39739. alphaFilter?: number;
  39740. updatable?: boolean;
  39741. onReady?: (mesh: GroundMesh) => void;
  39742. }, scene: Scene): GroundMesh;
  39743. }
  39744. }
  39745. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39746. import { Vector4 } from "babylonjs/Maths/math";
  39747. import { Mesh } from "babylonjs/Meshes/mesh";
  39748. /**
  39749. * Class containing static functions to help procedurally build meshes
  39750. */
  39751. export class TorusBuilder {
  39752. /**
  39753. * Creates a torus mesh
  39754. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39755. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39756. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39758. * * If you create a double-sided mesh, you can choose what parts of 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
  39759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39760. * @param name defines the name of the mesh
  39761. * @param options defines the options used to create the mesh
  39762. * @param scene defines the hosting scene
  39763. * @returns the torus mesh
  39764. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39765. */
  39766. static CreateTorus(name: string, options: {
  39767. diameter?: number;
  39768. thickness?: number;
  39769. tessellation?: number;
  39770. updatable?: boolean;
  39771. sideOrientation?: number;
  39772. frontUVs?: Vector4;
  39773. backUVs?: Vector4;
  39774. }, scene: any): Mesh;
  39775. }
  39776. }
  39777. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39778. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39779. import { Mesh } from "babylonjs/Meshes/mesh";
  39780. /**
  39781. * Class containing static functions to help procedurally build meshes
  39782. */
  39783. export class CylinderBuilder {
  39784. /**
  39785. * Creates a cylinder or a cone mesh
  39786. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39787. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39788. * * 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.
  39789. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39790. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39791. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39792. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39793. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39794. * * 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).
  39795. * * 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
  39796. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39797. * * 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
  39798. * * 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.
  39799. * * If `enclose` is false, a ring surface is one element.
  39800. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39801. * * 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
  39802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39803. * * If you create a double-sided mesh, you can choose what parts of 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
  39804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39805. * @param name defines the name of the mesh
  39806. * @param options defines the options used to create the mesh
  39807. * @param scene defines the hosting scene
  39808. * @returns the cylinder mesh
  39809. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39810. */
  39811. static CreateCylinder(name: string, options: {
  39812. height?: number;
  39813. diameterTop?: number;
  39814. diameterBottom?: number;
  39815. diameter?: number;
  39816. tessellation?: number;
  39817. subdivisions?: number;
  39818. arc?: number;
  39819. faceColors?: Color4[];
  39820. faceUV?: Vector4[];
  39821. updatable?: boolean;
  39822. hasRings?: boolean;
  39823. enclose?: boolean;
  39824. sideOrientation?: number;
  39825. frontUVs?: Vector4;
  39826. backUVs?: Vector4;
  39827. }, scene: any): Mesh;
  39828. }
  39829. }
  39830. declare module "babylonjs/Gamepads/gamepadManager" {
  39831. import { Observable } from "babylonjs/Misc/observable";
  39832. import { Nullable } from "babylonjs/types";
  39833. import { Scene } from "babylonjs/scene";
  39834. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39835. /**
  39836. * Manager for handling gamepads
  39837. */
  39838. export class GamepadManager {
  39839. private _scene?;
  39840. private _babylonGamepads;
  39841. private _oneGamepadConnected;
  39842. /** @hidden */
  39843. _isMonitoring: boolean;
  39844. private _gamepadEventSupported;
  39845. private _gamepadSupport;
  39846. /**
  39847. * observable to be triggered when the gamepad controller has been connected
  39848. */
  39849. onGamepadConnectedObservable: Observable<Gamepad>;
  39850. /**
  39851. * observable to be triggered when the gamepad controller has been disconnected
  39852. */
  39853. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39854. private _onGamepadConnectedEvent;
  39855. private _onGamepadDisconnectedEvent;
  39856. /**
  39857. * Initializes the gamepad manager
  39858. * @param _scene BabylonJS scene
  39859. */
  39860. constructor(_scene?: Scene | undefined);
  39861. /**
  39862. * The gamepads in the game pad manager
  39863. */
  39864. readonly gamepads: Gamepad[];
  39865. /**
  39866. * Get the gamepad controllers based on type
  39867. * @param type The type of gamepad controller
  39868. * @returns Nullable gamepad
  39869. */
  39870. getGamepadByType(type?: number): Nullable<Gamepad>;
  39871. /**
  39872. * Disposes the gamepad manager
  39873. */
  39874. dispose(): void;
  39875. private _addNewGamepad;
  39876. private _startMonitoringGamepads;
  39877. private _stopMonitoringGamepads;
  39878. /** @hidden */
  39879. _checkGamepadsStatus(): void;
  39880. private _updateGamepadObjects;
  39881. }
  39882. }
  39883. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39884. import { Nullable } from "babylonjs/types";
  39885. import { Scene } from "babylonjs/scene";
  39886. import { ISceneComponent } from "babylonjs/sceneComponent";
  39887. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39888. module "babylonjs/scene" {
  39889. interface Scene {
  39890. /** @hidden */
  39891. _gamepadManager: Nullable<GamepadManager>;
  39892. /**
  39893. * Gets the gamepad manager associated with the scene
  39894. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39895. */
  39896. gamepadManager: GamepadManager;
  39897. }
  39898. }
  39899. module "babylonjs/Cameras/freeCameraInputsManager" {
  39900. /**
  39901. * Interface representing a free camera inputs manager
  39902. */
  39903. interface FreeCameraInputsManager {
  39904. /**
  39905. * Adds gamepad input support to the FreeCameraInputsManager.
  39906. * @returns the FreeCameraInputsManager
  39907. */
  39908. addGamepad(): FreeCameraInputsManager;
  39909. }
  39910. }
  39911. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39912. /**
  39913. * Interface representing an arc rotate camera inputs manager
  39914. */
  39915. interface ArcRotateCameraInputsManager {
  39916. /**
  39917. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39918. * @returns the camera inputs manager
  39919. */
  39920. addGamepad(): ArcRotateCameraInputsManager;
  39921. }
  39922. }
  39923. /**
  39924. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39925. */
  39926. export class GamepadSystemSceneComponent implements ISceneComponent {
  39927. /**
  39928. * The component name helpfull to identify the component in the list of scene components.
  39929. */
  39930. readonly name: string;
  39931. /**
  39932. * The scene the component belongs to.
  39933. */
  39934. scene: Scene;
  39935. /**
  39936. * Creates a new instance of the component for the given scene
  39937. * @param scene Defines the scene to register the component in
  39938. */
  39939. constructor(scene: Scene);
  39940. /**
  39941. * Registers the component in a given scene
  39942. */
  39943. register(): void;
  39944. /**
  39945. * Rebuilds the elements related to this component in case of
  39946. * context lost for instance.
  39947. */
  39948. rebuild(): void;
  39949. /**
  39950. * Disposes the component and the associated ressources
  39951. */
  39952. dispose(): void;
  39953. private _beforeCameraUpdate;
  39954. }
  39955. }
  39956. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39957. import { Observable } from "babylonjs/Misc/observable";
  39958. import { Nullable } from "babylonjs/types";
  39959. import { Camera } from "babylonjs/Cameras/camera";
  39960. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39961. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39962. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39963. import { Scene } from "babylonjs/scene";
  39964. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39965. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39967. import { Mesh } from "babylonjs/Meshes/mesh";
  39968. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39969. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39970. import "babylonjs/Meshes/Builders/groundBuilder";
  39971. import "babylonjs/Meshes/Builders/torusBuilder";
  39972. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39973. import "babylonjs/Gamepads/gamepadSceneComponent";
  39974. import "babylonjs/Animations/animatable";
  39975. /**
  39976. * Options to modify the vr teleportation behavior.
  39977. */
  39978. export interface VRTeleportationOptions {
  39979. /**
  39980. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39981. */
  39982. floorMeshName?: string;
  39983. /**
  39984. * A list of meshes to be used as the teleportation floor. (default: empty)
  39985. */
  39986. floorMeshes?: Mesh[];
  39987. }
  39988. /**
  39989. * Options to modify the vr experience helper's behavior.
  39990. */
  39991. export interface VRExperienceHelperOptions extends WebVROptions {
  39992. /**
  39993. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39994. */
  39995. createDeviceOrientationCamera?: boolean;
  39996. /**
  39997. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39998. */
  39999. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40000. /**
  40001. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40002. */
  40003. laserToggle?: boolean;
  40004. /**
  40005. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40006. */
  40007. floorMeshes?: Mesh[];
  40008. /**
  40009. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40010. */
  40011. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40012. }
  40013. /**
  40014. * Event containing information after VR has been entered
  40015. */
  40016. export class OnAfterEnteringVRObservableEvent {
  40017. /**
  40018. * If entering vr was successful
  40019. */
  40020. success: boolean;
  40021. }
  40022. /**
  40023. * Helps to quickly add VR support to an existing scene.
  40024. * See http://doc.babylonjs.com/how_to/webvr_helper
  40025. */
  40026. export class VRExperienceHelper {
  40027. /** Options to modify the vr experience helper's behavior. */
  40028. webVROptions: VRExperienceHelperOptions;
  40029. private _scene;
  40030. private _position;
  40031. private _btnVR;
  40032. private _btnVRDisplayed;
  40033. private _webVRsupported;
  40034. private _webVRready;
  40035. private _webVRrequesting;
  40036. private _webVRpresenting;
  40037. private _hasEnteredVR;
  40038. private _fullscreenVRpresenting;
  40039. private _canvas;
  40040. private _webVRCamera;
  40041. private _vrDeviceOrientationCamera;
  40042. private _deviceOrientationCamera;
  40043. private _existingCamera;
  40044. private _onKeyDown;
  40045. private _onVrDisplayPresentChange;
  40046. private _onVRDisplayChanged;
  40047. private _onVRRequestPresentStart;
  40048. private _onVRRequestPresentComplete;
  40049. /**
  40050. * Observable raised right before entering VR.
  40051. */
  40052. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40053. /**
  40054. * Observable raised when entering VR has completed.
  40055. */
  40056. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40057. /**
  40058. * Observable raised when exiting VR.
  40059. */
  40060. onExitingVRObservable: Observable<VRExperienceHelper>;
  40061. /**
  40062. * Observable raised when controller mesh is loaded.
  40063. */
  40064. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40065. /** Return this.onEnteringVRObservable
  40066. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40067. */
  40068. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40069. /** Return this.onExitingVRObservable
  40070. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40071. */
  40072. readonly onExitingVR: Observable<VRExperienceHelper>;
  40073. /** Return this.onControllerMeshLoadedObservable
  40074. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40075. */
  40076. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40077. private _rayLength;
  40078. private _useCustomVRButton;
  40079. private _teleportationRequested;
  40080. private _teleportActive;
  40081. private _floorMeshName;
  40082. private _floorMeshesCollection;
  40083. private _rotationAllowed;
  40084. private _teleportBackwardsVector;
  40085. private _teleportationTarget;
  40086. private _isDefaultTeleportationTarget;
  40087. private _postProcessMove;
  40088. private _teleportationFillColor;
  40089. private _teleportationBorderColor;
  40090. private _rotationAngle;
  40091. private _haloCenter;
  40092. private _cameraGazer;
  40093. private _padSensibilityUp;
  40094. private _padSensibilityDown;
  40095. private _leftController;
  40096. private _rightController;
  40097. /**
  40098. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40099. */
  40100. onNewMeshSelected: Observable<AbstractMesh>;
  40101. /**
  40102. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40103. */
  40104. onNewMeshPicked: Observable<PickingInfo>;
  40105. private _circleEase;
  40106. /**
  40107. * Observable raised before camera teleportation
  40108. */
  40109. onBeforeCameraTeleport: Observable<Vector3>;
  40110. /**
  40111. * Observable raised after camera teleportation
  40112. */
  40113. onAfterCameraTeleport: Observable<Vector3>;
  40114. /**
  40115. * Observable raised when current selected mesh gets unselected
  40116. */
  40117. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40118. private _raySelectionPredicate;
  40119. /**
  40120. * To be optionaly changed by user to define custom ray selection
  40121. */
  40122. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40123. /**
  40124. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40125. */
  40126. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40127. /**
  40128. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40129. */
  40130. teleportationEnabled: boolean;
  40131. private _defaultHeight;
  40132. private _teleportationInitialized;
  40133. private _interactionsEnabled;
  40134. private _interactionsRequested;
  40135. private _displayGaze;
  40136. private _displayLaserPointer;
  40137. /**
  40138. * The mesh used to display where the user is going to teleport.
  40139. */
  40140. /**
  40141. * Sets the mesh to be used to display where the user is going to teleport.
  40142. */
  40143. teleportationTarget: Mesh;
  40144. /**
  40145. * 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
  40146. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40147. * See http://doc.babylonjs.com/resources/baking_transformations
  40148. */
  40149. gazeTrackerMesh: Mesh;
  40150. /**
  40151. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40152. */
  40153. updateGazeTrackerScale: boolean;
  40154. /**
  40155. * If the gaze trackers color should be updated when selecting meshes
  40156. */
  40157. updateGazeTrackerColor: boolean;
  40158. /**
  40159. * The gaze tracking mesh corresponding to the left controller
  40160. */
  40161. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40162. /**
  40163. * The gaze tracking mesh corresponding to the right controller
  40164. */
  40165. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40166. /**
  40167. * If the ray of the gaze should be displayed.
  40168. */
  40169. /**
  40170. * Sets if the ray of the gaze should be displayed.
  40171. */
  40172. displayGaze: boolean;
  40173. /**
  40174. * If the ray of the LaserPointer should be displayed.
  40175. */
  40176. /**
  40177. * Sets if the ray of the LaserPointer should be displayed.
  40178. */
  40179. displayLaserPointer: boolean;
  40180. /**
  40181. * The deviceOrientationCamera used as the camera when not in VR.
  40182. */
  40183. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40184. /**
  40185. * Based on the current WebVR support, returns the current VR camera used.
  40186. */
  40187. readonly currentVRCamera: Nullable<Camera>;
  40188. /**
  40189. * The webVRCamera which is used when in VR.
  40190. */
  40191. readonly webVRCamera: WebVRFreeCamera;
  40192. /**
  40193. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40194. */
  40195. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40196. private readonly _teleportationRequestInitiated;
  40197. /**
  40198. * Defines wether or not Pointer lock should be requested when switching to
  40199. * full screen.
  40200. */
  40201. requestPointerLockOnFullScreen: boolean;
  40202. /**
  40203. * Instantiates a VRExperienceHelper.
  40204. * Helps to quickly add VR support to an existing scene.
  40205. * @param scene The scene the VRExperienceHelper belongs to.
  40206. * @param webVROptions Options to modify the vr experience helper's behavior.
  40207. */
  40208. constructor(scene: Scene,
  40209. /** Options to modify the vr experience helper's behavior. */
  40210. webVROptions?: VRExperienceHelperOptions);
  40211. private _onDefaultMeshLoaded;
  40212. private _onResize;
  40213. private _onFullscreenChange;
  40214. /**
  40215. * Gets a value indicating if we are currently in VR mode.
  40216. */
  40217. readonly isInVRMode: boolean;
  40218. private onVrDisplayPresentChange;
  40219. private onVRDisplayChanged;
  40220. private moveButtonToBottomRight;
  40221. private displayVRButton;
  40222. private updateButtonVisibility;
  40223. private _cachedAngularSensibility;
  40224. /**
  40225. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40226. * Otherwise, will use the fullscreen API.
  40227. */
  40228. enterVR(): void;
  40229. /**
  40230. * Attempt to exit VR, or fullscreen.
  40231. */
  40232. exitVR(): void;
  40233. /**
  40234. * The position of the vr experience helper.
  40235. */
  40236. /**
  40237. * Sets the position of the vr experience helper.
  40238. */
  40239. position: Vector3;
  40240. /**
  40241. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40242. */
  40243. enableInteractions(): void;
  40244. private readonly _noControllerIsActive;
  40245. private beforeRender;
  40246. private _isTeleportationFloor;
  40247. /**
  40248. * Adds a floor mesh to be used for teleportation.
  40249. * @param floorMesh the mesh to be used for teleportation.
  40250. */
  40251. addFloorMesh(floorMesh: Mesh): void;
  40252. /**
  40253. * Removes a floor mesh from being used for teleportation.
  40254. * @param floorMesh the mesh to be removed.
  40255. */
  40256. removeFloorMesh(floorMesh: Mesh): void;
  40257. /**
  40258. * Enables interactions and teleportation using the VR controllers and gaze.
  40259. * @param vrTeleportationOptions options to modify teleportation behavior.
  40260. */
  40261. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40262. private _onNewGamepadConnected;
  40263. private _tryEnableInteractionOnController;
  40264. private _onNewGamepadDisconnected;
  40265. private _enableInteractionOnController;
  40266. private _checkTeleportWithRay;
  40267. private _checkRotate;
  40268. private _checkTeleportBackwards;
  40269. private _enableTeleportationOnController;
  40270. private _createTeleportationCircles;
  40271. private _displayTeleportationTarget;
  40272. private _hideTeleportationTarget;
  40273. private _rotateCamera;
  40274. private _moveTeleportationSelectorTo;
  40275. private _workingVector;
  40276. private _workingQuaternion;
  40277. private _workingMatrix;
  40278. /**
  40279. * Teleports the users feet to the desired location
  40280. * @param location The location where the user's feet should be placed
  40281. */
  40282. teleportCamera(location: Vector3): void;
  40283. private _convertNormalToDirectionOfRay;
  40284. private _castRayAndSelectObject;
  40285. private _notifySelectedMeshUnselected;
  40286. /**
  40287. * Sets the color of the laser ray from the vr controllers.
  40288. * @param color new color for the ray.
  40289. */
  40290. changeLaserColor(color: Color3): void;
  40291. /**
  40292. * Sets the color of the ray from the vr headsets gaze.
  40293. * @param color new color for the ray.
  40294. */
  40295. changeGazeColor(color: Color3): void;
  40296. /**
  40297. * Exits VR and disposes of the vr experience helper
  40298. */
  40299. dispose(): void;
  40300. /**
  40301. * Gets the name of the VRExperienceHelper class
  40302. * @returns "VRExperienceHelper"
  40303. */
  40304. getClassName(): string;
  40305. }
  40306. }
  40307. declare module "babylonjs/Cameras/VR/index" {
  40308. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40309. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40310. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40311. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40312. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40313. export * from "babylonjs/Cameras/VR/webVRCamera";
  40314. }
  40315. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40316. import { Observable } from "babylonjs/Misc/observable";
  40317. import { Nullable } from "babylonjs/types";
  40318. import { IDisposable, Scene } from "babylonjs/scene";
  40319. import { Vector3 } from "babylonjs/Maths/math";
  40320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40321. import { Ray } from "babylonjs/Culling/ray";
  40322. /**
  40323. * Manages an XRSession
  40324. * @see https://doc.babylonjs.com/how_to/webxr
  40325. */
  40326. export class WebXRSessionManager implements IDisposable {
  40327. private scene;
  40328. /**
  40329. * Fires every time a new xrFrame arrives which can be used to update the camera
  40330. */
  40331. onXRFrameObservable: Observable<any>;
  40332. /**
  40333. * Fires when the xr session is ended either by the device or manually done
  40334. */
  40335. onXRSessionEnded: Observable<any>;
  40336. /** @hidden */
  40337. _xrSession: XRSession;
  40338. /** @hidden */
  40339. _frameOfReference: XRFrameOfReference;
  40340. /** @hidden */
  40341. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40342. /** @hidden */
  40343. _currentXRFrame: Nullable<XRFrame>;
  40344. private _xrNavigator;
  40345. private _xrDevice;
  40346. private _tmpMatrix;
  40347. /**
  40348. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40349. * @param scene The scene which the session should be created for
  40350. */
  40351. constructor(scene: Scene);
  40352. /**
  40353. * Initializes the manager
  40354. * After initialization enterXR can be called to start an XR session
  40355. * @returns Promise which resolves after it is initialized
  40356. */
  40357. initializeAsync(): Promise<void>;
  40358. /**
  40359. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40360. * @param sessionCreationOptions xr options to create the session with
  40361. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40362. * @returns Promise which resolves after it enters XR
  40363. */
  40364. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40365. /**
  40366. * Stops the xrSession and restores the renderloop
  40367. * @returns Promise which resolves after it exits XR
  40368. */
  40369. exitXRAsync(): Promise<void>;
  40370. /**
  40371. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40372. * @param ray ray to cast into the environment
  40373. * @returns Promise which resolves with a collision point in the environment if it exists
  40374. */
  40375. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40376. /**
  40377. * Checks if a session would be supported for the creation options specified
  40378. * @param options creation options to check if they are supported
  40379. * @returns true if supported
  40380. */
  40381. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40382. /**
  40383. * @hidden
  40384. * Converts the render layer of xrSession to a render target
  40385. * @param session session to create render target for
  40386. * @param scene scene the new render target should be created for
  40387. */
  40388. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40389. /**
  40390. * Disposes of the session manager
  40391. */
  40392. dispose(): void;
  40393. }
  40394. }
  40395. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40396. import { Scene } from "babylonjs/scene";
  40397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40398. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40399. /**
  40400. * WebXR Camera which holds the views for the xrSession
  40401. * @see https://doc.babylonjs.com/how_to/webxr
  40402. */
  40403. export class WebXRCamera extends FreeCamera {
  40404. private static _TmpMatrix;
  40405. /**
  40406. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40407. * @param name the name of the camera
  40408. * @param scene the scene to add the camera to
  40409. */
  40410. constructor(name: string, scene: Scene);
  40411. private _updateNumberOfRigCameras;
  40412. /** @hidden */
  40413. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40414. /**
  40415. * Updates the cameras position from the current pose information of the XR session
  40416. * @param xrSessionManager the session containing pose information
  40417. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40418. */
  40419. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40420. }
  40421. }
  40422. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40423. import { Nullable } from "babylonjs/types";
  40424. import { Observable } from "babylonjs/Misc/observable";
  40425. import { IDisposable, Scene } from "babylonjs/scene";
  40426. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40428. import { Ray } from "babylonjs/Culling/ray";
  40429. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40430. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40431. /**
  40432. * States of the webXR experience
  40433. */
  40434. export enum WebXRState {
  40435. /**
  40436. * Transitioning to being in XR mode
  40437. */
  40438. ENTERING_XR = 0,
  40439. /**
  40440. * Transitioning to non XR mode
  40441. */
  40442. EXITING_XR = 1,
  40443. /**
  40444. * In XR mode and presenting
  40445. */
  40446. IN_XR = 2,
  40447. /**
  40448. * Not entered XR mode
  40449. */
  40450. NOT_IN_XR = 3
  40451. }
  40452. /**
  40453. * Helper class used to enable XR
  40454. * @see https://doc.babylonjs.com/how_to/webxr
  40455. */
  40456. export class WebXRExperienceHelper implements IDisposable {
  40457. private scene;
  40458. /**
  40459. * 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
  40460. */
  40461. container: AbstractMesh;
  40462. /**
  40463. * Camera used to render xr content
  40464. */
  40465. camera: WebXRCamera;
  40466. /**
  40467. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40468. */
  40469. state: WebXRState;
  40470. private _setState;
  40471. private static _TmpVector;
  40472. /**
  40473. * Fires when the state of the experience helper has changed
  40474. */
  40475. onStateChangedObservable: Observable<WebXRState>;
  40476. /** @hidden */
  40477. _sessionManager: WebXRSessionManager;
  40478. private _nonVRCamera;
  40479. private _originalSceneAutoClear;
  40480. private _supported;
  40481. /**
  40482. * Creates the experience helper
  40483. * @param scene the scene to attach the experience helper to
  40484. * @returns a promise for the experience helper
  40485. */
  40486. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40487. /**
  40488. * Creates a WebXRExperienceHelper
  40489. * @param scene The scene the helper should be created in
  40490. */
  40491. private constructor();
  40492. /**
  40493. * Exits XR mode and returns the scene to its original state
  40494. * @returns promise that resolves after xr mode has exited
  40495. */
  40496. exitXRAsync(): Promise<void>;
  40497. /**
  40498. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40499. * @param sessionCreationOptions options for the XR session
  40500. * @param frameOfReference frame of reference of the XR session
  40501. * @returns promise that resolves after xr mode has entered
  40502. */
  40503. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40504. /**
  40505. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40506. * @param ray ray to cast into the environment
  40507. * @returns Promise which resolves with a collision point in the environment if it exists
  40508. */
  40509. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40510. /**
  40511. * Updates the global position of the camera by moving the camera's container
  40512. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40513. * @param position The desired global position of the camera
  40514. */
  40515. setPositionOfCameraUsingContainer(position: Vector3): void;
  40516. /**
  40517. * Rotates the xr camera by rotating the camera's container around the camera's position
  40518. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40519. * @param rotation the desired quaternion rotation to apply to the camera
  40520. */
  40521. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40522. /**
  40523. * Checks if the creation options are supported by the xr session
  40524. * @param options creation options
  40525. * @returns true if supported
  40526. */
  40527. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40528. /**
  40529. * Disposes of the experience helper
  40530. */
  40531. dispose(): void;
  40532. }
  40533. }
  40534. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40535. import { Nullable } from "babylonjs/types";
  40536. import { Observable } from "babylonjs/Misc/observable";
  40537. import { IDisposable, Scene } from "babylonjs/scene";
  40538. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40539. /**
  40540. * Button which can be used to enter a different mode of XR
  40541. */
  40542. export class WebXREnterExitUIButton {
  40543. /** button element */
  40544. element: HTMLElement;
  40545. /** XR initialization options for the button */
  40546. initializationOptions: XRSessionCreationOptions;
  40547. /**
  40548. * Creates a WebXREnterExitUIButton
  40549. * @param element button element
  40550. * @param initializationOptions XR initialization options for the button
  40551. */
  40552. constructor(
  40553. /** button element */
  40554. element: HTMLElement,
  40555. /** XR initialization options for the button */
  40556. initializationOptions: XRSessionCreationOptions);
  40557. /**
  40558. * Overwritable function which can be used to update the button's visuals when the state changes
  40559. * @param activeButton the current active button in the UI
  40560. */
  40561. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40562. }
  40563. /**
  40564. * Options to create the webXR UI
  40565. */
  40566. export class WebXREnterExitUIOptions {
  40567. /**
  40568. * Context to enter xr with
  40569. */
  40570. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40571. /**
  40572. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40573. */
  40574. customButtons?: Array<WebXREnterExitUIButton>;
  40575. }
  40576. /**
  40577. * UI to allow the user to enter/exit XR mode
  40578. */
  40579. export class WebXREnterExitUI implements IDisposable {
  40580. private scene;
  40581. private _overlay;
  40582. private _buttons;
  40583. private _activeButton;
  40584. /**
  40585. * Fired every time the active button is changed.
  40586. *
  40587. * When xr is entered via a button that launches xr that button will be the callback parameter
  40588. *
  40589. * When exiting xr the callback parameter will be null)
  40590. */
  40591. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40592. /**
  40593. * Creates UI to allow the user to enter/exit XR mode
  40594. * @param scene the scene to add the ui to
  40595. * @param helper the xr experience helper to enter/exit xr with
  40596. * @param options options to configure the UI
  40597. * @returns the created ui
  40598. */
  40599. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40600. private constructor();
  40601. private _updateButtons;
  40602. /**
  40603. * Disposes of the object
  40604. */
  40605. dispose(): void;
  40606. }
  40607. }
  40608. declare module "babylonjs/Cameras/XR/webXRInput" {
  40609. import { IDisposable, Scene } from "babylonjs/scene";
  40610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40611. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40612. /**
  40613. * Represents an XR input
  40614. */
  40615. export class WebXRController {
  40616. /**
  40617. * 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
  40618. */
  40619. grip?: AbstractMesh;
  40620. /**
  40621. * Pointer which can be used to select objects or attach a visible laser to
  40622. */
  40623. pointer: AbstractMesh;
  40624. /**
  40625. * Creates the controller
  40626. * @see https://doc.babylonjs.com/how_to/webxr
  40627. * @param scene the scene which the controller should be associated to
  40628. */
  40629. constructor(scene: Scene);
  40630. /**
  40631. * Disposes of the object
  40632. */
  40633. dispose(): void;
  40634. }
  40635. /**
  40636. * XR input used to track XR inputs such as controllers/rays
  40637. */
  40638. export class WebXRInput implements IDisposable {
  40639. private helper;
  40640. /**
  40641. * XR controllers being tracked
  40642. */
  40643. controllers: Array<WebXRController>;
  40644. private _tmpMatrix;
  40645. private _frameObserver;
  40646. /**
  40647. * Initializes the WebXRInput
  40648. * @param helper experience helper which the input should be created for
  40649. */
  40650. constructor(helper: WebXRExperienceHelper);
  40651. /**
  40652. * Disposes of the object
  40653. */
  40654. dispose(): void;
  40655. }
  40656. }
  40657. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40658. import { Nullable } from "babylonjs/types";
  40659. import { IDisposable } from "babylonjs/scene";
  40660. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40661. /**
  40662. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40663. */
  40664. export class WebXRManagedOutputCanvas implements IDisposable {
  40665. private _canvas;
  40666. /**
  40667. * xrpresent context of the canvas which can be used to display/mirror xr content
  40668. */
  40669. canvasContext: Nullable<WebGLRenderingContext>;
  40670. /**
  40671. * Initializes the canvas to be added/removed upon entering/exiting xr
  40672. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40673. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40674. */
  40675. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40676. /**
  40677. * Disposes of the object
  40678. */
  40679. dispose(): void;
  40680. private _setManagedOutputCanvas;
  40681. private _addCanvas;
  40682. private _removeCanvas;
  40683. }
  40684. }
  40685. declare module "babylonjs/Cameras/XR/index" {
  40686. export * from "babylonjs/Cameras/XR/webXRCamera";
  40687. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40688. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40689. export * from "babylonjs/Cameras/XR/webXRInput";
  40690. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40691. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40692. }
  40693. declare module "babylonjs/Cameras/RigModes/index" {
  40694. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40695. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40696. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40697. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40698. }
  40699. declare module "babylonjs/Cameras/index" {
  40700. export * from "babylonjs/Cameras/Inputs/index";
  40701. export * from "babylonjs/Cameras/cameraInputsManager";
  40702. export * from "babylonjs/Cameras/camera";
  40703. export * from "babylonjs/Cameras/targetCamera";
  40704. export * from "babylonjs/Cameras/freeCamera";
  40705. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40706. export * from "babylonjs/Cameras/touchCamera";
  40707. export * from "babylonjs/Cameras/arcRotateCamera";
  40708. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40709. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40710. export * from "babylonjs/Cameras/flyCamera";
  40711. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40712. export * from "babylonjs/Cameras/followCamera";
  40713. export * from "babylonjs/Cameras/gamepadCamera";
  40714. export * from "babylonjs/Cameras/Stereoscopic/index";
  40715. export * from "babylonjs/Cameras/universalCamera";
  40716. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40717. export * from "babylonjs/Cameras/VR/index";
  40718. export * from "babylonjs/Cameras/XR/index";
  40719. export * from "babylonjs/Cameras/RigModes/index";
  40720. }
  40721. declare module "babylonjs/Collisions/index" {
  40722. export * from "babylonjs/Collisions/collider";
  40723. export * from "babylonjs/Collisions/collisionCoordinator";
  40724. export * from "babylonjs/Collisions/pickingInfo";
  40725. export * from "babylonjs/Collisions/intersectionInfo";
  40726. }
  40727. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40728. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40729. import { Vector3, Plane } from "babylonjs/Maths/math";
  40730. import { Ray } from "babylonjs/Culling/ray";
  40731. /**
  40732. * Contains an array of blocks representing the octree
  40733. */
  40734. export interface IOctreeContainer<T> {
  40735. /**
  40736. * Blocks within the octree
  40737. */
  40738. blocks: Array<OctreeBlock<T>>;
  40739. }
  40740. /**
  40741. * Class used to store a cell in an octree
  40742. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40743. */
  40744. export class OctreeBlock<T> {
  40745. /**
  40746. * Gets the content of the current block
  40747. */
  40748. entries: T[];
  40749. /**
  40750. * Gets the list of block children
  40751. */
  40752. blocks: Array<OctreeBlock<T>>;
  40753. private _depth;
  40754. private _maxDepth;
  40755. private _capacity;
  40756. private _minPoint;
  40757. private _maxPoint;
  40758. private _boundingVectors;
  40759. private _creationFunc;
  40760. /**
  40761. * Creates a new block
  40762. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40763. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40764. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40765. * @param depth defines the current depth of this block in the octree
  40766. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40767. * @param creationFunc defines a callback to call when an element is added to the block
  40768. */
  40769. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40770. /**
  40771. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40772. */
  40773. readonly capacity: number;
  40774. /**
  40775. * Gets the minimum vector (in world space) of the block's bounding box
  40776. */
  40777. readonly minPoint: Vector3;
  40778. /**
  40779. * Gets the maximum vector (in world space) of the block's bounding box
  40780. */
  40781. readonly maxPoint: Vector3;
  40782. /**
  40783. * Add a new element to this block
  40784. * @param entry defines the element to add
  40785. */
  40786. addEntry(entry: T): void;
  40787. /**
  40788. * Remove an element from this block
  40789. * @param entry defines the element to remove
  40790. */
  40791. removeEntry(entry: T): void;
  40792. /**
  40793. * Add an array of elements to this block
  40794. * @param entries defines the array of elements to add
  40795. */
  40796. addEntries(entries: T[]): void;
  40797. /**
  40798. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40799. * @param frustumPlanes defines the frustum planes to test
  40800. * @param selection defines the array to store current content if selection is positive
  40801. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40802. */
  40803. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40804. /**
  40805. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40806. * @param sphereCenter defines the bounding sphere center
  40807. * @param sphereRadius defines the bounding sphere radius
  40808. * @param selection defines the array to store current content if selection is positive
  40809. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40810. */
  40811. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40812. /**
  40813. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40814. * @param ray defines the ray to test with
  40815. * @param selection defines the array to store current content if selection is positive
  40816. */
  40817. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40818. /**
  40819. * Subdivide the content into child blocks (this block will then be empty)
  40820. */
  40821. createInnerBlocks(): void;
  40822. /**
  40823. * @hidden
  40824. */
  40825. 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;
  40826. }
  40827. }
  40828. declare module "babylonjs/Culling/Octrees/octree" {
  40829. import { SmartArray } from "babylonjs/Misc/smartArray";
  40830. import { Vector3, Plane } from "babylonjs/Maths/math";
  40831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40833. import { Ray } from "babylonjs/Culling/ray";
  40834. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40835. /**
  40836. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40837. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40838. */
  40839. export class Octree<T> {
  40840. /** 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.) */
  40841. maxDepth: number;
  40842. /**
  40843. * Blocks within the octree containing objects
  40844. */
  40845. blocks: Array<OctreeBlock<T>>;
  40846. /**
  40847. * Content stored in the octree
  40848. */
  40849. dynamicContent: T[];
  40850. private _maxBlockCapacity;
  40851. private _selectionContent;
  40852. private _creationFunc;
  40853. /**
  40854. * Creates a octree
  40855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40856. * @param creationFunc function to be used to instatiate the octree
  40857. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40858. * @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.)
  40859. */
  40860. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40861. /** 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.) */
  40862. maxDepth?: number);
  40863. /**
  40864. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40865. * @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);
  40866. * @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);
  40867. * @param entries meshes to be added to the octree blocks
  40868. */
  40869. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40870. /**
  40871. * Adds a mesh to the octree
  40872. * @param entry Mesh to add to the octree
  40873. */
  40874. addMesh(entry: T): void;
  40875. /**
  40876. * Remove an element from the octree
  40877. * @param entry defines the element to remove
  40878. */
  40879. removeMesh(entry: T): void;
  40880. /**
  40881. * Selects an array of meshes within the frustum
  40882. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40883. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40884. * @returns array of meshes within the frustum
  40885. */
  40886. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40887. /**
  40888. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40889. * @param sphereCenter defines the bounding sphere center
  40890. * @param sphereRadius defines the bounding sphere radius
  40891. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40892. * @returns an array of objects that intersect the sphere
  40893. */
  40894. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40895. /**
  40896. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40897. * @param ray defines the ray to test with
  40898. * @returns array of intersected objects
  40899. */
  40900. intersectsRay(ray: Ray): SmartArray<T>;
  40901. /**
  40902. * Adds a mesh into the octree block if it intersects the block
  40903. */
  40904. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40905. /**
  40906. * Adds a submesh into the octree block if it intersects the block
  40907. */
  40908. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40909. }
  40910. }
  40911. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40912. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40913. import { Scene } from "babylonjs/scene";
  40914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40916. import { Ray } from "babylonjs/Culling/ray";
  40917. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40918. import { Collider } from "babylonjs/Collisions/collider";
  40919. module "babylonjs/scene" {
  40920. interface Scene {
  40921. /**
  40922. * @hidden
  40923. * Backing Filed
  40924. */
  40925. _selectionOctree: Octree<AbstractMesh>;
  40926. /**
  40927. * Gets the octree used to boost mesh selection (picking)
  40928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40929. */
  40930. selectionOctree: Octree<AbstractMesh>;
  40931. /**
  40932. * Creates or updates the octree used to boost selection (picking)
  40933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40934. * @param maxCapacity defines the maximum capacity per leaf
  40935. * @param maxDepth defines the maximum depth of the octree
  40936. * @returns an octree of AbstractMesh
  40937. */
  40938. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40939. }
  40940. }
  40941. module "babylonjs/Meshes/abstractMesh" {
  40942. interface AbstractMesh {
  40943. /**
  40944. * @hidden
  40945. * Backing Field
  40946. */
  40947. _submeshesOctree: Octree<SubMesh>;
  40948. /**
  40949. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40950. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40951. * @param maxCapacity defines the maximum size of each block (64 by default)
  40952. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40953. * @returns the new octree
  40954. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40956. */
  40957. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40958. }
  40959. }
  40960. /**
  40961. * Defines the octree scene component responsible to manage any octrees
  40962. * in a given scene.
  40963. */
  40964. export class OctreeSceneComponent {
  40965. /**
  40966. * The component name helpfull to identify the component in the list of scene components.
  40967. */
  40968. readonly name: string;
  40969. /**
  40970. * The scene the component belongs to.
  40971. */
  40972. scene: Scene;
  40973. /**
  40974. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40975. */
  40976. readonly checksIsEnabled: boolean;
  40977. /**
  40978. * Creates a new instance of the component for the given scene
  40979. * @param scene Defines the scene to register the component in
  40980. */
  40981. constructor(scene: Scene);
  40982. /**
  40983. * Registers the component in a given scene
  40984. */
  40985. register(): void;
  40986. /**
  40987. * Return the list of active meshes
  40988. * @returns the list of active meshes
  40989. */
  40990. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40991. /**
  40992. * Return the list of active sub meshes
  40993. * @param mesh The mesh to get the candidates sub meshes from
  40994. * @returns the list of active sub meshes
  40995. */
  40996. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40997. private _tempRay;
  40998. /**
  40999. * Return the list of sub meshes intersecting with a given local ray
  41000. * @param mesh defines the mesh to find the submesh for
  41001. * @param localRay defines the ray in local space
  41002. * @returns the list of intersecting sub meshes
  41003. */
  41004. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41005. /**
  41006. * Return the list of sub meshes colliding with a collider
  41007. * @param mesh defines the mesh to find the submesh for
  41008. * @param collider defines the collider to evaluate the collision against
  41009. * @returns the list of colliding sub meshes
  41010. */
  41011. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41012. /**
  41013. * Rebuilds the elements related to this component in case of
  41014. * context lost for instance.
  41015. */
  41016. rebuild(): void;
  41017. /**
  41018. * Disposes the component and the associated ressources.
  41019. */
  41020. dispose(): void;
  41021. }
  41022. }
  41023. declare module "babylonjs/Culling/Octrees/index" {
  41024. export * from "babylonjs/Culling/Octrees/octree";
  41025. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41026. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41027. }
  41028. declare module "babylonjs/Culling/index" {
  41029. export * from "babylonjs/Culling/boundingBox";
  41030. export * from "babylonjs/Culling/boundingInfo";
  41031. export * from "babylonjs/Culling/boundingSphere";
  41032. export * from "babylonjs/Culling/Octrees/index";
  41033. export * from "babylonjs/Culling/ray";
  41034. }
  41035. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41036. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41037. import { Nullable } from "babylonjs/types";
  41038. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41039. import { Scene } from "babylonjs/scene";
  41040. /**
  41041. * Class containing static functions to help procedurally build meshes
  41042. */
  41043. export class LinesBuilder {
  41044. /**
  41045. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41046. * * 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
  41047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41048. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41049. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41050. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41051. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41052. * * 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
  41053. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41056. * @param name defines the name of the new line system
  41057. * @param options defines the options used to create the line system
  41058. * @param scene defines the hosting scene
  41059. * @returns a new line system mesh
  41060. */
  41061. static CreateLineSystem(name: string, options: {
  41062. lines: Vector3[][];
  41063. updatable?: boolean;
  41064. instance?: Nullable<LinesMesh>;
  41065. colors?: Nullable<Color4[][]>;
  41066. useVertexAlpha?: boolean;
  41067. }, scene: Nullable<Scene>): LinesMesh;
  41068. /**
  41069. * Creates a line mesh
  41070. * 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
  41071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41072. * * The parameter `points` is an array successive Vector3
  41073. * * 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
  41074. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41075. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41076. * * When updating an instance, remember that only point positions can change, not the number of points
  41077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41079. * @param name defines the name of the new line system
  41080. * @param options defines the options used to create the line system
  41081. * @param scene defines the hosting scene
  41082. * @returns a new line mesh
  41083. */
  41084. static CreateLines(name: string, options: {
  41085. points: Vector3[];
  41086. updatable?: boolean;
  41087. instance?: Nullable<LinesMesh>;
  41088. colors?: Color4[];
  41089. useVertexAlpha?: boolean;
  41090. }, scene?: Nullable<Scene>): LinesMesh;
  41091. /**
  41092. * Creates a dashed line mesh
  41093. * * 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
  41094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41095. * * The parameter `points` is an array successive Vector3
  41096. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41097. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41098. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41099. * * 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
  41100. * * When updating an instance, remember that only point positions can change, not the number of points
  41101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41102. * @param name defines the name of the mesh
  41103. * @param options defines the options used to create the mesh
  41104. * @param scene defines the hosting scene
  41105. * @returns the dashed line mesh
  41106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41107. */
  41108. static CreateDashedLines(name: string, options: {
  41109. points: Vector3[];
  41110. dashSize?: number;
  41111. gapSize?: number;
  41112. dashNb?: number;
  41113. updatable?: boolean;
  41114. instance?: LinesMesh;
  41115. }, scene?: Nullable<Scene>): LinesMesh;
  41116. }
  41117. }
  41118. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41119. import { IDisposable, Scene } from "babylonjs/scene";
  41120. import { Nullable } from "babylonjs/types";
  41121. import { Observable } from "babylonjs/Misc/observable";
  41122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41123. /**
  41124. * Renders a layer on top of an existing scene
  41125. */
  41126. export class UtilityLayerRenderer implements IDisposable {
  41127. /** the original scene that will be rendered on top of */
  41128. originalScene: Scene;
  41129. private _pointerCaptures;
  41130. private _lastPointerEvents;
  41131. private static _DefaultUtilityLayer;
  41132. private static _DefaultKeepDepthUtilityLayer;
  41133. /**
  41134. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41135. */
  41136. pickUtilitySceneFirst: boolean;
  41137. /**
  41138. * 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)
  41139. */
  41140. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41141. /**
  41142. * 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)
  41143. */
  41144. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41145. /**
  41146. * The scene that is rendered on top of the original scene
  41147. */
  41148. utilityLayerScene: Scene;
  41149. /**
  41150. * If the utility layer should automatically be rendered on top of existing scene
  41151. */
  41152. shouldRender: boolean;
  41153. /**
  41154. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41155. */
  41156. onlyCheckPointerDownEvents: boolean;
  41157. /**
  41158. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41159. */
  41160. processAllEvents: boolean;
  41161. /**
  41162. * Observable raised when the pointer move from the utility layer scene to the main scene
  41163. */
  41164. onPointerOutObservable: Observable<number>;
  41165. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41166. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41167. private _afterRenderObserver;
  41168. private _sceneDisposeObserver;
  41169. private _originalPointerObserver;
  41170. /**
  41171. * Instantiates a UtilityLayerRenderer
  41172. * @param originalScene the original scene that will be rendered on top of
  41173. * @param handleEvents boolean indicating if the utility layer should handle events
  41174. */
  41175. constructor(
  41176. /** the original scene that will be rendered on top of */
  41177. originalScene: Scene, handleEvents?: boolean);
  41178. private _notifyObservers;
  41179. /**
  41180. * Renders the utility layers scene on top of the original scene
  41181. */
  41182. render(): void;
  41183. /**
  41184. * Disposes of the renderer
  41185. */
  41186. dispose(): void;
  41187. private _updateCamera;
  41188. }
  41189. }
  41190. declare module "babylonjs/Gizmos/gizmo" {
  41191. import { Nullable } from "babylonjs/types";
  41192. import { IDisposable } from "babylonjs/scene";
  41193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41194. import { Mesh } from "babylonjs/Meshes/mesh";
  41195. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41196. /**
  41197. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41198. */
  41199. export class Gizmo implements IDisposable {
  41200. /** The utility layer the gizmo will be added to */
  41201. gizmoLayer: UtilityLayerRenderer;
  41202. /**
  41203. * The root mesh of the gizmo
  41204. */
  41205. _rootMesh: Mesh;
  41206. private _attachedMesh;
  41207. /**
  41208. * Ratio for the scale of the gizmo (Default: 1)
  41209. */
  41210. scaleRatio: number;
  41211. private _tmpMatrix;
  41212. /**
  41213. * If a custom mesh has been set (Default: false)
  41214. */
  41215. protected _customMeshSet: boolean;
  41216. /**
  41217. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41218. * * When set, interactions will be enabled
  41219. */
  41220. attachedMesh: Nullable<AbstractMesh>;
  41221. /**
  41222. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41223. * @param mesh The mesh to replace the default mesh of the gizmo
  41224. */
  41225. setCustomMesh(mesh: Mesh): void;
  41226. /**
  41227. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41228. */
  41229. updateGizmoRotationToMatchAttachedMesh: boolean;
  41230. /**
  41231. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41232. */
  41233. updateGizmoPositionToMatchAttachedMesh: boolean;
  41234. /**
  41235. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41236. */
  41237. protected _updateScale: boolean;
  41238. protected _interactionsEnabled: boolean;
  41239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41240. private _beforeRenderObserver;
  41241. /**
  41242. * Creates a gizmo
  41243. * @param gizmoLayer The utility layer the gizmo will be added to
  41244. */
  41245. constructor(
  41246. /** The utility layer the gizmo will be added to */
  41247. gizmoLayer?: UtilityLayerRenderer);
  41248. private _tempVector;
  41249. /**
  41250. * @hidden
  41251. * Updates the gizmo to match the attached mesh's position/rotation
  41252. */
  41253. protected _update(): void;
  41254. /**
  41255. * Disposes of the gizmo
  41256. */
  41257. dispose(): void;
  41258. }
  41259. }
  41260. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41261. import { Observable } from "babylonjs/Misc/observable";
  41262. import { Nullable } from "babylonjs/types";
  41263. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41266. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41267. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41269. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41270. import { Scene } from "babylonjs/scene";
  41271. /**
  41272. * Single axis drag gizmo
  41273. */
  41274. export class AxisDragGizmo extends Gizmo {
  41275. /**
  41276. * Drag behavior responsible for the gizmos dragging interactions
  41277. */
  41278. dragBehavior: PointerDragBehavior;
  41279. private _pointerObserver;
  41280. /**
  41281. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41282. */
  41283. snapDistance: number;
  41284. /**
  41285. * Event that fires each time the gizmo snaps to a new location.
  41286. * * snapDistance is the the change in distance
  41287. */
  41288. onSnapObservable: Observable<{
  41289. snapDistance: number;
  41290. }>;
  41291. /** @hidden */
  41292. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41293. /** @hidden */
  41294. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41295. /**
  41296. * Creates an AxisDragGizmo
  41297. * @param gizmoLayer The utility layer the gizmo will be added to
  41298. * @param dragAxis The axis which the gizmo will be able to drag on
  41299. * @param color The color of the gizmo
  41300. */
  41301. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41302. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41303. /**
  41304. * Disposes of the gizmo
  41305. */
  41306. dispose(): void;
  41307. }
  41308. }
  41309. declare module "babylonjs/Debug/axesViewer" {
  41310. import { Vector3 } from "babylonjs/Maths/math";
  41311. import { Nullable } from "babylonjs/types";
  41312. import { Scene } from "babylonjs/scene";
  41313. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41314. /**
  41315. * The Axes viewer will show 3 axes in a specific point in space
  41316. */
  41317. export class AxesViewer {
  41318. private _xAxis;
  41319. private _yAxis;
  41320. private _zAxis;
  41321. private _scaleLinesFactor;
  41322. private _instanced;
  41323. /**
  41324. * Gets the hosting scene
  41325. */
  41326. scene: Scene;
  41327. /**
  41328. * Gets or sets a number used to scale line length
  41329. */
  41330. scaleLines: number;
  41331. /** Gets the node hierarchy used to render x-axis */
  41332. readonly xAxis: TransformNode;
  41333. /** Gets the node hierarchy used to render y-axis */
  41334. readonly yAxis: TransformNode;
  41335. /** Gets the node hierarchy used to render z-axis */
  41336. readonly zAxis: TransformNode;
  41337. /**
  41338. * Creates a new AxesViewer
  41339. * @param scene defines the hosting scene
  41340. * @param scaleLines defines a number used to scale line length (1 by default)
  41341. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41342. * @param xAxis defines the node hierarchy used to render the x-axis
  41343. * @param yAxis defines the node hierarchy used to render the y-axis
  41344. * @param zAxis defines the node hierarchy used to render the z-axis
  41345. */
  41346. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41347. /**
  41348. * Force the viewer to update
  41349. * @param position defines the position of the viewer
  41350. * @param xaxis defines the x axis of the viewer
  41351. * @param yaxis defines the y axis of the viewer
  41352. * @param zaxis defines the z axis of the viewer
  41353. */
  41354. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41355. /**
  41356. * Creates an instance of this axes viewer.
  41357. * @returns a new axes viewer with instanced meshes
  41358. */
  41359. createInstance(): AxesViewer;
  41360. /** Releases resources */
  41361. dispose(): void;
  41362. private static _SetRenderingGroupId;
  41363. }
  41364. }
  41365. declare module "babylonjs/Debug/boneAxesViewer" {
  41366. import { Nullable } from "babylonjs/types";
  41367. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41368. import { Vector3 } from "babylonjs/Maths/math";
  41369. import { Mesh } from "babylonjs/Meshes/mesh";
  41370. import { Bone } from "babylonjs/Bones/bone";
  41371. import { Scene } from "babylonjs/scene";
  41372. /**
  41373. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41374. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41375. */
  41376. export class BoneAxesViewer extends AxesViewer {
  41377. /**
  41378. * Gets or sets the target mesh where to display the axes viewer
  41379. */
  41380. mesh: Nullable<Mesh>;
  41381. /**
  41382. * Gets or sets the target bone where to display the axes viewer
  41383. */
  41384. bone: Nullable<Bone>;
  41385. /** Gets current position */
  41386. pos: Vector3;
  41387. /** Gets direction of X axis */
  41388. xaxis: Vector3;
  41389. /** Gets direction of Y axis */
  41390. yaxis: Vector3;
  41391. /** Gets direction of Z axis */
  41392. zaxis: Vector3;
  41393. /**
  41394. * Creates a new BoneAxesViewer
  41395. * @param scene defines the hosting scene
  41396. * @param bone defines the target bone
  41397. * @param mesh defines the target mesh
  41398. * @param scaleLines defines a scaling factor for line length (1 by default)
  41399. */
  41400. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41401. /**
  41402. * Force the viewer to update
  41403. */
  41404. update(): void;
  41405. /** Releases resources */
  41406. dispose(): void;
  41407. }
  41408. }
  41409. declare module "babylonjs/Debug/debugLayer" {
  41410. import { Observable } from "babylonjs/Misc/observable";
  41411. import { Scene } from "babylonjs/scene";
  41412. /**
  41413. * Interface used to define scene explorer extensibility option
  41414. */
  41415. export interface IExplorerExtensibilityOption {
  41416. /**
  41417. * Define the option label
  41418. */
  41419. label: string;
  41420. /**
  41421. * Defines the action to execute on click
  41422. */
  41423. action: (entity: any) => void;
  41424. }
  41425. /**
  41426. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41427. */
  41428. export interface IExplorerExtensibilityGroup {
  41429. /**
  41430. * Defines a predicate to test if a given type mut be extended
  41431. */
  41432. predicate: (entity: any) => boolean;
  41433. /**
  41434. * Gets the list of options added to a type
  41435. */
  41436. entries: IExplorerExtensibilityOption[];
  41437. }
  41438. /**
  41439. * Interface used to define the options to use to create the Inspector
  41440. */
  41441. export interface IInspectorOptions {
  41442. /**
  41443. * Display in overlay mode (default: false)
  41444. */
  41445. overlay?: boolean;
  41446. /**
  41447. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41448. */
  41449. globalRoot?: HTMLElement;
  41450. /**
  41451. * Display the Scene explorer
  41452. */
  41453. showExplorer?: boolean;
  41454. /**
  41455. * Display the property inspector
  41456. */
  41457. showInspector?: boolean;
  41458. /**
  41459. * Display in embed mode (both panes on the right)
  41460. */
  41461. embedMode?: boolean;
  41462. /**
  41463. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41464. */
  41465. handleResize?: boolean;
  41466. /**
  41467. * Allow the panes to popup (default: true)
  41468. */
  41469. enablePopup?: boolean;
  41470. /**
  41471. * Allow the panes to be closed by users (default: true)
  41472. */
  41473. enableClose?: boolean;
  41474. /**
  41475. * Optional list of extensibility entries
  41476. */
  41477. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41478. /**
  41479. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41480. */
  41481. inspectorURL?: string;
  41482. }
  41483. module "babylonjs/scene" {
  41484. interface Scene {
  41485. /**
  41486. * @hidden
  41487. * Backing field
  41488. */
  41489. _debugLayer: DebugLayer;
  41490. /**
  41491. * Gets the debug layer (aka Inspector) associated with the scene
  41492. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41493. */
  41494. debugLayer: DebugLayer;
  41495. }
  41496. }
  41497. /**
  41498. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41499. * what is happening in your scene
  41500. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41501. */
  41502. export class DebugLayer {
  41503. /**
  41504. * Define the url to get the inspector script from.
  41505. * By default it uses the babylonjs CDN.
  41506. * @ignoreNaming
  41507. */
  41508. static InspectorURL: string;
  41509. private _scene;
  41510. private BJSINSPECTOR;
  41511. /**
  41512. * Observable triggered when a property is changed through the inspector.
  41513. */
  41514. onPropertyChangedObservable: Observable<{
  41515. object: any;
  41516. property: string;
  41517. value: any;
  41518. initialValue: any;
  41519. }>;
  41520. /**
  41521. * Instantiates a new debug layer.
  41522. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41523. * what is happening in your scene
  41524. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41525. * @param scene Defines the scene to inspect
  41526. */
  41527. constructor(scene: Scene);
  41528. /** Creates the inspector window. */
  41529. private _createInspector;
  41530. /**
  41531. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41532. * @param entity defines the entity to select
  41533. * @param lineContainerTitle defines the specific block to highlight
  41534. */
  41535. select(entity: any, lineContainerTitle?: string): void;
  41536. /** Get the inspector from bundle or global */
  41537. private _getGlobalInspector;
  41538. /**
  41539. * Get if the inspector is visible or not.
  41540. * @returns true if visible otherwise, false
  41541. */
  41542. isVisible(): boolean;
  41543. /**
  41544. * Hide the inspector and close its window.
  41545. */
  41546. hide(): void;
  41547. /**
  41548. * Launch the debugLayer.
  41549. * @param config Define the configuration of the inspector
  41550. * @return a promise fulfilled when the debug layer is visible
  41551. */
  41552. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41553. }
  41554. }
  41555. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41556. import { Nullable } from "babylonjs/types";
  41557. import { Scene } from "babylonjs/scene";
  41558. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41559. import { Mesh } from "babylonjs/Meshes/mesh";
  41560. /**
  41561. * Class containing static functions to help procedurally build meshes
  41562. */
  41563. export class BoxBuilder {
  41564. /**
  41565. * Creates a box mesh
  41566. * * The parameter `size` sets the size (float) of each box side (default 1)
  41567. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41568. * * 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)
  41569. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41571. * * If you create a double-sided mesh, you can choose what parts of 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
  41572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41573. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41574. * @param name defines the name of the mesh
  41575. * @param options defines the options used to create the mesh
  41576. * @param scene defines the hosting scene
  41577. * @returns the box mesh
  41578. */
  41579. static CreateBox(name: string, options: {
  41580. size?: number;
  41581. width?: number;
  41582. height?: number;
  41583. depth?: number;
  41584. faceUV?: Vector4[];
  41585. faceColors?: Color4[];
  41586. sideOrientation?: number;
  41587. frontUVs?: Vector4;
  41588. backUVs?: Vector4;
  41589. updatable?: boolean;
  41590. }, scene?: Nullable<Scene>): Mesh;
  41591. }
  41592. }
  41593. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41594. import { Vector4 } from "babylonjs/Maths/math";
  41595. import { Mesh } from "babylonjs/Meshes/mesh";
  41596. /**
  41597. * Class containing static functions to help procedurally build meshes
  41598. */
  41599. export class SphereBuilder {
  41600. /**
  41601. * Creates a sphere mesh
  41602. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41603. * * 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`)
  41604. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41605. * * 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
  41606. * * 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)
  41607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41608. * * If you create a double-sided mesh, you can choose what parts of 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
  41609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41610. * @param name defines the name of the mesh
  41611. * @param options defines the options used to create the mesh
  41612. * @param scene defines the hosting scene
  41613. * @returns the sphere mesh
  41614. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41615. */
  41616. static CreateSphere(name: string, options: {
  41617. segments?: number;
  41618. diameter?: number;
  41619. diameterX?: number;
  41620. diameterY?: number;
  41621. diameterZ?: number;
  41622. arc?: number;
  41623. slice?: number;
  41624. sideOrientation?: number;
  41625. frontUVs?: Vector4;
  41626. backUVs?: Vector4;
  41627. updatable?: boolean;
  41628. }, scene: any): Mesh;
  41629. }
  41630. }
  41631. declare module "babylonjs/Debug/physicsViewer" {
  41632. import { Nullable } from "babylonjs/types";
  41633. import { Scene } from "babylonjs/scene";
  41634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41635. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41636. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41637. /**
  41638. * Used to show the physics impostor around the specific mesh
  41639. */
  41640. export class PhysicsViewer {
  41641. /** @hidden */
  41642. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41643. /** @hidden */
  41644. protected _meshes: Array<Nullable<AbstractMesh>>;
  41645. /** @hidden */
  41646. protected _scene: Nullable<Scene>;
  41647. /** @hidden */
  41648. protected _numMeshes: number;
  41649. /** @hidden */
  41650. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41651. private _renderFunction;
  41652. private _utilityLayer;
  41653. private _debugBoxMesh;
  41654. private _debugSphereMesh;
  41655. private _debugMaterial;
  41656. /**
  41657. * Creates a new PhysicsViewer
  41658. * @param scene defines the hosting scene
  41659. */
  41660. constructor(scene: Scene);
  41661. /** @hidden */
  41662. protected _updateDebugMeshes(): void;
  41663. /**
  41664. * Renders a specified physic impostor
  41665. * @param impostor defines the impostor to render
  41666. * @returns the new debug mesh used to render the impostor
  41667. */
  41668. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41669. /**
  41670. * Hides a specified physic impostor
  41671. * @param impostor defines the impostor to hide
  41672. */
  41673. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41674. private _getDebugMaterial;
  41675. private _getDebugBoxMesh;
  41676. private _getDebugSphereMesh;
  41677. private _getDebugMesh;
  41678. /** Releases all resources */
  41679. dispose(): void;
  41680. }
  41681. }
  41682. declare module "babylonjs/Debug/rayHelper" {
  41683. import { Nullable } from "babylonjs/types";
  41684. import { Ray } from "babylonjs/Culling/ray";
  41685. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41686. import { Scene } from "babylonjs/scene";
  41687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41688. import "babylonjs/Meshes/Builders/linesBuilder";
  41689. /**
  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. */
  41694. export class RayHelper {
  41695. /**
  41696. * Defines the ray we are currently tryin to visualize.
  41697. */
  41698. ray: Nullable<Ray>;
  41699. private _renderPoints;
  41700. private _renderLine;
  41701. private _renderFunction;
  41702. private _scene;
  41703. private _updateToMeshFunction;
  41704. private _attachedToMesh;
  41705. private _meshSpaceDirection;
  41706. private _meshSpaceOrigin;
  41707. /**
  41708. * Helper function to create a colored helper in a scene in one line.
  41709. * @param ray Defines the ray we are currently tryin to visualize
  41710. * @param scene Defines the scene the ray is used in
  41711. * @param color Defines the color we want to see the ray in
  41712. * @returns The newly created ray helper.
  41713. */
  41714. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41715. /**
  41716. * Instantiate a new ray helper.
  41717. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41718. * in order to better appreciate the issue one might have.
  41719. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41720. * @param ray Defines the ray we are currently tryin to visualize
  41721. */
  41722. constructor(ray: Ray);
  41723. /**
  41724. * Shows the ray we are willing to debug.
  41725. * @param scene Defines the scene the ray needs to be rendered in
  41726. * @param color Defines the color the ray needs to be rendered in
  41727. */
  41728. show(scene: Scene, color?: Color3): void;
  41729. /**
  41730. * Hides the ray we are debugging.
  41731. */
  41732. hide(): void;
  41733. private _render;
  41734. /**
  41735. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41736. * @param mesh Defines the mesh we want the helper attached to
  41737. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41738. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41739. * @param length Defines the length of the ray
  41740. */
  41741. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41742. /**
  41743. * Detach the ray helper from the mesh it has previously been attached to.
  41744. */
  41745. detachFromMesh(): void;
  41746. private _updateToMesh;
  41747. /**
  41748. * Dispose the helper and release its associated resources.
  41749. */
  41750. dispose(): void;
  41751. }
  41752. }
  41753. declare module "babylonjs/Debug/skeletonViewer" {
  41754. import { Color3 } from "babylonjs/Maths/math";
  41755. import { Scene } from "babylonjs/scene";
  41756. import { Nullable } from "babylonjs/types";
  41757. import { Skeleton } from "babylonjs/Bones/skeleton";
  41758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41759. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41760. /**
  41761. * Class used to render a debug view of a given skeleton
  41762. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41763. */
  41764. export class SkeletonViewer {
  41765. /** defines the skeleton to render */
  41766. skeleton: Skeleton;
  41767. /** defines the mesh attached to the skeleton */
  41768. mesh: AbstractMesh;
  41769. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41770. autoUpdateBonesMatrices: boolean;
  41771. /** defines the rendering group id to use with the viewer */
  41772. renderingGroupId: number;
  41773. /** Gets or sets the color used to render the skeleton */
  41774. color: Color3;
  41775. private _scene;
  41776. private _debugLines;
  41777. private _debugMesh;
  41778. private _isEnabled;
  41779. private _renderFunction;
  41780. private _utilityLayer;
  41781. /**
  41782. * Returns the mesh used to render the bones
  41783. */
  41784. readonly debugMesh: Nullable<LinesMesh>;
  41785. /**
  41786. * Creates a new SkeletonViewer
  41787. * @param skeleton defines the skeleton to render
  41788. * @param mesh defines the mesh attached to the skeleton
  41789. * @param scene defines the hosting scene
  41790. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41791. * @param renderingGroupId defines the rendering group id to use with the viewer
  41792. */
  41793. constructor(
  41794. /** defines the skeleton to render */
  41795. skeleton: Skeleton,
  41796. /** defines the mesh attached to the skeleton */
  41797. mesh: AbstractMesh, scene: Scene,
  41798. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41799. autoUpdateBonesMatrices?: boolean,
  41800. /** defines the rendering group id to use with the viewer */
  41801. renderingGroupId?: number);
  41802. /** Gets or sets a boolean indicating if the viewer is enabled */
  41803. isEnabled: boolean;
  41804. private _getBonePosition;
  41805. private _getLinesForBonesWithLength;
  41806. private _getLinesForBonesNoLength;
  41807. /** Update the viewer to sync with current skeleton state */
  41808. update(): void;
  41809. /** Release associated resources */
  41810. dispose(): void;
  41811. }
  41812. }
  41813. declare module "babylonjs/Debug/index" {
  41814. export * from "babylonjs/Debug/axesViewer";
  41815. export * from "babylonjs/Debug/boneAxesViewer";
  41816. export * from "babylonjs/Debug/debugLayer";
  41817. export * from "babylonjs/Debug/physicsViewer";
  41818. export * from "babylonjs/Debug/rayHelper";
  41819. export * from "babylonjs/Debug/skeletonViewer";
  41820. }
  41821. declare module "babylonjs/Engines/nullEngine" {
  41822. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41823. import { Scene } from "babylonjs/scene";
  41824. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41825. import { Engine } from "babylonjs/Engines/engine";
  41826. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41827. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41829. import { Effect } from "babylonjs/Materials/effect";
  41830. /**
  41831. * Options to create the null engine
  41832. */
  41833. export class NullEngineOptions {
  41834. /**
  41835. * Render width (Default: 512)
  41836. */
  41837. renderWidth: number;
  41838. /**
  41839. * Render height (Default: 256)
  41840. */
  41841. renderHeight: number;
  41842. /**
  41843. * Texture size (Default: 512)
  41844. */
  41845. textureSize: number;
  41846. /**
  41847. * If delta time between frames should be constant
  41848. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41849. */
  41850. deterministicLockstep: boolean;
  41851. /**
  41852. * Maximum about of steps between frames (Default: 4)
  41853. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41854. */
  41855. lockstepMaxSteps: number;
  41856. }
  41857. /**
  41858. * The null engine class provides support for headless version of babylon.js.
  41859. * This can be used in server side scenario or for testing purposes
  41860. */
  41861. export class NullEngine extends Engine {
  41862. private _options;
  41863. /**
  41864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41865. */
  41866. isDeterministicLockStep(): boolean;
  41867. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41868. getLockstepMaxSteps(): number;
  41869. /**
  41870. * Sets hardware scaling, used to save performance if needed
  41871. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41872. */
  41873. getHardwareScalingLevel(): number;
  41874. constructor(options?: NullEngineOptions);
  41875. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41876. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41877. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41878. getRenderWidth(useScreen?: boolean): number;
  41879. getRenderHeight(useScreen?: boolean): number;
  41880. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41881. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41882. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41883. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41884. bindSamplers(effect: Effect): void;
  41885. enableEffect(effect: Effect): void;
  41886. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41887. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41888. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41889. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41890. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41891. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41892. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41893. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41894. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41895. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41896. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41897. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41898. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41899. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41900. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41901. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41902. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41903. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41904. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41905. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41906. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41907. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41908. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41909. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41910. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41911. bindBuffers(vertexBuffers: {
  41912. [key: string]: VertexBuffer;
  41913. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41914. wipeCaches(bruteForce?: boolean): void;
  41915. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41916. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41917. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41918. /** @hidden */
  41919. _createTexture(): WebGLTexture;
  41920. /** @hidden */
  41921. _releaseTexture(texture: InternalTexture): void;
  41922. 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;
  41923. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41924. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41925. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41926. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41927. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41928. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41929. areAllEffectsReady(): boolean;
  41930. /**
  41931. * @hidden
  41932. * Get the current error code of the webGL context
  41933. * @returns the error code
  41934. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41935. */
  41936. getError(): number;
  41937. /** @hidden */
  41938. _getUnpackAlignement(): number;
  41939. /** @hidden */
  41940. _unpackFlipY(value: boolean): void;
  41941. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41942. /**
  41943. * Updates a dynamic vertex buffer.
  41944. * @param vertexBuffer the vertex buffer to update
  41945. * @param data the data used to update the vertex buffer
  41946. * @param byteOffset the byte offset of the data (optional)
  41947. * @param byteLength the byte length of the data (optional)
  41948. */
  41949. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41950. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41951. /** @hidden */
  41952. _bindTexture(channel: number, texture: InternalTexture): void;
  41953. /** @hidden */
  41954. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41955. releaseEffects(): void;
  41956. displayLoadingUI(): void;
  41957. hideLoadingUI(): void;
  41958. /** @hidden */
  41959. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41960. /** @hidden */
  41961. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41962. /** @hidden */
  41963. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41964. /** @hidden */
  41965. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41966. }
  41967. }
  41968. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41969. import { Nullable, int } from "babylonjs/types";
  41970. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41971. /** @hidden */
  41972. export class _OcclusionDataStorage {
  41973. /** @hidden */
  41974. occlusionInternalRetryCounter: number;
  41975. /** @hidden */
  41976. isOcclusionQueryInProgress: boolean;
  41977. /** @hidden */
  41978. isOccluded: boolean;
  41979. /** @hidden */
  41980. occlusionRetryCount: number;
  41981. /** @hidden */
  41982. occlusionType: number;
  41983. /** @hidden */
  41984. occlusionQueryAlgorithmType: number;
  41985. }
  41986. module "babylonjs/Engines/engine" {
  41987. interface Engine {
  41988. /**
  41989. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41990. * @return the new query
  41991. */
  41992. createQuery(): WebGLQuery;
  41993. /**
  41994. * Delete and release a webGL query
  41995. * @param query defines the query to delete
  41996. * @return the current engine
  41997. */
  41998. deleteQuery(query: WebGLQuery): Engine;
  41999. /**
  42000. * Check if a given query has resolved and got its value
  42001. * @param query defines the query to check
  42002. * @returns true if the query got its value
  42003. */
  42004. isQueryResultAvailable(query: WebGLQuery): boolean;
  42005. /**
  42006. * Gets the value of a given query
  42007. * @param query defines the query to check
  42008. * @returns the value of the query
  42009. */
  42010. getQueryResult(query: WebGLQuery): number;
  42011. /**
  42012. * Initiates an occlusion query
  42013. * @param algorithmType defines the algorithm to use
  42014. * @param query defines the query to use
  42015. * @returns the current engine
  42016. * @see http://doc.babylonjs.com/features/occlusionquery
  42017. */
  42018. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42019. /**
  42020. * Ends an occlusion query
  42021. * @see http://doc.babylonjs.com/features/occlusionquery
  42022. * @param algorithmType defines the algorithm to use
  42023. * @returns the current engine
  42024. */
  42025. endOcclusionQuery(algorithmType: number): Engine;
  42026. /**
  42027. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42028. * Please note that only one query can be issued at a time
  42029. * @returns a time token used to track the time span
  42030. */
  42031. startTimeQuery(): Nullable<_TimeToken>;
  42032. /**
  42033. * Ends a time query
  42034. * @param token defines the token used to measure the time span
  42035. * @returns the time spent (in ns)
  42036. */
  42037. endTimeQuery(token: _TimeToken): int;
  42038. /** @hidden */
  42039. _currentNonTimestampToken: Nullable<_TimeToken>;
  42040. /** @hidden */
  42041. _createTimeQuery(): WebGLQuery;
  42042. /** @hidden */
  42043. _deleteTimeQuery(query: WebGLQuery): void;
  42044. /** @hidden */
  42045. _getGlAlgorithmType(algorithmType: number): number;
  42046. /** @hidden */
  42047. _getTimeQueryResult(query: WebGLQuery): any;
  42048. /** @hidden */
  42049. _getTimeQueryAvailability(query: WebGLQuery): any;
  42050. }
  42051. }
  42052. module "babylonjs/Meshes/abstractMesh" {
  42053. interface AbstractMesh {
  42054. /**
  42055. * Backing filed
  42056. * @hidden
  42057. */
  42058. __occlusionDataStorage: _OcclusionDataStorage;
  42059. /**
  42060. * Access property
  42061. * @hidden
  42062. */
  42063. _occlusionDataStorage: _OcclusionDataStorage;
  42064. /**
  42065. * 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.
  42066. * The default value is -1 which means don't break the query and wait till the result
  42067. * @see http://doc.babylonjs.com/features/occlusionquery
  42068. */
  42069. occlusionRetryCount: number;
  42070. /**
  42071. * 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:
  42072. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42073. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42074. * * 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.
  42075. * @see http://doc.babylonjs.com/features/occlusionquery
  42076. */
  42077. occlusionType: number;
  42078. /**
  42079. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42080. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42081. * * 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.
  42082. * @see http://doc.babylonjs.com/features/occlusionquery
  42083. */
  42084. occlusionQueryAlgorithmType: number;
  42085. /**
  42086. * 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
  42087. * @see http://doc.babylonjs.com/features/occlusionquery
  42088. */
  42089. isOccluded: boolean;
  42090. /**
  42091. * Flag to check the progress status of the query
  42092. * @see http://doc.babylonjs.com/features/occlusionquery
  42093. */
  42094. isOcclusionQueryInProgress: boolean;
  42095. }
  42096. }
  42097. }
  42098. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42099. import { Nullable } from "babylonjs/types";
  42100. /** @hidden */
  42101. export var _forceTransformFeedbackToBundle: boolean;
  42102. module "babylonjs/Engines/engine" {
  42103. interface Engine {
  42104. /**
  42105. * Creates a webGL transform feedback object
  42106. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42107. * @returns the webGL transform feedback object
  42108. */
  42109. createTransformFeedback(): WebGLTransformFeedback;
  42110. /**
  42111. * Delete a webGL transform feedback object
  42112. * @param value defines the webGL transform feedback object to delete
  42113. */
  42114. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42115. /**
  42116. * Bind a webGL transform feedback object to the webgl context
  42117. * @param value defines the webGL transform feedback object to bind
  42118. */
  42119. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42120. /**
  42121. * Begins a transform feedback operation
  42122. * @param usePoints defines if points or triangles must be used
  42123. */
  42124. beginTransformFeedback(usePoints: boolean): void;
  42125. /**
  42126. * Ends a transform feedback operation
  42127. */
  42128. endTransformFeedback(): void;
  42129. /**
  42130. * Specify the varyings to use with transform feedback
  42131. * @param program defines the associated webGL program
  42132. * @param value defines the list of strings representing the varying names
  42133. */
  42134. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42135. /**
  42136. * Bind a webGL buffer for a transform feedback operation
  42137. * @param value defines the webGL buffer to bind
  42138. */
  42139. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42140. }
  42141. }
  42142. }
  42143. declare module "babylonjs/Engines/Extensions/index" {
  42144. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42145. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42146. }
  42147. declare module "babylonjs/Engines/index" {
  42148. export * from "babylonjs/Engines/constants";
  42149. export * from "babylonjs/Engines/engine";
  42150. export * from "babylonjs/Engines/engineStore";
  42151. export * from "babylonjs/Engines/nullEngine";
  42152. export * from "babylonjs/Engines/Extensions/index";
  42153. }
  42154. declare module "babylonjs/Events/clipboardEvents" {
  42155. /**
  42156. * Gather the list of clipboard event types as constants.
  42157. */
  42158. export class ClipboardEventTypes {
  42159. /**
  42160. * The clipboard event is fired when a copy command is active (pressed).
  42161. */
  42162. static readonly COPY: number;
  42163. /**
  42164. * The clipboard event is fired when a cut command is active (pressed).
  42165. */
  42166. static readonly CUT: number;
  42167. /**
  42168. * The clipboard event is fired when a paste command is active (pressed).
  42169. */
  42170. static readonly PASTE: number;
  42171. }
  42172. /**
  42173. * This class is used to store clipboard related info for the onClipboardObservable event.
  42174. */
  42175. export class ClipboardInfo {
  42176. /**
  42177. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42178. */
  42179. type: number;
  42180. /**
  42181. * Defines the related dom event
  42182. */
  42183. event: ClipboardEvent;
  42184. /**
  42185. *Creates an instance of ClipboardInfo.
  42186. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42187. * @param event Defines the related dom event
  42188. */
  42189. constructor(
  42190. /**
  42191. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42192. */
  42193. type: number,
  42194. /**
  42195. * Defines the related dom event
  42196. */
  42197. event: ClipboardEvent);
  42198. /**
  42199. * Get the clipboard event's type from the keycode.
  42200. * @param keyCode Defines the keyCode for the current keyboard event.
  42201. * @return {number}
  42202. */
  42203. static GetTypeFromCharacter(keyCode: number): number;
  42204. }
  42205. }
  42206. declare module "babylonjs/Events/index" {
  42207. export * from "babylonjs/Events/keyboardEvents";
  42208. export * from "babylonjs/Events/pointerEvents";
  42209. export * from "babylonjs/Events/clipboardEvents";
  42210. }
  42211. declare module "babylonjs/Loading/sceneLoader" {
  42212. import { Observable } from "babylonjs/Misc/observable";
  42213. import { Nullable } from "babylonjs/types";
  42214. import { Scene } from "babylonjs/scene";
  42215. import { Engine } from "babylonjs/Engines/engine";
  42216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42217. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42218. import { AssetContainer } from "babylonjs/assetContainer";
  42219. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42220. import { Skeleton } from "babylonjs/Bones/skeleton";
  42221. /**
  42222. * Class used to represent data loading progression
  42223. */
  42224. export class SceneLoaderProgressEvent {
  42225. /** defines if data length to load can be evaluated */
  42226. readonly lengthComputable: boolean;
  42227. /** defines the loaded data length */
  42228. readonly loaded: number;
  42229. /** defines the data length to load */
  42230. readonly total: number;
  42231. /**
  42232. * Create a new progress event
  42233. * @param lengthComputable defines if data length to load can be evaluated
  42234. * @param loaded defines the loaded data length
  42235. * @param total defines the data length to load
  42236. */
  42237. constructor(
  42238. /** defines if data length to load can be evaluated */
  42239. lengthComputable: boolean,
  42240. /** defines the loaded data length */
  42241. loaded: number,
  42242. /** defines the data length to load */
  42243. total: number);
  42244. /**
  42245. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42246. * @param event defines the source event
  42247. * @returns a new SceneLoaderProgressEvent
  42248. */
  42249. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42250. }
  42251. /**
  42252. * Interface used by SceneLoader plugins to define supported file extensions
  42253. */
  42254. export interface ISceneLoaderPluginExtensions {
  42255. /**
  42256. * Defines the list of supported extensions
  42257. */
  42258. [extension: string]: {
  42259. isBinary: boolean;
  42260. };
  42261. }
  42262. /**
  42263. * Interface used by SceneLoader plugin factory
  42264. */
  42265. export interface ISceneLoaderPluginFactory {
  42266. /**
  42267. * Defines the name of the factory
  42268. */
  42269. name: string;
  42270. /**
  42271. * Function called to create a new plugin
  42272. * @return the new plugin
  42273. */
  42274. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42275. /**
  42276. * Boolean indicating if the plugin can direct load specific data
  42277. */
  42278. canDirectLoad?: (data: string) => boolean;
  42279. }
  42280. /**
  42281. * Interface used to define a SceneLoader plugin
  42282. */
  42283. export interface ISceneLoaderPlugin {
  42284. /**
  42285. * The friendly name of this plugin.
  42286. */
  42287. name: string;
  42288. /**
  42289. * The file extensions supported by this plugin.
  42290. */
  42291. extensions: string | ISceneLoaderPluginExtensions;
  42292. /**
  42293. * Import meshes into a scene.
  42294. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42295. * @param scene The scene to import into
  42296. * @param data The data to import
  42297. * @param rootUrl The root url for scene and resources
  42298. * @param meshes The meshes array to import into
  42299. * @param particleSystems The particle systems array to import into
  42300. * @param skeletons The skeletons array to import into
  42301. * @param onError The callback when import fails
  42302. * @returns True if successful or false otherwise
  42303. */
  42304. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42305. /**
  42306. * Load into a scene.
  42307. * @param scene The scene to load into
  42308. * @param data The data to import
  42309. * @param rootUrl The root url for scene and resources
  42310. * @param onError The callback when import fails
  42311. * @returns true if successful or false otherwise
  42312. */
  42313. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42314. /**
  42315. * The callback that returns true if the data can be directly loaded.
  42316. */
  42317. canDirectLoad?: (data: string) => boolean;
  42318. /**
  42319. * The callback that allows custom handling of the root url based on the response url.
  42320. */
  42321. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42322. /**
  42323. * Load into an asset container.
  42324. * @param scene The scene to load into
  42325. * @param data The data to import
  42326. * @param rootUrl The root url for scene and resources
  42327. * @param onError The callback when import fails
  42328. * @returns The loaded asset container
  42329. */
  42330. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42331. }
  42332. /**
  42333. * Interface used to define an async SceneLoader plugin
  42334. */
  42335. export interface ISceneLoaderPluginAsync {
  42336. /**
  42337. * The friendly name of this plugin.
  42338. */
  42339. name: string;
  42340. /**
  42341. * The file extensions supported by this plugin.
  42342. */
  42343. extensions: string | ISceneLoaderPluginExtensions;
  42344. /**
  42345. * Import meshes into a scene.
  42346. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42347. * @param scene The scene to import into
  42348. * @param data The data to import
  42349. * @param rootUrl The root url for scene and resources
  42350. * @param onProgress The callback when the load progresses
  42351. * @param fileName Defines the name of the file to load
  42352. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42353. */
  42354. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42355. meshes: AbstractMesh[];
  42356. particleSystems: IParticleSystem[];
  42357. skeletons: Skeleton[];
  42358. animationGroups: AnimationGroup[];
  42359. }>;
  42360. /**
  42361. * Load into a scene.
  42362. * @param scene The scene to load into
  42363. * @param data The data to import
  42364. * @param rootUrl The root url for scene and resources
  42365. * @param onProgress The callback when the load progresses
  42366. * @param fileName Defines the name of the file to load
  42367. * @returns Nothing
  42368. */
  42369. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42370. /**
  42371. * The callback that returns true if the data can be directly loaded.
  42372. */
  42373. canDirectLoad?: (data: string) => boolean;
  42374. /**
  42375. * The callback that allows custom handling of the root url based on the response url.
  42376. */
  42377. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42378. /**
  42379. * Load into an asset container.
  42380. * @param scene The scene to load into
  42381. * @param data The data to import
  42382. * @param rootUrl The root url for scene and resources
  42383. * @param onProgress The callback when the load progresses
  42384. * @param fileName Defines the name of the file to load
  42385. * @returns The loaded asset container
  42386. */
  42387. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42388. }
  42389. /**
  42390. * Class used to load scene from various file formats using registered plugins
  42391. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42392. */
  42393. export class SceneLoader {
  42394. /**
  42395. * No logging while loading
  42396. */
  42397. static readonly NO_LOGGING: number;
  42398. /**
  42399. * Minimal logging while loading
  42400. */
  42401. static readonly MINIMAL_LOGGING: number;
  42402. /**
  42403. * Summary logging while loading
  42404. */
  42405. static readonly SUMMARY_LOGGING: number;
  42406. /**
  42407. * Detailled logging while loading
  42408. */
  42409. static readonly DETAILED_LOGGING: number;
  42410. /**
  42411. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42412. */
  42413. static ForceFullSceneLoadingForIncremental: boolean;
  42414. /**
  42415. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42416. */
  42417. static ShowLoadingScreen: boolean;
  42418. /**
  42419. * Defines the current logging level (while loading the scene)
  42420. * @ignorenaming
  42421. */
  42422. static loggingLevel: number;
  42423. /**
  42424. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42425. */
  42426. static CleanBoneMatrixWeights: boolean;
  42427. /**
  42428. * Event raised when a plugin is used to load a scene
  42429. */
  42430. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42431. private static _registeredPlugins;
  42432. private static _getDefaultPlugin;
  42433. private static _getPluginForExtension;
  42434. private static _getPluginForDirectLoad;
  42435. private static _getPluginForFilename;
  42436. private static _getDirectLoad;
  42437. private static _loadData;
  42438. private static _getFileInfo;
  42439. /**
  42440. * Gets a plugin that can load the given extension
  42441. * @param extension defines the extension to load
  42442. * @returns a plugin or null if none works
  42443. */
  42444. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42445. /**
  42446. * Gets a boolean indicating that the given extension can be loaded
  42447. * @param extension defines the extension to load
  42448. * @returns true if the extension is supported
  42449. */
  42450. static IsPluginForExtensionAvailable(extension: string): boolean;
  42451. /**
  42452. * Adds a new plugin to the list of registered plugins
  42453. * @param plugin defines the plugin to add
  42454. */
  42455. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42456. /**
  42457. * Import meshes into a scene
  42458. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42459. * @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)
  42460. * @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)
  42461. * @param scene the instance of BABYLON.Scene to append to
  42462. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42463. * @param onProgress a callback with a progress event for each file being loaded
  42464. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42465. * @param pluginExtension the extension used to determine the plugin
  42466. * @returns The loaded plugin
  42467. */
  42468. 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>;
  42469. /**
  42470. * Import meshes into a scene
  42471. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 scene the instance of BABYLON.Scene to append to
  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 list of imported meshes, particle systems, skeletons, and animation groups
  42478. */
  42479. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42480. meshes: AbstractMesh[];
  42481. particleSystems: IParticleSystem[];
  42482. skeletons: Skeleton[];
  42483. animationGroups: AnimationGroup[];
  42484. }>;
  42485. /**
  42486. * Load a scene
  42487. * @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)
  42488. * @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)
  42489. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42490. * @param onSuccess a callback with the scene when import succeeds
  42491. * @param onProgress a callback with a progress event for each file being loaded
  42492. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42493. * @param pluginExtension the extension used to determine the plugin
  42494. * @returns The loaded plugin
  42495. */
  42496. 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>;
  42497. /**
  42498. * Load a scene
  42499. * @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)
  42500. * @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)
  42501. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42502. * @param onProgress a callback with a progress event for each file being loaded
  42503. * @param pluginExtension the extension used to determine the plugin
  42504. * @returns The loaded scene
  42505. */
  42506. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42507. /**
  42508. * Append a scene
  42509. * @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)
  42510. * @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)
  42511. * @param scene is the instance of BABYLON.Scene to append to
  42512. * @param onSuccess a callback with the scene when import succeeds
  42513. * @param onProgress a callback with a progress event for each file being loaded
  42514. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42515. * @param pluginExtension the extension used to determine the plugin
  42516. * @returns The loaded plugin
  42517. */
  42518. 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>;
  42519. /**
  42520. * Append a scene
  42521. * @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)
  42522. * @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)
  42523. * @param scene is the instance of BABYLON.Scene to append to
  42524. * @param onProgress a callback with a progress event for each file being loaded
  42525. * @param pluginExtension the extension used to determine the plugin
  42526. * @returns The given scene
  42527. */
  42528. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42529. /**
  42530. * Load a scene into an asset container
  42531. * @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)
  42532. * @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)
  42533. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42534. * @param onSuccess a callback with the scene when import succeeds
  42535. * @param onProgress a callback with a progress event for each file being loaded
  42536. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42537. * @param pluginExtension the extension used to determine the plugin
  42538. * @returns The loaded plugin
  42539. */
  42540. 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>;
  42541. /**
  42542. * Load a scene into an asset container
  42543. * @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)
  42544. * @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)
  42545. * @param scene is the instance of Scene to append to
  42546. * @param onProgress a callback with a progress event for each file being loaded
  42547. * @param pluginExtension the extension used to determine the plugin
  42548. * @returns The loaded asset container
  42549. */
  42550. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42551. }
  42552. }
  42553. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42554. import { Scene } from "babylonjs/scene";
  42555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42556. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42557. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42558. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42559. /**
  42560. * Google Daydream controller
  42561. */
  42562. export class DaydreamController extends WebVRController {
  42563. /**
  42564. * Base Url for the controller model.
  42565. */
  42566. static MODEL_BASE_URL: string;
  42567. /**
  42568. * File name for the controller model.
  42569. */
  42570. static MODEL_FILENAME: string;
  42571. /**
  42572. * Gamepad Id prefix used to identify Daydream Controller.
  42573. */
  42574. static readonly GAMEPAD_ID_PREFIX: string;
  42575. /**
  42576. * Creates a new DaydreamController from a gamepad
  42577. * @param vrGamepad the gamepad that the controller should be created from
  42578. */
  42579. constructor(vrGamepad: any);
  42580. /**
  42581. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42582. * @param scene scene in which to add meshes
  42583. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42584. */
  42585. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42586. /**
  42587. * Called once for each button that changed state since the last frame
  42588. * @param buttonIdx Which button index changed
  42589. * @param state New state of the button
  42590. * @param changes Which properties on the state changed since last frame
  42591. */
  42592. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42593. }
  42594. }
  42595. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42596. import { Scene } from "babylonjs/scene";
  42597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42598. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42599. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42600. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42601. /**
  42602. * Gear VR Controller
  42603. */
  42604. export class GearVRController extends WebVRController {
  42605. /**
  42606. * Base Url for the controller model.
  42607. */
  42608. static MODEL_BASE_URL: string;
  42609. /**
  42610. * File name for the controller model.
  42611. */
  42612. static MODEL_FILENAME: string;
  42613. /**
  42614. * Gamepad Id prefix used to identify this controller.
  42615. */
  42616. static readonly GAMEPAD_ID_PREFIX: string;
  42617. private readonly _buttonIndexToObservableNameMap;
  42618. /**
  42619. * Creates a new GearVRController from a gamepad
  42620. * @param vrGamepad the gamepad that the controller should be created from
  42621. */
  42622. constructor(vrGamepad: any);
  42623. /**
  42624. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42625. * @param scene scene in which to add meshes
  42626. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42627. */
  42628. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42629. /**
  42630. * Called once for each button that changed state since the last frame
  42631. * @param buttonIdx Which button index changed
  42632. * @param state New state of the button
  42633. * @param changes Which properties on the state changed since last frame
  42634. */
  42635. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42636. }
  42637. }
  42638. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42639. import { Scene } from "babylonjs/scene";
  42640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42641. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42642. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42643. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42644. /**
  42645. * Generic Controller
  42646. */
  42647. export class GenericController extends WebVRController {
  42648. /**
  42649. * Base Url for the controller model.
  42650. */
  42651. static readonly MODEL_BASE_URL: string;
  42652. /**
  42653. * File name for the controller model.
  42654. */
  42655. static readonly MODEL_FILENAME: string;
  42656. /**
  42657. * Creates a new GenericController from a gamepad
  42658. * @param vrGamepad the gamepad that the controller should be created from
  42659. */
  42660. constructor(vrGamepad: any);
  42661. /**
  42662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42663. * @param scene scene in which to add meshes
  42664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42665. */
  42666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42667. /**
  42668. * Called once for each button that changed state since the last frame
  42669. * @param buttonIdx Which button index changed
  42670. * @param state New state of the button
  42671. * @param changes Which properties on the state changed since last frame
  42672. */
  42673. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42674. }
  42675. }
  42676. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42677. import { Observable } from "babylonjs/Misc/observable";
  42678. import { Scene } from "babylonjs/scene";
  42679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42680. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42681. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42682. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42683. /**
  42684. * Oculus Touch Controller
  42685. */
  42686. export class OculusTouchController extends WebVRController {
  42687. /**
  42688. * Base Url for the controller model.
  42689. */
  42690. static MODEL_BASE_URL: string;
  42691. /**
  42692. * File name for the left controller model.
  42693. */
  42694. static MODEL_LEFT_FILENAME: string;
  42695. /**
  42696. * File name for the right controller model.
  42697. */
  42698. static MODEL_RIGHT_FILENAME: string;
  42699. /**
  42700. * Fired when the secondary trigger on this controller is modified
  42701. */
  42702. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42703. /**
  42704. * Fired when the thumb rest on this controller is modified
  42705. */
  42706. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42707. /**
  42708. * Creates a new OculusTouchController from a gamepad
  42709. * @param vrGamepad the gamepad that the controller should be created from
  42710. */
  42711. constructor(vrGamepad: any);
  42712. /**
  42713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42714. * @param scene scene in which to add meshes
  42715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42716. */
  42717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42718. /**
  42719. * Fired when the A button on this controller is modified
  42720. */
  42721. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42722. /**
  42723. * Fired when the B button on this controller is modified
  42724. */
  42725. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42726. /**
  42727. * Fired when the X button on this controller is modified
  42728. */
  42729. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42730. /**
  42731. * Fired when the Y button on this controller is modified
  42732. */
  42733. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42734. /**
  42735. * Called once for each button that changed state since the last frame
  42736. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42737. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42738. * 2) secondary trigger (same)
  42739. * 3) A (right) X (left), touch, pressed = value
  42740. * 4) B / Y
  42741. * 5) thumb rest
  42742. * @param buttonIdx Which button index changed
  42743. * @param state New state of the button
  42744. * @param changes Which properties on the state changed since last frame
  42745. */
  42746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42747. }
  42748. }
  42749. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42750. import { Scene } from "babylonjs/scene";
  42751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42752. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42753. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42754. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42755. import { Observable } from "babylonjs/Misc/observable";
  42756. /**
  42757. * Vive Controller
  42758. */
  42759. export class ViveController extends WebVRController {
  42760. /**
  42761. * Base Url for the controller model.
  42762. */
  42763. static MODEL_BASE_URL: string;
  42764. /**
  42765. * File name for the controller model.
  42766. */
  42767. static MODEL_FILENAME: string;
  42768. /**
  42769. * Creates a new ViveController from a gamepad
  42770. * @param vrGamepad the gamepad that the controller should be created from
  42771. */
  42772. constructor(vrGamepad: any);
  42773. /**
  42774. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42775. * @param scene scene in which to add meshes
  42776. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42777. */
  42778. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42779. /**
  42780. * Fired when the left button on this controller is modified
  42781. */
  42782. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42783. /**
  42784. * Fired when the right button on this controller is modified
  42785. */
  42786. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42787. /**
  42788. * Fired when the menu button on this controller is modified
  42789. */
  42790. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42791. /**
  42792. * Called once for each button that changed state since the last frame
  42793. * Vive mapping:
  42794. * 0: touchpad
  42795. * 1: trigger
  42796. * 2: left AND right buttons
  42797. * 3: menu button
  42798. * @param buttonIdx Which button index changed
  42799. * @param state New state of the button
  42800. * @param changes Which properties on the state changed since last frame
  42801. */
  42802. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42803. }
  42804. }
  42805. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42806. import { Observable } from "babylonjs/Misc/observable";
  42807. import { Scene } from "babylonjs/scene";
  42808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42809. import { Ray } from "babylonjs/Culling/ray";
  42810. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42811. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42812. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42813. /**
  42814. * Defines the WindowsMotionController object that the state of the windows motion controller
  42815. */
  42816. export class WindowsMotionController extends WebVRController {
  42817. /**
  42818. * The base url used to load the left and right controller models
  42819. */
  42820. static MODEL_BASE_URL: string;
  42821. /**
  42822. * The name of the left controller model file
  42823. */
  42824. static MODEL_LEFT_FILENAME: string;
  42825. /**
  42826. * The name of the right controller model file
  42827. */
  42828. static MODEL_RIGHT_FILENAME: string;
  42829. /**
  42830. * The controller name prefix for this controller type
  42831. */
  42832. static readonly GAMEPAD_ID_PREFIX: string;
  42833. /**
  42834. * The controller id pattern for this controller type
  42835. */
  42836. private static readonly GAMEPAD_ID_PATTERN;
  42837. private _loadedMeshInfo;
  42838. private readonly _mapping;
  42839. /**
  42840. * Fired when the trackpad on this controller is clicked
  42841. */
  42842. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42843. /**
  42844. * Fired when the trackpad on this controller is modified
  42845. */
  42846. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42847. /**
  42848. * The current x and y values of this controller's trackpad
  42849. */
  42850. trackpad: StickValues;
  42851. /**
  42852. * Creates a new WindowsMotionController from a gamepad
  42853. * @param vrGamepad the gamepad that the controller should be created from
  42854. */
  42855. constructor(vrGamepad: any);
  42856. /**
  42857. * Fired when the trigger on this controller is modified
  42858. */
  42859. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42860. /**
  42861. * Fired when the menu button on this controller is modified
  42862. */
  42863. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42864. /**
  42865. * Fired when the grip button on this controller is modified
  42866. */
  42867. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42868. /**
  42869. * Fired when the thumbstick button on this controller is modified
  42870. */
  42871. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42872. /**
  42873. * Fired when the touchpad button on this controller is modified
  42874. */
  42875. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42876. /**
  42877. * Fired when the touchpad values on this controller are modified
  42878. */
  42879. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42880. private _updateTrackpad;
  42881. /**
  42882. * Called once per frame by the engine.
  42883. */
  42884. update(): void;
  42885. /**
  42886. * Called once for each button that changed state since the last frame
  42887. * @param buttonIdx Which button index changed
  42888. * @param state New state of the button
  42889. * @param changes Which properties on the state changed since last frame
  42890. */
  42891. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42892. /**
  42893. * Moves the buttons on the controller mesh based on their current state
  42894. * @param buttonName the name of the button to move
  42895. * @param buttonValue the value of the button which determines the buttons new position
  42896. */
  42897. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42898. /**
  42899. * Moves the axis on the controller mesh based on its current state
  42900. * @param axis the index of the axis
  42901. * @param axisValue the value of the axis which determines the meshes new position
  42902. * @hidden
  42903. */
  42904. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42905. /**
  42906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42907. * @param scene scene in which to add meshes
  42908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42909. */
  42910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42911. /**
  42912. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42913. * can be transformed by button presses and axes values, based on this._mapping.
  42914. *
  42915. * @param scene scene in which the meshes exist
  42916. * @param meshes list of meshes that make up the controller model to process
  42917. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42918. */
  42919. private processModel;
  42920. private createMeshInfo;
  42921. /**
  42922. * Gets the ray of the controller in the direction the controller is pointing
  42923. * @param length the length the resulting ray should be
  42924. * @returns a ray in the direction the controller is pointing
  42925. */
  42926. getForwardRay(length?: number): Ray;
  42927. /**
  42928. * Disposes of the controller
  42929. */
  42930. dispose(): void;
  42931. }
  42932. }
  42933. declare module "babylonjs/Gamepads/Controllers/index" {
  42934. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42935. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42936. export * from "babylonjs/Gamepads/Controllers/genericController";
  42937. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42938. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42939. export * from "babylonjs/Gamepads/Controllers/viveController";
  42940. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42941. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42942. }
  42943. declare module "babylonjs/Gamepads/index" {
  42944. export * from "babylonjs/Gamepads/Controllers/index";
  42945. export * from "babylonjs/Gamepads/gamepad";
  42946. export * from "babylonjs/Gamepads/gamepadManager";
  42947. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42948. export * from "babylonjs/Gamepads/xboxGamepad";
  42949. }
  42950. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42951. import { Observable } from "babylonjs/Misc/observable";
  42952. import { Nullable } from "babylonjs/types";
  42953. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42955. import { Mesh } from "babylonjs/Meshes/mesh";
  42956. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42958. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42959. /**
  42960. * Single axis scale gizmo
  42961. */
  42962. export class AxisScaleGizmo extends Gizmo {
  42963. private _coloredMaterial;
  42964. /**
  42965. * Drag behavior responsible for the gizmos dragging interactions
  42966. */
  42967. dragBehavior: PointerDragBehavior;
  42968. private _pointerObserver;
  42969. /**
  42970. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42971. */
  42972. snapDistance: number;
  42973. /**
  42974. * Event that fires each time the gizmo snaps to a new location.
  42975. * * snapDistance is the the change in distance
  42976. */
  42977. onSnapObservable: Observable<{
  42978. snapDistance: number;
  42979. }>;
  42980. /**
  42981. * If the scaling operation should be done on all axis (default: false)
  42982. */
  42983. uniformScaling: boolean;
  42984. /**
  42985. * Creates an AxisScaleGizmo
  42986. * @param gizmoLayer The utility layer the gizmo will be added to
  42987. * @param dragAxis The axis which the gizmo will be able to scale on
  42988. * @param color The color of the gizmo
  42989. */
  42990. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42991. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42992. /**
  42993. * Disposes of the gizmo
  42994. */
  42995. dispose(): void;
  42996. /**
  42997. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42998. * @param mesh The mesh to replace the default mesh of the gizmo
  42999. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43000. */
  43001. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43002. }
  43003. }
  43004. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43005. import { Observable } from "babylonjs/Misc/observable";
  43006. import { Nullable } from "babylonjs/types";
  43007. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43009. import { Mesh } from "babylonjs/Meshes/mesh";
  43010. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43011. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43012. import "babylonjs/Meshes/Builders/boxBuilder";
  43013. /**
  43014. * Bounding box gizmo
  43015. */
  43016. export class BoundingBoxGizmo extends Gizmo {
  43017. private _lineBoundingBox;
  43018. private _rotateSpheresParent;
  43019. private _scaleBoxesParent;
  43020. private _boundingDimensions;
  43021. private _renderObserver;
  43022. private _pointerObserver;
  43023. private _scaleDragSpeed;
  43024. private _tmpQuaternion;
  43025. private _tmpVector;
  43026. private _tmpRotationMatrix;
  43027. /**
  43028. * 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)
  43029. */
  43030. ignoreChildren: boolean;
  43031. /**
  43032. * 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)
  43033. */
  43034. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43035. /**
  43036. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43037. */
  43038. rotationSphereSize: number;
  43039. /**
  43040. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43041. */
  43042. scaleBoxSize: number;
  43043. /**
  43044. * 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)
  43045. */
  43046. fixedDragMeshScreenSize: boolean;
  43047. /**
  43048. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43049. */
  43050. fixedDragMeshScreenSizeDistanceFactor: number;
  43051. /**
  43052. * Fired when a rotation sphere or scale box is dragged
  43053. */
  43054. onDragStartObservable: Observable<{}>;
  43055. /**
  43056. * Fired when a scale box is dragged
  43057. */
  43058. onScaleBoxDragObservable: Observable<{}>;
  43059. /**
  43060. * Fired when a scale box drag is ended
  43061. */
  43062. onScaleBoxDragEndObservable: Observable<{}>;
  43063. /**
  43064. * Fired when a rotation sphere is dragged
  43065. */
  43066. onRotationSphereDragObservable: Observable<{}>;
  43067. /**
  43068. * Fired when a rotation sphere drag is ended
  43069. */
  43070. onRotationSphereDragEndObservable: Observable<{}>;
  43071. /**
  43072. * 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)
  43073. */
  43074. scalePivot: Nullable<Vector3>;
  43075. private _anchorMesh;
  43076. private _existingMeshScale;
  43077. private _dragMesh;
  43078. private pointerDragBehavior;
  43079. private coloredMaterial;
  43080. private hoverColoredMaterial;
  43081. /**
  43082. * Sets the color of the bounding box gizmo
  43083. * @param color the color to set
  43084. */
  43085. setColor(color: Color3): void;
  43086. /**
  43087. * Creates an BoundingBoxGizmo
  43088. * @param gizmoLayer The utility layer the gizmo will be added to
  43089. * @param color The color of the gizmo
  43090. */
  43091. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43093. private _selectNode;
  43094. /**
  43095. * Updates the bounding box information for the Gizmo
  43096. */
  43097. updateBoundingBox(): void;
  43098. private _updateRotationSpheres;
  43099. private _updateScaleBoxes;
  43100. /**
  43101. * Enables rotation on the specified axis and disables rotation on the others
  43102. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43103. */
  43104. setEnabledRotationAxis(axis: string): void;
  43105. /**
  43106. * Enables/disables scaling
  43107. * @param enable if scaling should be enabled
  43108. */
  43109. setEnabledScaling(enable: boolean): void;
  43110. private _updateDummy;
  43111. /**
  43112. * Enables a pointer drag behavior on the bounding box of the gizmo
  43113. */
  43114. enableDragBehavior(): void;
  43115. /**
  43116. * Disposes of the gizmo
  43117. */
  43118. dispose(): void;
  43119. /**
  43120. * 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)
  43121. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43122. * @returns the bounding box mesh with the passed in mesh as a child
  43123. */
  43124. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43125. /**
  43126. * CustomMeshes are not supported by this gizmo
  43127. * @param mesh The mesh to replace the default mesh of the gizmo
  43128. */
  43129. setCustomMesh(mesh: Mesh): void;
  43130. }
  43131. }
  43132. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43133. import { Observable } from "babylonjs/Misc/observable";
  43134. import { Nullable } from "babylonjs/types";
  43135. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43137. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43138. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43139. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43140. import "babylonjs/Meshes/Builders/linesBuilder";
  43141. /**
  43142. * Single plane rotation gizmo
  43143. */
  43144. export class PlaneRotationGizmo extends Gizmo {
  43145. /**
  43146. * Drag behavior responsible for the gizmos dragging interactions
  43147. */
  43148. dragBehavior: PointerDragBehavior;
  43149. private _pointerObserver;
  43150. /**
  43151. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43152. */
  43153. snapDistance: number;
  43154. /**
  43155. * Event that fires each time the gizmo snaps to a new location.
  43156. * * snapDistance is the the change in distance
  43157. */
  43158. onSnapObservable: Observable<{
  43159. snapDistance: number;
  43160. }>;
  43161. /**
  43162. * Creates a PlaneRotationGizmo
  43163. * @param gizmoLayer The utility layer the gizmo will be added to
  43164. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43165. * @param color The color of the gizmo
  43166. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43167. */
  43168. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43170. /**
  43171. * Disposes of the gizmo
  43172. */
  43173. dispose(): void;
  43174. }
  43175. }
  43176. declare module "babylonjs/Gizmos/rotationGizmo" {
  43177. import { Observable } from "babylonjs/Misc/observable";
  43178. import { Nullable } from "babylonjs/types";
  43179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43180. import { Mesh } from "babylonjs/Meshes/mesh";
  43181. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43182. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43183. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43184. /**
  43185. * Gizmo that enables rotating a mesh along 3 axis
  43186. */
  43187. export class RotationGizmo extends Gizmo {
  43188. /**
  43189. * Internal gizmo used for interactions on the x axis
  43190. */
  43191. xGizmo: PlaneRotationGizmo;
  43192. /**
  43193. * Internal gizmo used for interactions on the y axis
  43194. */
  43195. yGizmo: PlaneRotationGizmo;
  43196. /**
  43197. * Internal gizmo used for interactions on the z axis
  43198. */
  43199. zGizmo: PlaneRotationGizmo;
  43200. /** Fires an event when any of it's sub gizmos are dragged */
  43201. onDragStartObservable: Observable<{}>;
  43202. /** Fires an event when any of it's sub gizmos are released from dragging */
  43203. onDragEndObservable: Observable<{}>;
  43204. attachedMesh: Nullable<AbstractMesh>;
  43205. /**
  43206. * Creates a RotationGizmo
  43207. * @param gizmoLayer The utility layer the gizmo will be added to
  43208. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43209. */
  43210. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43211. updateGizmoRotationToMatchAttachedMesh: boolean;
  43212. /**
  43213. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43214. */
  43215. snapDistance: number;
  43216. /**
  43217. * Ratio for the scale of the gizmo (Default: 1)
  43218. */
  43219. scaleRatio: number;
  43220. /**
  43221. * Disposes of the gizmo
  43222. */
  43223. dispose(): void;
  43224. /**
  43225. * CustomMeshes are not supported by this gizmo
  43226. * @param mesh The mesh to replace the default mesh of the gizmo
  43227. */
  43228. setCustomMesh(mesh: Mesh): void;
  43229. }
  43230. }
  43231. declare module "babylonjs/Gizmos/positionGizmo" {
  43232. import { Observable } from "babylonjs/Misc/observable";
  43233. import { Nullable } from "babylonjs/types";
  43234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43235. import { Mesh } from "babylonjs/Meshes/mesh";
  43236. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43237. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43238. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43239. /**
  43240. * Gizmo that enables dragging a mesh along 3 axis
  43241. */
  43242. export class PositionGizmo extends Gizmo {
  43243. /**
  43244. * Internal gizmo used for interactions on the x axis
  43245. */
  43246. xGizmo: AxisDragGizmo;
  43247. /**
  43248. * Internal gizmo used for interactions on the y axis
  43249. */
  43250. yGizmo: AxisDragGizmo;
  43251. /**
  43252. * Internal gizmo used for interactions on the z axis
  43253. */
  43254. zGizmo: AxisDragGizmo;
  43255. /** Fires an event when any of it's sub gizmos are dragged */
  43256. onDragStartObservable: Observable<{}>;
  43257. /** Fires an event when any of it's sub gizmos are released from dragging */
  43258. onDragEndObservable: Observable<{}>;
  43259. attachedMesh: Nullable<AbstractMesh>;
  43260. /**
  43261. * Creates a PositionGizmo
  43262. * @param gizmoLayer The utility layer the gizmo will be added to
  43263. */
  43264. constructor(gizmoLayer?: UtilityLayerRenderer);
  43265. updateGizmoRotationToMatchAttachedMesh: boolean;
  43266. /**
  43267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43268. */
  43269. snapDistance: number;
  43270. /**
  43271. * Ratio for the scale of the gizmo (Default: 1)
  43272. */
  43273. scaleRatio: number;
  43274. /**
  43275. * Disposes of the gizmo
  43276. */
  43277. dispose(): void;
  43278. /**
  43279. * CustomMeshes are not supported by this gizmo
  43280. * @param mesh The mesh to replace the default mesh of the gizmo
  43281. */
  43282. setCustomMesh(mesh: Mesh): void;
  43283. }
  43284. }
  43285. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43286. import { Scene } from "babylonjs/scene";
  43287. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43288. import { Mesh } from "babylonjs/Meshes/mesh";
  43289. /**
  43290. * Class containing static functions to help procedurally build meshes
  43291. */
  43292. export class PolyhedronBuilder {
  43293. /**
  43294. * Creates a polyhedron mesh
  43295. * * 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
  43296. * * The parameter `size` (positive float, default 1) sets the polygon size
  43297. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43298. * * 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`
  43299. * * 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
  43300. * * 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)`)
  43301. * * 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
  43302. * * 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
  43303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43304. * * If you create a double-sided mesh, you can choose what parts of 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
  43305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43306. * @param name defines the name of the mesh
  43307. * @param options defines the options used to create the mesh
  43308. * @param scene defines the hosting scene
  43309. * @returns the polyhedron mesh
  43310. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43311. */
  43312. static CreatePolyhedron(name: string, options: {
  43313. type?: number;
  43314. size?: number;
  43315. sizeX?: number;
  43316. sizeY?: number;
  43317. sizeZ?: number;
  43318. custom?: any;
  43319. faceUV?: Vector4[];
  43320. faceColors?: Color4[];
  43321. flat?: boolean;
  43322. updatable?: boolean;
  43323. sideOrientation?: number;
  43324. frontUVs?: Vector4;
  43325. backUVs?: Vector4;
  43326. }, scene: Scene): Mesh;
  43327. }
  43328. }
  43329. declare module "babylonjs/Gizmos/scaleGizmo" {
  43330. import { Observable } from "babylonjs/Misc/observable";
  43331. import { Nullable } from "babylonjs/types";
  43332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43333. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43334. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43335. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43336. /**
  43337. * Gizmo that enables scaling a mesh along 3 axis
  43338. */
  43339. export class ScaleGizmo extends Gizmo {
  43340. /**
  43341. * Internal gizmo used for interactions on the x axis
  43342. */
  43343. xGizmo: AxisScaleGizmo;
  43344. /**
  43345. * Internal gizmo used for interactions on the y axis
  43346. */
  43347. yGizmo: AxisScaleGizmo;
  43348. /**
  43349. * Internal gizmo used for interactions on the z axis
  43350. */
  43351. zGizmo: AxisScaleGizmo;
  43352. /**
  43353. * Internal gizmo used to scale all axis equally
  43354. */
  43355. uniformScaleGizmo: AxisScaleGizmo;
  43356. /** Fires an event when any of it's sub gizmos are dragged */
  43357. onDragStartObservable: Observable<{}>;
  43358. /** Fires an event when any of it's sub gizmos are released from dragging */
  43359. onDragEndObservable: Observable<{}>;
  43360. attachedMesh: Nullable<AbstractMesh>;
  43361. /**
  43362. * Creates a ScaleGizmo
  43363. * @param gizmoLayer The utility layer the gizmo will be added to
  43364. */
  43365. constructor(gizmoLayer?: UtilityLayerRenderer);
  43366. updateGizmoRotationToMatchAttachedMesh: boolean;
  43367. /**
  43368. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43369. */
  43370. snapDistance: number;
  43371. /**
  43372. * Ratio for the scale of the gizmo (Default: 1)
  43373. */
  43374. scaleRatio: number;
  43375. /**
  43376. * Disposes of the gizmo
  43377. */
  43378. dispose(): void;
  43379. }
  43380. }
  43381. declare module "babylonjs/Gizmos/gizmoManager" {
  43382. import { Observable } from "babylonjs/Misc/observable";
  43383. import { Nullable } from "babylonjs/types";
  43384. import { Scene, IDisposable } from "babylonjs/scene";
  43385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43386. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43387. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43388. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43389. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43390. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43391. /**
  43392. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43393. */
  43394. export class GizmoManager implements IDisposable {
  43395. private scene;
  43396. /**
  43397. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43398. */
  43399. gizmos: {
  43400. positionGizmo: Nullable<PositionGizmo>;
  43401. rotationGizmo: Nullable<RotationGizmo>;
  43402. scaleGizmo: Nullable<ScaleGizmo>;
  43403. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43404. };
  43405. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43406. clearGizmoOnEmptyPointerEvent: boolean;
  43407. /** Fires an event when the manager is attached to a mesh */
  43408. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43409. private _gizmosEnabled;
  43410. private _pointerObserver;
  43411. private _attachedMesh;
  43412. private _boundingBoxColor;
  43413. private _defaultUtilityLayer;
  43414. private _defaultKeepDepthUtilityLayer;
  43415. /**
  43416. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43417. */
  43418. boundingBoxDragBehavior: SixDofDragBehavior;
  43419. /**
  43420. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43421. */
  43422. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43423. /**
  43424. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43425. */
  43426. usePointerToAttachGizmos: boolean;
  43427. /**
  43428. * Instatiates a gizmo manager
  43429. * @param scene the scene to overlay the gizmos on top of
  43430. */
  43431. constructor(scene: Scene);
  43432. /**
  43433. * Attaches a set of gizmos to the specified mesh
  43434. * @param mesh The mesh the gizmo's should be attached to
  43435. */
  43436. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43437. /**
  43438. * If the position gizmo is enabled
  43439. */
  43440. positionGizmoEnabled: boolean;
  43441. /**
  43442. * If the rotation gizmo is enabled
  43443. */
  43444. rotationGizmoEnabled: boolean;
  43445. /**
  43446. * If the scale gizmo is enabled
  43447. */
  43448. scaleGizmoEnabled: boolean;
  43449. /**
  43450. * If the boundingBox gizmo is enabled
  43451. */
  43452. boundingBoxGizmoEnabled: boolean;
  43453. /**
  43454. * Disposes of the gizmo manager
  43455. */
  43456. dispose(): void;
  43457. }
  43458. }
  43459. declare module "babylonjs/Gizmos/lightGizmo" {
  43460. import { Nullable } from "babylonjs/types";
  43461. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43462. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43463. import { Light } from "babylonjs/Lights/light";
  43464. /**
  43465. * Gizmo that enables viewing a light
  43466. */
  43467. export class LightGizmo extends Gizmo {
  43468. private _box;
  43469. /**
  43470. * Creates a LightGizmo
  43471. * @param gizmoLayer The utility layer the gizmo will be added to
  43472. */
  43473. constructor(gizmoLayer?: UtilityLayerRenderer);
  43474. private _light;
  43475. /**
  43476. * The light that the gizmo is attached to
  43477. */
  43478. light: Nullable<Light>;
  43479. /**
  43480. * @hidden
  43481. * Updates the gizmo to match the attached mesh's position/rotation
  43482. */
  43483. protected _update(): void;
  43484. }
  43485. }
  43486. declare module "babylonjs/Gizmos/index" {
  43487. export * from "babylonjs/Gizmos/axisDragGizmo";
  43488. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43489. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43490. export * from "babylonjs/Gizmos/gizmo";
  43491. export * from "babylonjs/Gizmos/gizmoManager";
  43492. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43493. export * from "babylonjs/Gizmos/positionGizmo";
  43494. export * from "babylonjs/Gizmos/rotationGizmo";
  43495. export * from "babylonjs/Gizmos/scaleGizmo";
  43496. export * from "babylonjs/Gizmos/lightGizmo";
  43497. }
  43498. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43499. /** @hidden */
  43500. export var backgroundFragmentDeclaration: {
  43501. name: string;
  43502. shader: string;
  43503. };
  43504. }
  43505. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43506. /** @hidden */
  43507. export var backgroundUboDeclaration: {
  43508. name: string;
  43509. shader: string;
  43510. };
  43511. }
  43512. declare module "babylonjs/Shaders/background.fragment" {
  43513. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43514. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43515. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43516. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43517. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43518. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43520. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43521. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43522. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43523. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43524. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43525. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43526. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43527. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43528. /** @hidden */
  43529. export var backgroundPixelShader: {
  43530. name: string;
  43531. shader: string;
  43532. };
  43533. }
  43534. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43535. /** @hidden */
  43536. export var backgroundVertexDeclaration: {
  43537. name: string;
  43538. shader: string;
  43539. };
  43540. }
  43541. declare module "babylonjs/Shaders/background.vertex" {
  43542. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43543. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43544. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43546. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43547. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43548. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43549. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43550. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43551. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43552. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43553. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43554. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43555. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43556. /** @hidden */
  43557. export var backgroundVertexShader: {
  43558. name: string;
  43559. shader: string;
  43560. };
  43561. }
  43562. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43563. import { Nullable, int, float } from "babylonjs/types";
  43564. import { Scene } from "babylonjs/scene";
  43565. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43566. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43568. import { Mesh } from "babylonjs/Meshes/mesh";
  43569. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43570. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43571. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43573. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43574. import "babylonjs/Shaders/background.fragment";
  43575. import "babylonjs/Shaders/background.vertex";
  43576. /**
  43577. * Background material used to create an efficient environement around your scene.
  43578. */
  43579. export class BackgroundMaterial extends PushMaterial {
  43580. /**
  43581. * Standard reflectance value at parallel view angle.
  43582. */
  43583. static StandardReflectance0: number;
  43584. /**
  43585. * Standard reflectance value at grazing angle.
  43586. */
  43587. static StandardReflectance90: number;
  43588. protected _primaryColor: Color3;
  43589. /**
  43590. * Key light Color (multiply against the environement texture)
  43591. */
  43592. primaryColor: Color3;
  43593. protected __perceptualColor: Nullable<Color3>;
  43594. /**
  43595. * Experimental Internal Use Only.
  43596. *
  43597. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43598. * This acts as a helper to set the primary color to a more "human friendly" value.
  43599. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43600. * output color as close as possible from the chosen value.
  43601. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43602. * part of lighting setup.)
  43603. */
  43604. _perceptualColor: Nullable<Color3>;
  43605. protected _primaryColorShadowLevel: float;
  43606. /**
  43607. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43608. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43609. */
  43610. primaryColorShadowLevel: float;
  43611. protected _primaryColorHighlightLevel: float;
  43612. /**
  43613. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43614. * The primary color is used at the level chosen to define what the white area would look.
  43615. */
  43616. primaryColorHighlightLevel: float;
  43617. protected _reflectionTexture: Nullable<BaseTexture>;
  43618. /**
  43619. * Reflection Texture used in the material.
  43620. * Should be author in a specific way for the best result (refer to the documentation).
  43621. */
  43622. reflectionTexture: Nullable<BaseTexture>;
  43623. protected _reflectionBlur: float;
  43624. /**
  43625. * Reflection Texture level of blur.
  43626. *
  43627. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43628. * texture twice.
  43629. */
  43630. reflectionBlur: float;
  43631. protected _diffuseTexture: Nullable<BaseTexture>;
  43632. /**
  43633. * Diffuse Texture used in the material.
  43634. * Should be author in a specific way for the best result (refer to the documentation).
  43635. */
  43636. diffuseTexture: Nullable<BaseTexture>;
  43637. protected _shadowLights: Nullable<IShadowLight[]>;
  43638. /**
  43639. * Specify the list of lights casting shadow on the material.
  43640. * All scene shadow lights will be included if null.
  43641. */
  43642. shadowLights: Nullable<IShadowLight[]>;
  43643. protected _shadowLevel: float;
  43644. /**
  43645. * Helps adjusting the shadow to a softer level if required.
  43646. * 0 means black shadows and 1 means no shadows.
  43647. */
  43648. shadowLevel: float;
  43649. protected _sceneCenter: Vector3;
  43650. /**
  43651. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43652. * It is usually zero but might be interesting to modify according to your setup.
  43653. */
  43654. sceneCenter: Vector3;
  43655. protected _opacityFresnel: boolean;
  43656. /**
  43657. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43658. * This helps ensuring a nice transition when the camera goes under the ground.
  43659. */
  43660. opacityFresnel: boolean;
  43661. protected _reflectionFresnel: boolean;
  43662. /**
  43663. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43664. * This helps adding a mirror texture on the ground.
  43665. */
  43666. reflectionFresnel: boolean;
  43667. protected _reflectionFalloffDistance: number;
  43668. /**
  43669. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43670. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43671. */
  43672. reflectionFalloffDistance: number;
  43673. protected _reflectionAmount: number;
  43674. /**
  43675. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43676. */
  43677. reflectionAmount: number;
  43678. protected _reflectionReflectance0: number;
  43679. /**
  43680. * This specifies the weight of the reflection at grazing angle.
  43681. */
  43682. reflectionReflectance0: number;
  43683. protected _reflectionReflectance90: number;
  43684. /**
  43685. * This specifies the weight of the reflection at a perpendicular point of view.
  43686. */
  43687. reflectionReflectance90: number;
  43688. /**
  43689. * Sets the reflection reflectance fresnel values according to the default standard
  43690. * empirically know to work well :-)
  43691. */
  43692. reflectionStandardFresnelWeight: number;
  43693. protected _useRGBColor: boolean;
  43694. /**
  43695. * Helps to directly use the maps channels instead of their level.
  43696. */
  43697. useRGBColor: boolean;
  43698. protected _enableNoise: boolean;
  43699. /**
  43700. * This helps reducing the banding effect that could occur on the background.
  43701. */
  43702. enableNoise: boolean;
  43703. /**
  43704. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43705. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43706. * Recommended to be keep at 1.0 except for special cases.
  43707. */
  43708. fovMultiplier: number;
  43709. private _fovMultiplier;
  43710. /**
  43711. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43712. */
  43713. useEquirectangularFOV: boolean;
  43714. private _maxSimultaneousLights;
  43715. /**
  43716. * Number of Simultaneous lights allowed on the material.
  43717. */
  43718. maxSimultaneousLights: int;
  43719. /**
  43720. * Default configuration related to image processing available in the Background Material.
  43721. */
  43722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43723. /**
  43724. * Keep track of the image processing observer to allow dispose and replace.
  43725. */
  43726. private _imageProcessingObserver;
  43727. /**
  43728. * Attaches a new image processing configuration to the PBR Material.
  43729. * @param configuration (if null the scene configuration will be use)
  43730. */
  43731. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43732. /**
  43733. * Gets the image processing configuration used either in this material.
  43734. */
  43735. /**
  43736. * Sets the Default image processing configuration used either in the this material.
  43737. *
  43738. * If sets to null, the scene one is in use.
  43739. */
  43740. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43741. /**
  43742. * Gets wether the color curves effect is enabled.
  43743. */
  43744. /**
  43745. * Sets wether the color curves effect is enabled.
  43746. */
  43747. cameraColorCurvesEnabled: boolean;
  43748. /**
  43749. * Gets wether the color grading effect is enabled.
  43750. */
  43751. /**
  43752. * Gets wether the color grading effect is enabled.
  43753. */
  43754. cameraColorGradingEnabled: boolean;
  43755. /**
  43756. * Gets wether tonemapping is enabled or not.
  43757. */
  43758. /**
  43759. * Sets wether tonemapping is enabled or not
  43760. */
  43761. cameraToneMappingEnabled: boolean;
  43762. /**
  43763. * The camera exposure used on this material.
  43764. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43765. * This corresponds to a photographic exposure.
  43766. */
  43767. /**
  43768. * The camera exposure used on this material.
  43769. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43770. * This corresponds to a photographic exposure.
  43771. */
  43772. cameraExposure: float;
  43773. /**
  43774. * Gets The camera contrast used on this material.
  43775. */
  43776. /**
  43777. * Sets The camera contrast used on this material.
  43778. */
  43779. cameraContrast: float;
  43780. /**
  43781. * Gets the Color Grading 2D Lookup Texture.
  43782. */
  43783. /**
  43784. * Sets the Color Grading 2D Lookup Texture.
  43785. */
  43786. cameraColorGradingTexture: Nullable<BaseTexture>;
  43787. /**
  43788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43790. * 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;
  43791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43792. */
  43793. /**
  43794. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43795. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43796. * 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;
  43797. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43798. */
  43799. cameraColorCurves: Nullable<ColorCurves>;
  43800. /**
  43801. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43802. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43803. */
  43804. switchToBGR: boolean;
  43805. private _renderTargets;
  43806. private _reflectionControls;
  43807. private _white;
  43808. private _primaryShadowColor;
  43809. private _primaryHighlightColor;
  43810. /**
  43811. * Instantiates a Background Material in the given scene
  43812. * @param name The friendly name of the material
  43813. * @param scene The scene to add the material to
  43814. */
  43815. constructor(name: string, scene: Scene);
  43816. /**
  43817. * Gets a boolean indicating that current material needs to register RTT
  43818. */
  43819. readonly hasRenderTargetTextures: boolean;
  43820. /**
  43821. * The entire material has been created in order to prevent overdraw.
  43822. * @returns false
  43823. */
  43824. needAlphaTesting(): boolean;
  43825. /**
  43826. * The entire material has been created in order to prevent overdraw.
  43827. * @returns true if blending is enable
  43828. */
  43829. needAlphaBlending(): boolean;
  43830. /**
  43831. * Checks wether the material is ready to be rendered for a given mesh.
  43832. * @param mesh The mesh to render
  43833. * @param subMesh The submesh to check against
  43834. * @param useInstances Specify wether or not the material is used with instances
  43835. * @returns true if all the dependencies are ready (Textures, Effects...)
  43836. */
  43837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43838. /**
  43839. * Compute the primary color according to the chosen perceptual color.
  43840. */
  43841. private _computePrimaryColorFromPerceptualColor;
  43842. /**
  43843. * Compute the highlights and shadow colors according to their chosen levels.
  43844. */
  43845. private _computePrimaryColors;
  43846. /**
  43847. * Build the uniform buffer used in the material.
  43848. */
  43849. buildUniformLayout(): void;
  43850. /**
  43851. * Unbind the material.
  43852. */
  43853. unbind(): void;
  43854. /**
  43855. * Bind only the world matrix to the material.
  43856. * @param world The world matrix to bind.
  43857. */
  43858. bindOnlyWorldMatrix(world: Matrix): void;
  43859. /**
  43860. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43861. * @param world The world matrix to bind.
  43862. * @param subMesh The submesh to bind for.
  43863. */
  43864. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43865. /**
  43866. * Dispose the material.
  43867. * @param forceDisposeEffect Force disposal of the associated effect.
  43868. * @param forceDisposeTextures Force disposal of the associated textures.
  43869. */
  43870. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43871. /**
  43872. * Clones the material.
  43873. * @param name The cloned name.
  43874. * @returns The cloned material.
  43875. */
  43876. clone(name: string): BackgroundMaterial;
  43877. /**
  43878. * Serializes the current material to its JSON representation.
  43879. * @returns The JSON representation.
  43880. */
  43881. serialize(): any;
  43882. /**
  43883. * Gets the class name of the material
  43884. * @returns "BackgroundMaterial"
  43885. */
  43886. getClassName(): string;
  43887. /**
  43888. * Parse a JSON input to create back a background material.
  43889. * @param source The JSON data to parse
  43890. * @param scene The scene to create the parsed material in
  43891. * @param rootUrl The root url of the assets the material depends upon
  43892. * @returns the instantiated BackgroundMaterial.
  43893. */
  43894. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43895. }
  43896. }
  43897. declare module "babylonjs/Helpers/environmentHelper" {
  43898. import { Observable } from "babylonjs/Misc/observable";
  43899. import { Nullable } from "babylonjs/types";
  43900. import { Scene } from "babylonjs/scene";
  43901. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43903. import { Mesh } from "babylonjs/Meshes/mesh";
  43904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43905. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43906. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43907. import "babylonjs/Meshes/Builders/planeBuilder";
  43908. import "babylonjs/Meshes/Builders/boxBuilder";
  43909. /**
  43910. * Represents the different options available during the creation of
  43911. * a Environment helper.
  43912. *
  43913. * This can control the default ground, skybox and image processing setup of your scene.
  43914. */
  43915. export interface IEnvironmentHelperOptions {
  43916. /**
  43917. * Specifies wether or not to create a ground.
  43918. * True by default.
  43919. */
  43920. createGround: boolean;
  43921. /**
  43922. * Specifies the ground size.
  43923. * 15 by default.
  43924. */
  43925. groundSize: number;
  43926. /**
  43927. * The texture used on the ground for the main color.
  43928. * Comes from the BabylonJS CDN by default.
  43929. *
  43930. * Remarks: Can be either a texture or a url.
  43931. */
  43932. groundTexture: string | BaseTexture;
  43933. /**
  43934. * The color mixed in the ground texture by default.
  43935. * BabylonJS clearColor by default.
  43936. */
  43937. groundColor: Color3;
  43938. /**
  43939. * Specifies the ground opacity.
  43940. * 1 by default.
  43941. */
  43942. groundOpacity: number;
  43943. /**
  43944. * Enables the ground to receive shadows.
  43945. * True by default.
  43946. */
  43947. enableGroundShadow: boolean;
  43948. /**
  43949. * Helps preventing the shadow to be fully black on the ground.
  43950. * 0.5 by default.
  43951. */
  43952. groundShadowLevel: number;
  43953. /**
  43954. * Creates a mirror texture attach to the ground.
  43955. * false by default.
  43956. */
  43957. enableGroundMirror: boolean;
  43958. /**
  43959. * Specifies the ground mirror size ratio.
  43960. * 0.3 by default as the default kernel is 64.
  43961. */
  43962. groundMirrorSizeRatio: number;
  43963. /**
  43964. * Specifies the ground mirror blur kernel size.
  43965. * 64 by default.
  43966. */
  43967. groundMirrorBlurKernel: number;
  43968. /**
  43969. * Specifies the ground mirror visibility amount.
  43970. * 1 by default
  43971. */
  43972. groundMirrorAmount: number;
  43973. /**
  43974. * Specifies the ground mirror reflectance weight.
  43975. * This uses the standard weight of the background material to setup the fresnel effect
  43976. * of the mirror.
  43977. * 1 by default.
  43978. */
  43979. groundMirrorFresnelWeight: number;
  43980. /**
  43981. * Specifies the ground mirror Falloff distance.
  43982. * This can helps reducing the size of the reflection.
  43983. * 0 by Default.
  43984. */
  43985. groundMirrorFallOffDistance: number;
  43986. /**
  43987. * Specifies the ground mirror texture type.
  43988. * Unsigned Int by Default.
  43989. */
  43990. groundMirrorTextureType: number;
  43991. /**
  43992. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43993. * the shown objects.
  43994. */
  43995. groundYBias: number;
  43996. /**
  43997. * Specifies wether or not to create a skybox.
  43998. * True by default.
  43999. */
  44000. createSkybox: boolean;
  44001. /**
  44002. * Specifies the skybox size.
  44003. * 20 by default.
  44004. */
  44005. skyboxSize: number;
  44006. /**
  44007. * The texture used on the skybox for the main color.
  44008. * Comes from the BabylonJS CDN by default.
  44009. *
  44010. * Remarks: Can be either a texture or a url.
  44011. */
  44012. skyboxTexture: string | BaseTexture;
  44013. /**
  44014. * The color mixed in the skybox texture by default.
  44015. * BabylonJS clearColor by default.
  44016. */
  44017. skyboxColor: Color3;
  44018. /**
  44019. * The background rotation around the Y axis of the scene.
  44020. * This helps aligning the key lights of your scene with the background.
  44021. * 0 by default.
  44022. */
  44023. backgroundYRotation: number;
  44024. /**
  44025. * Compute automatically the size of the elements to best fit with the scene.
  44026. */
  44027. sizeAuto: boolean;
  44028. /**
  44029. * Default position of the rootMesh if autoSize is not true.
  44030. */
  44031. rootPosition: Vector3;
  44032. /**
  44033. * Sets up the image processing in the scene.
  44034. * true by default.
  44035. */
  44036. setupImageProcessing: boolean;
  44037. /**
  44038. * The texture used as your environment texture in the scene.
  44039. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44040. *
  44041. * Remarks: Can be either a texture or a url.
  44042. */
  44043. environmentTexture: string | BaseTexture;
  44044. /**
  44045. * The value of the exposure to apply to the scene.
  44046. * 0.6 by default if setupImageProcessing is true.
  44047. */
  44048. cameraExposure: number;
  44049. /**
  44050. * The value of the contrast to apply to the scene.
  44051. * 1.6 by default if setupImageProcessing is true.
  44052. */
  44053. cameraContrast: number;
  44054. /**
  44055. * Specifies wether or not tonemapping should be enabled in the scene.
  44056. * true by default if setupImageProcessing is true.
  44057. */
  44058. toneMappingEnabled: boolean;
  44059. }
  44060. /**
  44061. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44062. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44063. * It also helps with the default setup of your imageProcessing configuration.
  44064. */
  44065. export class EnvironmentHelper {
  44066. /**
  44067. * Default ground texture URL.
  44068. */
  44069. private static _groundTextureCDNUrl;
  44070. /**
  44071. * Default skybox texture URL.
  44072. */
  44073. private static _skyboxTextureCDNUrl;
  44074. /**
  44075. * Default environment texture URL.
  44076. */
  44077. private static _environmentTextureCDNUrl;
  44078. /**
  44079. * Creates the default options for the helper.
  44080. */
  44081. private static _getDefaultOptions;
  44082. private _rootMesh;
  44083. /**
  44084. * Gets the root mesh created by the helper.
  44085. */
  44086. readonly rootMesh: Mesh;
  44087. private _skybox;
  44088. /**
  44089. * Gets the skybox created by the helper.
  44090. */
  44091. readonly skybox: Nullable<Mesh>;
  44092. private _skyboxTexture;
  44093. /**
  44094. * Gets the skybox texture created by the helper.
  44095. */
  44096. readonly skyboxTexture: Nullable<BaseTexture>;
  44097. private _skyboxMaterial;
  44098. /**
  44099. * Gets the skybox material created by the helper.
  44100. */
  44101. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44102. private _ground;
  44103. /**
  44104. * Gets the ground mesh created by the helper.
  44105. */
  44106. readonly ground: Nullable<Mesh>;
  44107. private _groundTexture;
  44108. /**
  44109. * Gets the ground texture created by the helper.
  44110. */
  44111. readonly groundTexture: Nullable<BaseTexture>;
  44112. private _groundMirror;
  44113. /**
  44114. * Gets the ground mirror created by the helper.
  44115. */
  44116. readonly groundMirror: Nullable<MirrorTexture>;
  44117. /**
  44118. * Gets the ground mirror render list to helps pushing the meshes
  44119. * you wish in the ground reflection.
  44120. */
  44121. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44122. private _groundMaterial;
  44123. /**
  44124. * Gets the ground material created by the helper.
  44125. */
  44126. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44127. /**
  44128. * Stores the creation options.
  44129. */
  44130. private readonly _scene;
  44131. private _options;
  44132. /**
  44133. * This observable will be notified with any error during the creation of the environment,
  44134. * mainly texture creation errors.
  44135. */
  44136. onErrorObservable: Observable<{
  44137. message?: string;
  44138. exception?: any;
  44139. }>;
  44140. /**
  44141. * constructor
  44142. * @param options Defines the options we want to customize the helper
  44143. * @param scene The scene to add the material to
  44144. */
  44145. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44146. /**
  44147. * Updates the background according to the new options
  44148. * @param options
  44149. */
  44150. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44151. /**
  44152. * Sets the primary color of all the available elements.
  44153. * @param color the main color to affect to the ground and the background
  44154. */
  44155. setMainColor(color: Color3): void;
  44156. /**
  44157. * Setup the image processing according to the specified options.
  44158. */
  44159. private _setupImageProcessing;
  44160. /**
  44161. * Setup the environment texture according to the specified options.
  44162. */
  44163. private _setupEnvironmentTexture;
  44164. /**
  44165. * Setup the background according to the specified options.
  44166. */
  44167. private _setupBackground;
  44168. /**
  44169. * Get the scene sizes according to the setup.
  44170. */
  44171. private _getSceneSize;
  44172. /**
  44173. * Setup the ground according to the specified options.
  44174. */
  44175. private _setupGround;
  44176. /**
  44177. * Setup the ground material according to the specified options.
  44178. */
  44179. private _setupGroundMaterial;
  44180. /**
  44181. * Setup the ground diffuse texture according to the specified options.
  44182. */
  44183. private _setupGroundDiffuseTexture;
  44184. /**
  44185. * Setup the ground mirror texture according to the specified options.
  44186. */
  44187. private _setupGroundMirrorTexture;
  44188. /**
  44189. * Setup the ground to receive the mirror texture.
  44190. */
  44191. private _setupMirrorInGroundMaterial;
  44192. /**
  44193. * Setup the skybox according to the specified options.
  44194. */
  44195. private _setupSkybox;
  44196. /**
  44197. * Setup the skybox material according to the specified options.
  44198. */
  44199. private _setupSkyboxMaterial;
  44200. /**
  44201. * Setup the skybox reflection texture according to the specified options.
  44202. */
  44203. private _setupSkyboxReflectionTexture;
  44204. private _errorHandler;
  44205. /**
  44206. * Dispose all the elements created by the Helper.
  44207. */
  44208. dispose(): void;
  44209. }
  44210. }
  44211. declare module "babylonjs/Helpers/photoDome" {
  44212. import { Observable } from "babylonjs/Misc/observable";
  44213. import { Nullable } from "babylonjs/types";
  44214. import { Scene } from "babylonjs/scene";
  44215. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44216. import { Mesh } from "babylonjs/Meshes/mesh";
  44217. import { Texture } from "babylonjs/Materials/Textures/texture";
  44218. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44219. import "babylonjs/Meshes/Builders/sphereBuilder";
  44220. /**
  44221. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44222. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44223. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44224. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44225. */
  44226. export class PhotoDome extends TransformNode {
  44227. private _useDirectMapping;
  44228. /**
  44229. * The texture being displayed on the sphere
  44230. */
  44231. protected _photoTexture: Texture;
  44232. /**
  44233. * Gets or sets the texture being displayed on the sphere
  44234. */
  44235. photoTexture: Texture;
  44236. /**
  44237. * Observable raised when an error occured while loading the 360 image
  44238. */
  44239. onLoadErrorObservable: Observable<string>;
  44240. /**
  44241. * The skybox material
  44242. */
  44243. protected _material: BackgroundMaterial;
  44244. /**
  44245. * The surface used for the skybox
  44246. */
  44247. protected _mesh: Mesh;
  44248. /**
  44249. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44250. * Also see the options.resolution property.
  44251. */
  44252. fovMultiplier: number;
  44253. /**
  44254. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44255. * @param name Element's name, child elements will append suffixes for their own names.
  44256. * @param urlsOfPhoto defines the url of the photo to display
  44257. * @param options defines an object containing optional or exposed sub element properties
  44258. * @param onError defines a callback called when an error occured while loading the texture
  44259. */
  44260. constructor(name: string, urlOfPhoto: string, options: {
  44261. resolution?: number;
  44262. size?: number;
  44263. useDirectMapping?: boolean;
  44264. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44265. /**
  44266. * Releases resources associated with this node.
  44267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44269. */
  44270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Misc/textureTools" {
  44274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44275. import { Texture } from "babylonjs/Materials/Textures/texture";
  44276. import { Scene } from "babylonjs/scene";
  44277. /**
  44278. * Class used to host texture specific utilities
  44279. */
  44280. export class TextureTools {
  44281. /**
  44282. * Uses the GPU to create a copy texture rescaled at a given size
  44283. * @param texture Texture to copy from
  44284. * @param width defines the desired width
  44285. * @param height defines the desired height
  44286. * @param useBilinearMode defines if bilinear mode has to be used
  44287. * @return the generated texture
  44288. */
  44289. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44290. /**
  44291. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44292. * @param scene defines the hosting scene
  44293. * @returns the environment BRDF texture
  44294. */
  44295. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44296. private static _environmentBRDFBase64Texture;
  44297. }
  44298. }
  44299. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44300. import { Nullable } from "babylonjs/types";
  44301. import { IAnimatable } from "babylonjs/Misc/tools";
  44302. import { Color3 } from "babylonjs/Maths/math";
  44303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44304. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44305. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44306. import { Engine } from "babylonjs/Engines/engine";
  44307. import { Scene } from "babylonjs/scene";
  44308. /**
  44309. * @hidden
  44310. */
  44311. export interface IMaterialClearCoatDefines {
  44312. CLEARCOAT: boolean;
  44313. CLEARCOAT_DEFAULTIOR: boolean;
  44314. CLEARCOAT_TEXTURE: boolean;
  44315. CLEARCOAT_TEXTUREDIRECTUV: number;
  44316. CLEARCOAT_BUMP: boolean;
  44317. CLEARCOAT_BUMPDIRECTUV: number;
  44318. CLEARCOAT_TINT: boolean;
  44319. CLEARCOAT_TINT_TEXTURE: boolean;
  44320. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44321. /** @hidden */
  44322. _areTexturesDirty: boolean;
  44323. }
  44324. /**
  44325. * Define the code related to the clear coat parameters of the pbr material.
  44326. */
  44327. export class PBRClearCoatConfiguration {
  44328. /**
  44329. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44330. * The default fits with a polyurethane material.
  44331. */
  44332. private static readonly _DefaultIndiceOfRefraction;
  44333. private _isEnabled;
  44334. /**
  44335. * Defines if the clear coat is enabled in the material.
  44336. */
  44337. isEnabled: boolean;
  44338. /**
  44339. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44340. */
  44341. intensity: number;
  44342. /**
  44343. * Defines the clear coat layer roughness.
  44344. */
  44345. roughness: number;
  44346. private _indiceOfRefraction;
  44347. /**
  44348. * Defines the indice of refraction of the clear coat.
  44349. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44350. * The default fits with a polyurethane material.
  44351. * Changing the default value is more performance intensive.
  44352. */
  44353. indiceOfRefraction: number;
  44354. private _texture;
  44355. /**
  44356. * Stores the clear coat values in a texture.
  44357. */
  44358. texture: Nullable<BaseTexture>;
  44359. private _bumpTexture;
  44360. /**
  44361. * Define the clear coat specific bump texture.
  44362. */
  44363. bumpTexture: Nullable<BaseTexture>;
  44364. private _isTintEnabled;
  44365. /**
  44366. * Defines if the clear coat tint is enabled in the material.
  44367. */
  44368. isTintEnabled: boolean;
  44369. /**
  44370. * Defines if the clear coat tint is enabled in the material.
  44371. * This is only use if tint is enabled
  44372. */
  44373. tintColor: Color3;
  44374. /**
  44375. * Defines if the distance at which the tint color should be found in the
  44376. * clear coat media.
  44377. * This is only use if tint is enabled
  44378. */
  44379. tintColorAtDistance: number;
  44380. /**
  44381. * Defines the clear coat layer thickness.
  44382. * This is only use if tint is enabled
  44383. */
  44384. tintThickness: number;
  44385. private _tintTexture;
  44386. /**
  44387. * Stores the clear tint values in a texture.
  44388. * rgb is tint
  44389. * a is a thickness factor
  44390. */
  44391. tintTexture: Nullable<BaseTexture>;
  44392. /** @hidden */
  44393. private _internalMarkAllSubMeshesAsTexturesDirty;
  44394. /** @hidden */
  44395. _markAllSubMeshesAsTexturesDirty(): void;
  44396. /**
  44397. * Instantiate a new istance of clear coat configuration.
  44398. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44399. */
  44400. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44401. /**
  44402. * Specifies that the submesh is ready to be used.
  44403. * @param defines the list of "defines" to update.
  44404. * @param scene defines the scene the material belongs to.
  44405. * @param engine defines the engine the material belongs to.
  44406. * @param disableBumpMap defines wether the material disables bump or not.
  44407. * @returns - boolean indicating that the submesh is ready or not.
  44408. */
  44409. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44410. /**
  44411. * Checks to see if a texture is used in the material.
  44412. * @param defines the list of "defines" to update.
  44413. * @param scene defines the scene to the material belongs to.
  44414. */
  44415. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44416. /**
  44417. * Binds the material data.
  44418. * @param uniformBuffer defines the Uniform buffer to fill in.
  44419. * @param scene defines the scene the material belongs to.
  44420. * @param engine defines the engine the material belongs to.
  44421. * @param disableBumpMap defines wether the material disables bump or not.
  44422. * @param isFrozen defines wether the material is frozen or not.
  44423. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44424. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44425. */
  44426. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44427. /**
  44428. * Checks to see if a texture is used in the material.
  44429. * @param texture - Base texture to use.
  44430. * @returns - Boolean specifying if a texture is used in the material.
  44431. */
  44432. hasTexture(texture: BaseTexture): boolean;
  44433. /**
  44434. * Returns an array of the actively used textures.
  44435. * @param activeTextures Array of BaseTextures
  44436. */
  44437. getActiveTextures(activeTextures: BaseTexture[]): void;
  44438. /**
  44439. * Returns the animatable textures.
  44440. * @param animatables Array of animatable textures.
  44441. */
  44442. getAnimatables(animatables: IAnimatable[]): void;
  44443. /**
  44444. * Disposes the resources of the material.
  44445. * @param forceDisposeTextures - Forces the disposal of all textures.
  44446. */
  44447. dispose(forceDisposeTextures?: boolean): void;
  44448. /**
  44449. * Get the current class name of the texture useful for serialization or dynamic coding.
  44450. * @returns "PBRClearCoatConfiguration"
  44451. */
  44452. getClassName(): string;
  44453. /**
  44454. * Add fallbacks to the effect fallbacks list.
  44455. * @param defines defines the Base texture to use.
  44456. * @param fallbacks defines the current fallback list.
  44457. * @param currentRank defines the current fallback rank.
  44458. * @returns the new fallback rank.
  44459. */
  44460. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44461. /**
  44462. * Add the required uniforms to the current list.
  44463. * @param uniforms defines the current uniform list.
  44464. */
  44465. static AddUniforms(uniforms: string[]): void;
  44466. /**
  44467. * Add the required samplers to the current list.
  44468. * @param samplers defines the current sampler list.
  44469. */
  44470. static AddSamplers(samplers: string[]): void;
  44471. /**
  44472. * Add the required uniforms to the current buffer.
  44473. * @param uniformBuffer defines the current uniform buffer.
  44474. */
  44475. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44476. /**
  44477. * Makes a duplicate of the current configuration into another one.
  44478. * @param clearCoatConfiguration define the config where to copy the info
  44479. */
  44480. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44481. /**
  44482. * Serializes this clear coat configuration.
  44483. * @returns - An object with the serialized config.
  44484. */
  44485. serialize(): any;
  44486. /**
  44487. * Parses a Clear Coat Configuration from a serialized object.
  44488. * @param source - Serialized object.
  44489. */
  44490. parse(source: any): void;
  44491. }
  44492. }
  44493. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44494. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44495. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44497. import { Vector2 } from "babylonjs/Maths/math";
  44498. import { Scene } from "babylonjs/scene";
  44499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44500. import { IAnimatable } from "babylonjs/Misc/tools";
  44501. import { Nullable } from "babylonjs/types";
  44502. /**
  44503. * @hidden
  44504. */
  44505. export interface IMaterialAnisotropicDefines {
  44506. ANISOTROPIC: boolean;
  44507. ANISOTROPIC_TEXTURE: boolean;
  44508. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44509. MAINUV1: boolean;
  44510. _areTexturesDirty: boolean;
  44511. _needUVs: boolean;
  44512. }
  44513. /**
  44514. * Define the code related to the anisotropic parameters of the pbr material.
  44515. */
  44516. export class PBRAnisotropicConfiguration {
  44517. private _isEnabled;
  44518. /**
  44519. * Defines if the anisotropy is enabled in the material.
  44520. */
  44521. isEnabled: boolean;
  44522. /**
  44523. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44524. */
  44525. intensity: number;
  44526. /**
  44527. * Defines if the effect is along the tangents, bitangents or in between.
  44528. * By default, the effect is "strectching" the highlights along the tangents.
  44529. */
  44530. direction: Vector2;
  44531. private _texture;
  44532. /**
  44533. * Stores the anisotropy values in a texture.
  44534. * rg is direction (like normal from -1 to 1)
  44535. * b is a intensity
  44536. */
  44537. texture: Nullable<BaseTexture>;
  44538. /** @hidden */
  44539. private _internalMarkAllSubMeshesAsTexturesDirty;
  44540. /** @hidden */
  44541. _markAllSubMeshesAsTexturesDirty(): void;
  44542. /**
  44543. * Instantiate a new istance of anisotropy configuration.
  44544. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44545. */
  44546. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44547. /**
  44548. * Specifies that the submesh is ready to be used.
  44549. * @param defines the list of "defines" to update.
  44550. * @param scene defines the scene the material belongs to.
  44551. * @returns - boolean indicating that the submesh is ready or not.
  44552. */
  44553. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44554. /**
  44555. * Checks to see if a texture is used in the material.
  44556. * @param defines the list of "defines" to update.
  44557. * @param mesh the mesh we are preparing the defines for.
  44558. * @param scene defines the scene the material belongs to.
  44559. */
  44560. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44561. /**
  44562. * Binds the material data.
  44563. * @param uniformBuffer defines the Uniform buffer to fill in.
  44564. * @param scene defines the scene the material belongs to.
  44565. * @param isFrozen defines wether the material is frozen or not.
  44566. */
  44567. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44568. /**
  44569. * Checks to see if a texture is used in the material.
  44570. * @param texture - Base texture to use.
  44571. * @returns - Boolean specifying if a texture is used in the material.
  44572. */
  44573. hasTexture(texture: BaseTexture): boolean;
  44574. /**
  44575. * Returns an array of the actively used textures.
  44576. * @param activeTextures Array of BaseTextures
  44577. */
  44578. getActiveTextures(activeTextures: BaseTexture[]): void;
  44579. /**
  44580. * Returns the animatable textures.
  44581. * @param animatables Array of animatable textures.
  44582. */
  44583. getAnimatables(animatables: IAnimatable[]): void;
  44584. /**
  44585. * Disposes the resources of the material.
  44586. * @param forceDisposeTextures - Forces the disposal of all textures.
  44587. */
  44588. dispose(forceDisposeTextures?: boolean): void;
  44589. /**
  44590. * Get the current class name of the texture useful for serialization or dynamic coding.
  44591. * @returns "PBRAnisotropicConfiguration"
  44592. */
  44593. getClassName(): string;
  44594. /**
  44595. * Add fallbacks to the effect fallbacks list.
  44596. * @param defines defines the Base texture to use.
  44597. * @param fallbacks defines the current fallback list.
  44598. * @param currentRank defines the current fallback rank.
  44599. * @returns the new fallback rank.
  44600. */
  44601. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44602. /**
  44603. * Add the required uniforms to the current list.
  44604. * @param uniforms defines the current uniform list.
  44605. */
  44606. static AddUniforms(uniforms: string[]): void;
  44607. /**
  44608. * Add the required uniforms to the current buffer.
  44609. * @param uniformBuffer defines the current uniform buffer.
  44610. */
  44611. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44612. /**
  44613. * Add the required samplers to the current list.
  44614. * @param samplers defines the current sampler list.
  44615. */
  44616. static AddSamplers(samplers: string[]): void;
  44617. /**
  44618. * Makes a duplicate of the current configuration into another one.
  44619. * @param anisotropicConfiguration define the config where to copy the info
  44620. */
  44621. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44622. /**
  44623. * Serializes this anisotropy configuration.
  44624. * @returns - An object with the serialized config.
  44625. */
  44626. serialize(): any;
  44627. /**
  44628. * Parses a anisotropy Configuration from a serialized object.
  44629. * @param source - Serialized object.
  44630. */
  44631. parse(source: any): void;
  44632. }
  44633. }
  44634. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44635. /**
  44636. * @hidden
  44637. */
  44638. export interface IMaterialBRDFDefines {
  44639. BRDF_V_HEIGHT_CORRELATED: boolean;
  44640. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44641. /** @hidden */
  44642. _areMiscDirty: boolean;
  44643. }
  44644. /**
  44645. * Define the code related to the BRDF parameters of the pbr material.
  44646. */
  44647. export class PBRBRDFConfiguration {
  44648. private _useEnergyConservation;
  44649. /**
  44650. * Defines if the material uses energy conservation.
  44651. */
  44652. useEnergyConservation: boolean;
  44653. private _useSmithVisibilityHeightCorrelated;
  44654. /**
  44655. * LEGACY Mode set to false
  44656. * Defines if the material uses height smith correlated visibility term.
  44657. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44658. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44659. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44660. * Not relying on height correlated will also disable energy conservation.
  44661. */
  44662. useSmithVisibilityHeightCorrelated: boolean;
  44663. /** @hidden */
  44664. private _internalMarkAllSubMeshesAsMiscDirty;
  44665. /** @hidden */
  44666. _markAllSubMeshesAsMiscDirty(): void;
  44667. /**
  44668. * Instantiate a new istance of clear coat configuration.
  44669. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44670. */
  44671. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44672. /**
  44673. * Checks to see if a texture is used in the material.
  44674. * @param defines the list of "defines" to update.
  44675. */
  44676. prepareDefines(defines: IMaterialBRDFDefines): void;
  44677. /**
  44678. * Get the current class name of the texture useful for serialization or dynamic coding.
  44679. * @returns "PBRClearCoatConfiguration"
  44680. */
  44681. getClassName(): string;
  44682. /**
  44683. * Makes a duplicate of the current configuration into another one.
  44684. * @param brdfConfiguration define the config where to copy the info
  44685. */
  44686. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44687. /**
  44688. * Serializes this BRDF configuration.
  44689. * @returns - An object with the serialized config.
  44690. */
  44691. serialize(): any;
  44692. /**
  44693. * Parses a BRDF Configuration from a serialized object.
  44694. * @param source - Serialized object.
  44695. */
  44696. parse(source: any): void;
  44697. }
  44698. }
  44699. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44700. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44701. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44702. import { Color3 } from "babylonjs/Maths/math";
  44703. import { Scene } from "babylonjs/scene";
  44704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44705. import { IAnimatable } from "babylonjs/Misc/tools";
  44706. import { Nullable } from "babylonjs/types";
  44707. /**
  44708. * @hidden
  44709. */
  44710. export interface IMaterialSheenDefines {
  44711. SHEEN: boolean;
  44712. SHEEN_TEXTURE: boolean;
  44713. SHEEN_TEXTUREDIRECTUV: number;
  44714. SHEEN_LINKWITHALBEDO: boolean;
  44715. /** @hidden */
  44716. _areTexturesDirty: boolean;
  44717. }
  44718. /**
  44719. * Define the code related to the Sheen parameters of the pbr material.
  44720. */
  44721. export class PBRSheenConfiguration {
  44722. private _isEnabled;
  44723. /**
  44724. * Defines if the material uses sheen.
  44725. */
  44726. isEnabled: boolean;
  44727. private _linkSheenWithAlbedo;
  44728. /**
  44729. * Defines if the sheen is linked to the sheen color.
  44730. */
  44731. linkSheenWithAlbedo: boolean;
  44732. /**
  44733. * Defines the sheen intensity.
  44734. */
  44735. intensity: number;
  44736. /**
  44737. * Defines the sheen color.
  44738. */
  44739. color: Color3;
  44740. private _texture;
  44741. /**
  44742. * Stores the sheen tint values in a texture.
  44743. * rgb is tint
  44744. * a is a intensity
  44745. */
  44746. texture: Nullable<BaseTexture>;
  44747. /** @hidden */
  44748. private _internalMarkAllSubMeshesAsTexturesDirty;
  44749. /** @hidden */
  44750. _markAllSubMeshesAsTexturesDirty(): void;
  44751. /**
  44752. * Instantiate a new istance of clear coat configuration.
  44753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44754. */
  44755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44756. /**
  44757. * Specifies that the submesh is ready to be used.
  44758. * @param defines the list of "defines" to update.
  44759. * @param scene defines the scene the material belongs to.
  44760. * @returns - boolean indicating that the submesh is ready or not.
  44761. */
  44762. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44763. /**
  44764. * Checks to see if a texture is used in the material.
  44765. * @param defines the list of "defines" to update.
  44766. * @param scene defines the scene the material belongs to.
  44767. */
  44768. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44769. /**
  44770. * Binds the material data.
  44771. * @param uniformBuffer defines the Uniform buffer to fill in.
  44772. * @param scene defines the scene the material belongs to.
  44773. * @param isFrozen defines wether the material is frozen or not.
  44774. */
  44775. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44776. /**
  44777. * Checks to see if a texture is used in the material.
  44778. * @param texture - Base texture to use.
  44779. * @returns - Boolean specifying if a texture is used in the material.
  44780. */
  44781. hasTexture(texture: BaseTexture): boolean;
  44782. /**
  44783. * Returns an array of the actively used textures.
  44784. * @param activeTextures Array of BaseTextures
  44785. */
  44786. getActiveTextures(activeTextures: BaseTexture[]): void;
  44787. /**
  44788. * Returns the animatable textures.
  44789. * @param animatables Array of animatable textures.
  44790. */
  44791. getAnimatables(animatables: IAnimatable[]): void;
  44792. /**
  44793. * Disposes the resources of the material.
  44794. * @param forceDisposeTextures - Forces the disposal of all textures.
  44795. */
  44796. dispose(forceDisposeTextures?: boolean): void;
  44797. /**
  44798. * Get the current class name of the texture useful for serialization or dynamic coding.
  44799. * @returns "PBRSheenConfiguration"
  44800. */
  44801. getClassName(): string;
  44802. /**
  44803. * Add fallbacks to the effect fallbacks list.
  44804. * @param defines defines the Base texture to use.
  44805. * @param fallbacks defines the current fallback list.
  44806. * @param currentRank defines the current fallback rank.
  44807. * @returns the new fallback rank.
  44808. */
  44809. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44810. /**
  44811. * Add the required uniforms to the current list.
  44812. * @param uniforms defines the current uniform list.
  44813. */
  44814. static AddUniforms(uniforms: string[]): void;
  44815. /**
  44816. * Add the required uniforms to the current buffer.
  44817. * @param uniformBuffer defines the current uniform buffer.
  44818. */
  44819. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44820. /**
  44821. * Add the required samplers to the current list.
  44822. * @param samplers defines the current sampler list.
  44823. */
  44824. static AddSamplers(samplers: string[]): void;
  44825. /**
  44826. * Makes a duplicate of the current configuration into another one.
  44827. * @param sheenConfiguration define the config where to copy the info
  44828. */
  44829. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44830. /**
  44831. * Serializes this BRDF configuration.
  44832. * @returns - An object with the serialized config.
  44833. */
  44834. serialize(): any;
  44835. /**
  44836. * Parses a Sheen Configuration from a serialized object.
  44837. * @param source - Serialized object.
  44838. */
  44839. parse(source: any): void;
  44840. }
  44841. }
  44842. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44843. /** @hidden */
  44844. export var pbrFragmentDeclaration: {
  44845. name: string;
  44846. shader: string;
  44847. };
  44848. }
  44849. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44850. /** @hidden */
  44851. export var pbrUboDeclaration: {
  44852. name: string;
  44853. shader: string;
  44854. };
  44855. }
  44856. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44857. /** @hidden */
  44858. export var pbrFunctions: {
  44859. name: string;
  44860. shader: string;
  44861. };
  44862. }
  44863. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44864. /** @hidden */
  44865. export var harmonicsFunctions: {
  44866. name: string;
  44867. shader: string;
  44868. };
  44869. }
  44870. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44871. /** @hidden */
  44872. export var pbrPreLightingFunctions: {
  44873. name: string;
  44874. shader: string;
  44875. };
  44876. }
  44877. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44878. /** @hidden */
  44879. export var pbrFalloffLightingFunctions: {
  44880. name: string;
  44881. shader: string;
  44882. };
  44883. }
  44884. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44885. /** @hidden */
  44886. export var pbrLightingFunctions: {
  44887. name: string;
  44888. shader: string;
  44889. };
  44890. }
  44891. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44892. /** @hidden */
  44893. export var pbrDebug: {
  44894. name: string;
  44895. shader: string;
  44896. };
  44897. }
  44898. declare module "babylonjs/Shaders/pbr.fragment" {
  44899. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44900. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44901. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44902. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44903. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44904. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44905. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44906. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44907. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44908. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44909. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44910. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44911. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44912. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44913. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44914. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44915. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44916. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44917. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44918. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44919. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44920. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44921. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44922. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44923. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44924. /** @hidden */
  44925. export var pbrPixelShader: {
  44926. name: string;
  44927. shader: string;
  44928. };
  44929. }
  44930. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44931. /** @hidden */
  44932. export var pbrVertexDeclaration: {
  44933. name: string;
  44934. shader: string;
  44935. };
  44936. }
  44937. declare module "babylonjs/Shaders/pbr.vertex" {
  44938. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44939. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44940. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44942. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44943. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44944. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44945. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44946. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44947. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44948. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44949. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44951. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44952. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44953. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44954. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44955. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44956. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44957. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44958. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44959. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44960. /** @hidden */
  44961. export var pbrVertexShader: {
  44962. name: string;
  44963. shader: string;
  44964. };
  44965. }
  44966. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44967. import { IAnimatable } from "babylonjs/Misc/tools";
  44968. import { Nullable } from "babylonjs/types";
  44969. import { Scene } from "babylonjs/scene";
  44970. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44973. import { Mesh } from "babylonjs/Meshes/mesh";
  44974. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44975. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44976. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44977. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  44978. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44979. import { Material } from "babylonjs/Materials/material";
  44980. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44982. import "babylonjs/Shaders/pbr.fragment";
  44983. import "babylonjs/Shaders/pbr.vertex";
  44984. /**
  44985. * The Physically based material base class of BJS.
  44986. *
  44987. * This offers the main features of a standard PBR material.
  44988. * For more information, please refer to the documentation :
  44989. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44990. */
  44991. export abstract class PBRBaseMaterial extends PushMaterial {
  44992. /**
  44993. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44994. */
  44995. static readonly PBRMATERIAL_OPAQUE: number;
  44996. /**
  44997. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44998. */
  44999. static readonly PBRMATERIAL_ALPHATEST: number;
  45000. /**
  45001. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45002. */
  45003. static readonly PBRMATERIAL_ALPHABLEND: number;
  45004. /**
  45005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45006. * They are also discarded below the alpha cutoff threshold to improve performances.
  45007. */
  45008. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45009. /**
  45010. * Defines the default value of how much AO map is occluding the analytical lights
  45011. * (point spot...).
  45012. */
  45013. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45014. /**
  45015. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45016. */
  45017. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45018. /**
  45019. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45020. * to enhance interoperability with other engines.
  45021. */
  45022. static readonly LIGHTFALLOFF_GLTF: number;
  45023. /**
  45024. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45025. * to enhance interoperability with other materials.
  45026. */
  45027. static readonly LIGHTFALLOFF_STANDARD: number;
  45028. /**
  45029. * Intensity of the direct lights e.g. the four lights available in your scene.
  45030. * This impacts both the direct diffuse and specular highlights.
  45031. */
  45032. protected _directIntensity: number;
  45033. /**
  45034. * Intensity of the emissive part of the material.
  45035. * This helps controlling the emissive effect without modifying the emissive color.
  45036. */
  45037. protected _emissiveIntensity: number;
  45038. /**
  45039. * Intensity of the environment e.g. how much the environment will light the object
  45040. * either through harmonics for rough material or through the refelction for shiny ones.
  45041. */
  45042. protected _environmentIntensity: number;
  45043. /**
  45044. * This is a special control allowing the reduction of the specular highlights coming from the
  45045. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45046. */
  45047. protected _specularIntensity: number;
  45048. /**
  45049. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45050. */
  45051. private _lightingInfos;
  45052. /**
  45053. * Debug Control allowing disabling the bump map on this material.
  45054. */
  45055. protected _disableBumpMap: boolean;
  45056. /**
  45057. * AKA Diffuse Texture in standard nomenclature.
  45058. */
  45059. protected _albedoTexture: BaseTexture;
  45060. /**
  45061. * AKA Occlusion Texture in other nomenclature.
  45062. */
  45063. protected _ambientTexture: BaseTexture;
  45064. /**
  45065. * AKA Occlusion Texture Intensity in other nomenclature.
  45066. */
  45067. protected _ambientTextureStrength: number;
  45068. /**
  45069. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45070. * 1 means it completely occludes it
  45071. * 0 mean it has no impact
  45072. */
  45073. protected _ambientTextureImpactOnAnalyticalLights: number;
  45074. /**
  45075. * Stores the alpha values in a texture.
  45076. */
  45077. protected _opacityTexture: BaseTexture;
  45078. /**
  45079. * Stores the reflection values in a texture.
  45080. */
  45081. protected _reflectionTexture: BaseTexture;
  45082. /**
  45083. * Stores the refraction values in a texture.
  45084. */
  45085. protected _refractionTexture: BaseTexture;
  45086. /**
  45087. * Stores the emissive values in a texture.
  45088. */
  45089. protected _emissiveTexture: BaseTexture;
  45090. /**
  45091. * AKA Specular texture in other nomenclature.
  45092. */
  45093. protected _reflectivityTexture: BaseTexture;
  45094. /**
  45095. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45096. */
  45097. protected _metallicTexture: BaseTexture;
  45098. /**
  45099. * Specifies the metallic scalar of the metallic/roughness workflow.
  45100. * Can also be used to scale the metalness values of the metallic texture.
  45101. */
  45102. protected _metallic: Nullable<number>;
  45103. /**
  45104. * Specifies the roughness scalar of the metallic/roughness workflow.
  45105. * Can also be used to scale the roughness values of the metallic texture.
  45106. */
  45107. protected _roughness: Nullable<number>;
  45108. /**
  45109. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45110. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45111. */
  45112. protected _microSurfaceTexture: BaseTexture;
  45113. /**
  45114. * Stores surface normal data used to displace a mesh in a texture.
  45115. */
  45116. protected _bumpTexture: BaseTexture;
  45117. /**
  45118. * Stores the pre-calculated light information of a mesh in a texture.
  45119. */
  45120. protected _lightmapTexture: BaseTexture;
  45121. /**
  45122. * The color of a material in ambient lighting.
  45123. */
  45124. protected _ambientColor: Color3;
  45125. /**
  45126. * AKA Diffuse Color in other nomenclature.
  45127. */
  45128. protected _albedoColor: Color3;
  45129. /**
  45130. * AKA Specular Color in other nomenclature.
  45131. */
  45132. protected _reflectivityColor: Color3;
  45133. /**
  45134. * The color applied when light is reflected from a material.
  45135. */
  45136. protected _reflectionColor: Color3;
  45137. /**
  45138. * The color applied when light is emitted from a material.
  45139. */
  45140. protected _emissiveColor: Color3;
  45141. /**
  45142. * AKA Glossiness in other nomenclature.
  45143. */
  45144. protected _microSurface: number;
  45145. /**
  45146. * source material index of refraction (IOR)' / 'destination material IOR.
  45147. */
  45148. protected _indexOfRefraction: number;
  45149. /**
  45150. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45151. */
  45152. protected _invertRefractionY: boolean;
  45153. /**
  45154. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45155. * Materials half opaque for instance using refraction could benefit from this control.
  45156. */
  45157. protected _linkRefractionWithTransparency: boolean;
  45158. /**
  45159. * Specifies that the material will use the light map as a show map.
  45160. */
  45161. protected _useLightmapAsShadowmap: boolean;
  45162. /**
  45163. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45164. * makes the reflect vector face the model (under horizon).
  45165. */
  45166. protected _useHorizonOcclusion: boolean;
  45167. /**
  45168. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45169. * too much the area relying on ambient texture to define their ambient occlusion.
  45170. */
  45171. protected _useRadianceOcclusion: boolean;
  45172. /**
  45173. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45174. */
  45175. protected _useAlphaFromAlbedoTexture: boolean;
  45176. /**
  45177. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45178. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45179. */
  45180. protected _useSpecularOverAlpha: boolean;
  45181. /**
  45182. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45183. */
  45184. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45185. /**
  45186. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45187. */
  45188. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45189. /**
  45190. * Specifies if the metallic texture contains the roughness information in its green channel.
  45191. */
  45192. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45193. /**
  45194. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45195. */
  45196. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45197. /**
  45198. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45199. */
  45200. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45201. /**
  45202. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45203. */
  45204. protected _useAmbientInGrayScale: boolean;
  45205. /**
  45206. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45207. * The material will try to infer what glossiness each pixel should be.
  45208. */
  45209. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45210. /**
  45211. * Defines the falloff type used in this material.
  45212. * It by default is Physical.
  45213. */
  45214. protected _lightFalloff: number;
  45215. /**
  45216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45218. */
  45219. protected _useRadianceOverAlpha: boolean;
  45220. /**
  45221. * Allows using an object space normal map (instead of tangent space).
  45222. */
  45223. protected _useObjectSpaceNormalMap: boolean;
  45224. /**
  45225. * Allows using the bump map in parallax mode.
  45226. */
  45227. protected _useParallax: boolean;
  45228. /**
  45229. * Allows using the bump map in parallax occlusion mode.
  45230. */
  45231. protected _useParallaxOcclusion: boolean;
  45232. /**
  45233. * Controls the scale bias of the parallax mode.
  45234. */
  45235. protected _parallaxScaleBias: number;
  45236. /**
  45237. * If sets to true, disables all the lights affecting the material.
  45238. */
  45239. protected _disableLighting: boolean;
  45240. /**
  45241. * Number of Simultaneous lights allowed on the material.
  45242. */
  45243. protected _maxSimultaneousLights: number;
  45244. /**
  45245. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45246. */
  45247. protected _invertNormalMapX: boolean;
  45248. /**
  45249. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45250. */
  45251. protected _invertNormalMapY: boolean;
  45252. /**
  45253. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45254. */
  45255. protected _twoSidedLighting: boolean;
  45256. /**
  45257. * Defines the alpha limits in alpha test mode.
  45258. */
  45259. protected _alphaCutOff: number;
  45260. /**
  45261. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45262. */
  45263. protected _forceAlphaTest: boolean;
  45264. /**
  45265. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45266. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45267. */
  45268. protected _useAlphaFresnel: boolean;
  45269. /**
  45270. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45271. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45272. */
  45273. protected _useLinearAlphaFresnel: boolean;
  45274. /**
  45275. * The transparency mode of the material.
  45276. */
  45277. protected _transparencyMode: Nullable<number>;
  45278. /**
  45279. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45280. * from cos thetav and roughness:
  45281. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45282. */
  45283. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45284. /**
  45285. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45286. */
  45287. protected _forceIrradianceInFragment: boolean;
  45288. /**
  45289. * Force normal to face away from face.
  45290. */
  45291. protected _forceNormalForward: boolean;
  45292. /**
  45293. * Enables specular anti aliasing in the PBR shader.
  45294. * It will both interacts on the Geometry for analytical and IBL lighting.
  45295. * It also prefilter the roughness map based on the bump values.
  45296. */
  45297. protected _enableSpecularAntiAliasing: boolean;
  45298. /**
  45299. * Default configuration related to image processing available in the PBR Material.
  45300. */
  45301. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45302. /**
  45303. * Keep track of the image processing observer to allow dispose and replace.
  45304. */
  45305. private _imageProcessingObserver;
  45306. /**
  45307. * Attaches a new image processing configuration to the PBR Material.
  45308. * @param configuration
  45309. */
  45310. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45311. /**
  45312. * Stores the available render targets.
  45313. */
  45314. private _renderTargets;
  45315. /**
  45316. * Sets the global ambient color for the material used in lighting calculations.
  45317. */
  45318. private _globalAmbientColor;
  45319. /**
  45320. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45321. */
  45322. private _useLogarithmicDepth;
  45323. /**
  45324. * If set to true, no lighting calculations will be applied.
  45325. */
  45326. private _unlit;
  45327. private _debugMode;
  45328. /**
  45329. * @hidden
  45330. * This is reserved for the inspector.
  45331. * Defines the material debug mode.
  45332. * It helps seeing only some components of the material while troubleshooting.
  45333. */
  45334. debugMode: number;
  45335. /**
  45336. * @hidden
  45337. * This is reserved for the inspector.
  45338. * Specify from where on screen the debug mode should start.
  45339. * The value goes from -1 (full screen) to 1 (not visible)
  45340. * It helps with side by side comparison against the final render
  45341. * This defaults to -1
  45342. */
  45343. private debugLimit;
  45344. /**
  45345. * @hidden
  45346. * This is reserved for the inspector.
  45347. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45348. * You can use the factor to better multiply the final value.
  45349. */
  45350. private debugFactor;
  45351. /**
  45352. * Defines the clear coat layer parameters for the material.
  45353. */
  45354. readonly clearCoat: PBRClearCoatConfiguration;
  45355. /**
  45356. * Defines the anisotropic parameters for the material.
  45357. */
  45358. readonly anisotropy: PBRAnisotropicConfiguration;
  45359. /**
  45360. * Defines the BRDF parameters for the material.
  45361. */
  45362. readonly brdf: PBRBRDFConfiguration;
  45363. /**
  45364. * Defines the Sheen parameters for the material.
  45365. */
  45366. readonly sheen: PBRSheenConfiguration;
  45367. /**
  45368. * Instantiates a new PBRMaterial instance.
  45369. *
  45370. * @param name The material name
  45371. * @param scene The scene the material will be use in.
  45372. */
  45373. constructor(name: string, scene: Scene);
  45374. /**
  45375. * Gets a boolean indicating that current material needs to register RTT
  45376. */
  45377. readonly hasRenderTargetTextures: boolean;
  45378. /**
  45379. * Gets the name of the material class.
  45380. */
  45381. getClassName(): string;
  45382. /**
  45383. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45384. */
  45385. /**
  45386. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45387. */
  45388. useLogarithmicDepth: boolean;
  45389. /**
  45390. * Gets the current transparency mode.
  45391. */
  45392. /**
  45393. * Sets the transparency mode of the material.
  45394. *
  45395. * | Value | Type | Description |
  45396. * | ----- | ----------------------------------- | ----------- |
  45397. * | 0 | OPAQUE | |
  45398. * | 1 | ALPHATEST | |
  45399. * | 2 | ALPHABLEND | |
  45400. * | 3 | ALPHATESTANDBLEND | |
  45401. *
  45402. */
  45403. transparencyMode: Nullable<number>;
  45404. /**
  45405. * Returns true if alpha blending should be disabled.
  45406. */
  45407. private readonly _disableAlphaBlending;
  45408. /**
  45409. * Specifies whether or not this material should be rendered in alpha blend mode.
  45410. */
  45411. needAlphaBlending(): boolean;
  45412. /**
  45413. * Specifies if the mesh will require alpha blending.
  45414. * @param mesh - BJS mesh.
  45415. */
  45416. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45417. /**
  45418. * Specifies whether or not this material should be rendered in alpha test mode.
  45419. */
  45420. needAlphaTesting(): boolean;
  45421. /**
  45422. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45423. */
  45424. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45425. /**
  45426. * Gets the texture used for the alpha test.
  45427. */
  45428. getAlphaTestTexture(): BaseTexture;
  45429. /**
  45430. * Specifies that the submesh is ready to be used.
  45431. * @param mesh - BJS mesh.
  45432. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45433. * @param useInstances - Specifies that instances should be used.
  45434. * @returns - boolean indicating that the submesh is ready or not.
  45435. */
  45436. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45437. /**
  45438. * Specifies if the material uses metallic roughness workflow.
  45439. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45440. */
  45441. isMetallicWorkflow(): boolean;
  45442. private _prepareEffect;
  45443. private _prepareDefines;
  45444. /**
  45445. * Force shader compilation
  45446. */
  45447. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45448. clipPlane: boolean;
  45449. }>): void;
  45450. /**
  45451. * Initializes the uniform buffer layout for the shader.
  45452. */
  45453. buildUniformLayout(): void;
  45454. /**
  45455. * Unbinds the textures.
  45456. */
  45457. unbind(): void;
  45458. /**
  45459. * Binds the submesh data.
  45460. * @param world - The world matrix.
  45461. * @param mesh - The BJS mesh.
  45462. * @param subMesh - A submesh of the BJS mesh.
  45463. */
  45464. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45465. /**
  45466. * Returns the animatable textures.
  45467. * @returns - Array of animatable textures.
  45468. */
  45469. getAnimatables(): IAnimatable[];
  45470. /**
  45471. * Returns the texture used for reflections.
  45472. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45473. */
  45474. private _getReflectionTexture;
  45475. /**
  45476. * Returns the texture used for refraction or null if none is used.
  45477. * @returns - Refection texture if present. If no refraction texture and refraction
  45478. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45479. */
  45480. private _getRefractionTexture;
  45481. /**
  45482. * Returns an array of the actively used textures.
  45483. * @returns - Array of BaseTextures
  45484. */
  45485. getActiveTextures(): BaseTexture[];
  45486. /**
  45487. * Checks to see if a texture is used in the material.
  45488. * @param texture - Base texture to use.
  45489. * @returns - Boolean specifying if a texture is used in the material.
  45490. */
  45491. hasTexture(texture: BaseTexture): boolean;
  45492. /**
  45493. * Disposes the resources of the material.
  45494. * @param forceDisposeEffect - Forces the disposal of effects.
  45495. * @param forceDisposeTextures - Forces the disposal of all textures.
  45496. */
  45497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45498. }
  45499. }
  45500. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45501. import { Nullable } from "babylonjs/types";
  45502. import { Scene } from "babylonjs/scene";
  45503. import { Color3 } from "babylonjs/Maths/math";
  45504. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45505. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45507. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45508. /**
  45509. * The Physically based material of BJS.
  45510. *
  45511. * This offers the main features of a standard PBR material.
  45512. * For more information, please refer to the documentation :
  45513. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45514. */
  45515. export class PBRMaterial extends PBRBaseMaterial {
  45516. /**
  45517. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45518. */
  45519. static readonly PBRMATERIAL_OPAQUE: number;
  45520. /**
  45521. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45522. */
  45523. static readonly PBRMATERIAL_ALPHATEST: number;
  45524. /**
  45525. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45526. */
  45527. static readonly PBRMATERIAL_ALPHABLEND: number;
  45528. /**
  45529. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45530. * They are also discarded below the alpha cutoff threshold to improve performances.
  45531. */
  45532. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45533. /**
  45534. * Defines the default value of how much AO map is occluding the analytical lights
  45535. * (point spot...).
  45536. */
  45537. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45538. /**
  45539. * Intensity of the direct lights e.g. the four lights available in your scene.
  45540. * This impacts both the direct diffuse and specular highlights.
  45541. */
  45542. directIntensity: number;
  45543. /**
  45544. * Intensity of the emissive part of the material.
  45545. * This helps controlling the emissive effect without modifying the emissive color.
  45546. */
  45547. emissiveIntensity: number;
  45548. /**
  45549. * Intensity of the environment e.g. how much the environment will light the object
  45550. * either through harmonics for rough material or through the refelction for shiny ones.
  45551. */
  45552. environmentIntensity: number;
  45553. /**
  45554. * This is a special control allowing the reduction of the specular highlights coming from the
  45555. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45556. */
  45557. specularIntensity: number;
  45558. /**
  45559. * Debug Control allowing disabling the bump map on this material.
  45560. */
  45561. disableBumpMap: boolean;
  45562. /**
  45563. * AKA Diffuse Texture in standard nomenclature.
  45564. */
  45565. albedoTexture: BaseTexture;
  45566. /**
  45567. * AKA Occlusion Texture in other nomenclature.
  45568. */
  45569. ambientTexture: BaseTexture;
  45570. /**
  45571. * AKA Occlusion Texture Intensity in other nomenclature.
  45572. */
  45573. ambientTextureStrength: number;
  45574. /**
  45575. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45576. * 1 means it completely occludes it
  45577. * 0 mean it has no impact
  45578. */
  45579. ambientTextureImpactOnAnalyticalLights: number;
  45580. /**
  45581. * Stores the alpha values in a texture.
  45582. */
  45583. opacityTexture: BaseTexture;
  45584. /**
  45585. * Stores the reflection values in a texture.
  45586. */
  45587. reflectionTexture: Nullable<BaseTexture>;
  45588. /**
  45589. * Stores the emissive values in a texture.
  45590. */
  45591. emissiveTexture: BaseTexture;
  45592. /**
  45593. * AKA Specular texture in other nomenclature.
  45594. */
  45595. reflectivityTexture: BaseTexture;
  45596. /**
  45597. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45598. */
  45599. metallicTexture: BaseTexture;
  45600. /**
  45601. * Specifies the metallic scalar of the metallic/roughness workflow.
  45602. * Can also be used to scale the metalness values of the metallic texture.
  45603. */
  45604. metallic: Nullable<number>;
  45605. /**
  45606. * Specifies the roughness scalar of the metallic/roughness workflow.
  45607. * Can also be used to scale the roughness values of the metallic texture.
  45608. */
  45609. roughness: Nullable<number>;
  45610. /**
  45611. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45612. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45613. */
  45614. microSurfaceTexture: BaseTexture;
  45615. /**
  45616. * Stores surface normal data used to displace a mesh in a texture.
  45617. */
  45618. bumpTexture: BaseTexture;
  45619. /**
  45620. * Stores the pre-calculated light information of a mesh in a texture.
  45621. */
  45622. lightmapTexture: BaseTexture;
  45623. /**
  45624. * Stores the refracted light information in a texture.
  45625. */
  45626. refractionTexture: BaseTexture;
  45627. /**
  45628. * The color of a material in ambient lighting.
  45629. */
  45630. ambientColor: Color3;
  45631. /**
  45632. * AKA Diffuse Color in other nomenclature.
  45633. */
  45634. albedoColor: Color3;
  45635. /**
  45636. * AKA Specular Color in other nomenclature.
  45637. */
  45638. reflectivityColor: Color3;
  45639. /**
  45640. * The color reflected from the material.
  45641. */
  45642. reflectionColor: Color3;
  45643. /**
  45644. * The color emitted from the material.
  45645. */
  45646. emissiveColor: Color3;
  45647. /**
  45648. * AKA Glossiness in other nomenclature.
  45649. */
  45650. microSurface: number;
  45651. /**
  45652. * source material index of refraction (IOR)' / 'destination material IOR.
  45653. */
  45654. indexOfRefraction: number;
  45655. /**
  45656. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45657. */
  45658. invertRefractionY: boolean;
  45659. /**
  45660. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45661. * Materials half opaque for instance using refraction could benefit from this control.
  45662. */
  45663. linkRefractionWithTransparency: boolean;
  45664. /**
  45665. * If true, the light map contains occlusion information instead of lighting info.
  45666. */
  45667. useLightmapAsShadowmap: boolean;
  45668. /**
  45669. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45670. */
  45671. useAlphaFromAlbedoTexture: boolean;
  45672. /**
  45673. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45674. */
  45675. forceAlphaTest: boolean;
  45676. /**
  45677. * Defines the alpha limits in alpha test mode.
  45678. */
  45679. alphaCutOff: number;
  45680. /**
  45681. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45682. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45683. */
  45684. useSpecularOverAlpha: boolean;
  45685. /**
  45686. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45687. */
  45688. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45689. /**
  45690. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45691. */
  45692. useRoughnessFromMetallicTextureAlpha: boolean;
  45693. /**
  45694. * Specifies if the metallic texture contains the roughness information in its green channel.
  45695. */
  45696. useRoughnessFromMetallicTextureGreen: boolean;
  45697. /**
  45698. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45699. */
  45700. useMetallnessFromMetallicTextureBlue: boolean;
  45701. /**
  45702. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45703. */
  45704. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45705. /**
  45706. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45707. */
  45708. useAmbientInGrayScale: boolean;
  45709. /**
  45710. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45711. * The material will try to infer what glossiness each pixel should be.
  45712. */
  45713. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45714. /**
  45715. * BJS is using an harcoded light falloff based on a manually sets up range.
  45716. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45717. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45718. */
  45719. /**
  45720. * BJS is using an harcoded light falloff based on a manually sets up range.
  45721. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45722. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45723. */
  45724. usePhysicalLightFalloff: boolean;
  45725. /**
  45726. * In order to support the falloff compatibility with gltf, a special mode has been added
  45727. * to reproduce the gltf light falloff.
  45728. */
  45729. /**
  45730. * In order to support the falloff compatibility with gltf, a special mode has been added
  45731. * to reproduce the gltf light falloff.
  45732. */
  45733. useGLTFLightFalloff: boolean;
  45734. /**
  45735. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45736. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45737. */
  45738. useRadianceOverAlpha: boolean;
  45739. /**
  45740. * Allows using an object space normal map (instead of tangent space).
  45741. */
  45742. useObjectSpaceNormalMap: boolean;
  45743. /**
  45744. * Allows using the bump map in parallax mode.
  45745. */
  45746. useParallax: boolean;
  45747. /**
  45748. * Allows using the bump map in parallax occlusion mode.
  45749. */
  45750. useParallaxOcclusion: boolean;
  45751. /**
  45752. * Controls the scale bias of the parallax mode.
  45753. */
  45754. parallaxScaleBias: number;
  45755. /**
  45756. * If sets to true, disables all the lights affecting the material.
  45757. */
  45758. disableLighting: boolean;
  45759. /**
  45760. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45761. */
  45762. forceIrradianceInFragment: boolean;
  45763. /**
  45764. * Number of Simultaneous lights allowed on the material.
  45765. */
  45766. maxSimultaneousLights: number;
  45767. /**
  45768. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45769. */
  45770. invertNormalMapX: boolean;
  45771. /**
  45772. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45773. */
  45774. invertNormalMapY: boolean;
  45775. /**
  45776. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45777. */
  45778. twoSidedLighting: boolean;
  45779. /**
  45780. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45781. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45782. */
  45783. useAlphaFresnel: boolean;
  45784. /**
  45785. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45786. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45787. */
  45788. useLinearAlphaFresnel: boolean;
  45789. /**
  45790. * Let user defines the brdf lookup texture used for IBL.
  45791. * A default 8bit version is embedded but you could point at :
  45792. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45793. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45794. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45795. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45796. */
  45797. environmentBRDFTexture: Nullable<BaseTexture>;
  45798. /**
  45799. * Force normal to face away from face.
  45800. */
  45801. forceNormalForward: boolean;
  45802. /**
  45803. * Enables specular anti aliasing in the PBR shader.
  45804. * It will both interacts on the Geometry for analytical and IBL lighting.
  45805. * It also prefilter the roughness map based on the bump values.
  45806. */
  45807. enableSpecularAntiAliasing: boolean;
  45808. /**
  45809. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45810. * makes the reflect vector face the model (under horizon).
  45811. */
  45812. useHorizonOcclusion: boolean;
  45813. /**
  45814. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45815. * too much the area relying on ambient texture to define their ambient occlusion.
  45816. */
  45817. useRadianceOcclusion: boolean;
  45818. /**
  45819. * If set to true, no lighting calculations will be applied.
  45820. */
  45821. unlit: boolean;
  45822. /**
  45823. * Gets the image processing configuration used either in this material.
  45824. */
  45825. /**
  45826. * Sets the Default image processing configuration used either in the this material.
  45827. *
  45828. * If sets to null, the scene one is in use.
  45829. */
  45830. imageProcessingConfiguration: ImageProcessingConfiguration;
  45831. /**
  45832. * Gets wether the color curves effect is enabled.
  45833. */
  45834. /**
  45835. * Sets wether the color curves effect is enabled.
  45836. */
  45837. cameraColorCurvesEnabled: boolean;
  45838. /**
  45839. * Gets wether the color grading effect is enabled.
  45840. */
  45841. /**
  45842. * Gets wether the color grading effect is enabled.
  45843. */
  45844. cameraColorGradingEnabled: boolean;
  45845. /**
  45846. * Gets wether tonemapping is enabled or not.
  45847. */
  45848. /**
  45849. * Sets wether tonemapping is enabled or not
  45850. */
  45851. cameraToneMappingEnabled: boolean;
  45852. /**
  45853. * The camera exposure used on this material.
  45854. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45855. * This corresponds to a photographic exposure.
  45856. */
  45857. /**
  45858. * The camera exposure used on this material.
  45859. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45860. * This corresponds to a photographic exposure.
  45861. */
  45862. cameraExposure: number;
  45863. /**
  45864. * Gets The camera contrast used on this material.
  45865. */
  45866. /**
  45867. * Sets The camera contrast used on this material.
  45868. */
  45869. cameraContrast: number;
  45870. /**
  45871. * Gets the Color Grading 2D Lookup Texture.
  45872. */
  45873. /**
  45874. * Sets the Color Grading 2D Lookup Texture.
  45875. */
  45876. cameraColorGradingTexture: Nullable<BaseTexture>;
  45877. /**
  45878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45880. * 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;
  45881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45882. */
  45883. /**
  45884. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45885. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45886. * 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;
  45887. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45888. */
  45889. cameraColorCurves: Nullable<ColorCurves>;
  45890. /**
  45891. * Instantiates a new PBRMaterial instance.
  45892. *
  45893. * @param name The material name
  45894. * @param scene The scene the material will be use in.
  45895. */
  45896. constructor(name: string, scene: Scene);
  45897. /**
  45898. * Returns the name of this material class.
  45899. */
  45900. getClassName(): string;
  45901. /**
  45902. * Makes a duplicate of the current material.
  45903. * @param name - name to use for the new material.
  45904. */
  45905. clone(name: string): PBRMaterial;
  45906. /**
  45907. * Serializes this PBR Material.
  45908. * @returns - An object with the serialized material.
  45909. */
  45910. serialize(): any;
  45911. /**
  45912. * Parses a PBR Material from a serialized object.
  45913. * @param source - Serialized object.
  45914. * @param scene - BJS scene instance.
  45915. * @param rootUrl - url for the scene object
  45916. * @returns - PBRMaterial
  45917. */
  45918. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45919. }
  45920. }
  45921. declare module "babylonjs/Misc/dds" {
  45922. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45923. import { Engine } from "babylonjs/Engines/engine";
  45924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45925. import { Nullable } from "babylonjs/types";
  45926. import { Scene } from "babylonjs/scene";
  45927. /**
  45928. * Direct draw surface info
  45929. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45930. */
  45931. export interface DDSInfo {
  45932. /**
  45933. * Width of the texture
  45934. */
  45935. width: number;
  45936. /**
  45937. * Width of the texture
  45938. */
  45939. height: number;
  45940. /**
  45941. * Number of Mipmaps for the texture
  45942. * @see https://en.wikipedia.org/wiki/Mipmap
  45943. */
  45944. mipmapCount: number;
  45945. /**
  45946. * If the textures format is a known fourCC format
  45947. * @see https://www.fourcc.org/
  45948. */
  45949. isFourCC: boolean;
  45950. /**
  45951. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45952. */
  45953. isRGB: boolean;
  45954. /**
  45955. * If the texture is a lumincance format
  45956. */
  45957. isLuminance: boolean;
  45958. /**
  45959. * If this is a cube texture
  45960. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45961. */
  45962. isCube: boolean;
  45963. /**
  45964. * If the texture is a compressed format eg. FOURCC_DXT1
  45965. */
  45966. isCompressed: boolean;
  45967. /**
  45968. * The dxgiFormat of the texture
  45969. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45970. */
  45971. dxgiFormat: number;
  45972. /**
  45973. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45974. */
  45975. textureType: number;
  45976. /**
  45977. * Sphericle polynomial created for the dds texture
  45978. */
  45979. sphericalPolynomial?: SphericalPolynomial;
  45980. }
  45981. /**
  45982. * Class used to provide DDS decompression tools
  45983. */
  45984. export class DDSTools {
  45985. /**
  45986. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45987. */
  45988. static StoreLODInAlphaChannel: boolean;
  45989. /**
  45990. * Gets DDS information from an array buffer
  45991. * @param arrayBuffer defines the array buffer to read data from
  45992. * @returns the DDS information
  45993. */
  45994. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45995. private static _FloatView;
  45996. private static _Int32View;
  45997. private static _ToHalfFloat;
  45998. private static _FromHalfFloat;
  45999. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46000. private static _GetHalfFloatRGBAArrayBuffer;
  46001. private static _GetFloatRGBAArrayBuffer;
  46002. private static _GetFloatAsUIntRGBAArrayBuffer;
  46003. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46004. private static _GetRGBAArrayBuffer;
  46005. private static _ExtractLongWordOrder;
  46006. private static _GetRGBArrayBuffer;
  46007. private static _GetLuminanceArrayBuffer;
  46008. /**
  46009. * Uploads DDS Levels to a Babylon Texture
  46010. * @hidden
  46011. */
  46012. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46013. }
  46014. module "babylonjs/Engines/engine" {
  46015. interface Engine {
  46016. /**
  46017. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46018. * @param rootUrl defines the url where the file to load is located
  46019. * @param scene defines the current scene
  46020. * @param lodScale defines scale to apply to the mip map selection
  46021. * @param lodOffset defines offset to apply to the mip map selection
  46022. * @param onLoad defines an optional callback raised when the texture is loaded
  46023. * @param onError defines an optional callback raised if there is an issue to load the texture
  46024. * @param format defines the format of the data
  46025. * @param forcedExtension defines the extension to use to pick the right loader
  46026. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46027. * @returns the cube texture as an InternalTexture
  46028. */
  46029. 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;
  46030. }
  46031. }
  46032. }
  46033. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46034. import { Nullable } from "babylonjs/types";
  46035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46036. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46037. /**
  46038. * Implementation of the DDS Texture Loader.
  46039. * @hidden
  46040. */
  46041. export class _DDSTextureLoader implements IInternalTextureLoader {
  46042. /**
  46043. * Defines wether the loader supports cascade loading the different faces.
  46044. */
  46045. readonly supportCascades: boolean;
  46046. /**
  46047. * This returns if the loader support the current file information.
  46048. * @param extension defines the file extension of the file being loaded
  46049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46050. * @param fallback defines the fallback internal texture if any
  46051. * @param isBase64 defines whether the texture is encoded as a base64
  46052. * @param isBuffer defines whether the texture data are stored as a buffer
  46053. * @returns true if the loader can load the specified file
  46054. */
  46055. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46056. /**
  46057. * Transform the url before loading if required.
  46058. * @param rootUrl the url of the texture
  46059. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46060. * @returns the transformed texture
  46061. */
  46062. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46063. /**
  46064. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46065. * @param rootUrl the url of the texture
  46066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46067. * @returns the fallback texture
  46068. */
  46069. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46070. /**
  46071. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46072. * @param data contains the texture data
  46073. * @param texture defines the BabylonJS internal texture
  46074. * @param createPolynomials will be true if polynomials have been requested
  46075. * @param onLoad defines the callback to trigger once the texture is ready
  46076. * @param onError defines the callback to trigger in case of error
  46077. */
  46078. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46079. /**
  46080. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46081. * @param data contains the texture data
  46082. * @param texture defines the BabylonJS internal texture
  46083. * @param callback defines the method to call once ready to upload
  46084. */
  46085. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46086. }
  46087. }
  46088. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46089. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46090. /** @hidden */
  46091. export var rgbdEncodePixelShader: {
  46092. name: string;
  46093. shader: string;
  46094. };
  46095. }
  46096. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46098. /** @hidden */
  46099. export var rgbdDecodePixelShader: {
  46100. name: string;
  46101. shader: string;
  46102. };
  46103. }
  46104. declare module "babylonjs/Misc/environmentTextureTools" {
  46105. import { Nullable } from "babylonjs/types";
  46106. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46108. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46109. import "babylonjs/Shaders/rgbdEncode.fragment";
  46110. import "babylonjs/Shaders/rgbdDecode.fragment";
  46111. /**
  46112. * Raw texture data and descriptor sufficient for WebGL texture upload
  46113. */
  46114. export interface EnvironmentTextureInfo {
  46115. /**
  46116. * Version of the environment map
  46117. */
  46118. version: number;
  46119. /**
  46120. * Width of image
  46121. */
  46122. width: number;
  46123. /**
  46124. * Irradiance information stored in the file.
  46125. */
  46126. irradiance: any;
  46127. /**
  46128. * Specular information stored in the file.
  46129. */
  46130. specular: any;
  46131. }
  46132. /**
  46133. * Sets of helpers addressing the serialization and deserialization of environment texture
  46134. * stored in a BabylonJS env file.
  46135. * Those files are usually stored as .env files.
  46136. */
  46137. export class EnvironmentTextureTools {
  46138. /**
  46139. * Magic number identifying the env file.
  46140. */
  46141. private static _MagicBytes;
  46142. /**
  46143. * Gets the environment info from an env file.
  46144. * @param data The array buffer containing the .env bytes.
  46145. * @returns the environment file info (the json header) if successfully parsed.
  46146. */
  46147. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46148. /**
  46149. * Creates an environment texture from a loaded cube texture.
  46150. * @param texture defines the cube texture to convert in env file
  46151. * @return a promise containing the environment data if succesfull.
  46152. */
  46153. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46154. /**
  46155. * Creates a JSON representation of the spherical data.
  46156. * @param texture defines the texture containing the polynomials
  46157. * @return the JSON representation of the spherical info
  46158. */
  46159. private static _CreateEnvTextureIrradiance;
  46160. /**
  46161. * Uploads the texture info contained in the env file to the GPU.
  46162. * @param texture defines the internal texture to upload to
  46163. * @param arrayBuffer defines the buffer cotaining the data to load
  46164. * @param info defines the texture info retrieved through the GetEnvInfo method
  46165. * @returns a promise
  46166. */
  46167. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46168. /**
  46169. * Uploads the levels of image data to the GPU.
  46170. * @param texture defines the internal texture to upload to
  46171. * @param imageData defines the array buffer views of image data [mipmap][face]
  46172. * @returns a promise
  46173. */
  46174. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46175. /**
  46176. * Uploads spherical polynomials information to the texture.
  46177. * @param texture defines the texture we are trying to upload the information to
  46178. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46179. */
  46180. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46181. /** @hidden */
  46182. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46183. }
  46184. }
  46185. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46186. import { Nullable } from "babylonjs/types";
  46187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46188. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46189. /**
  46190. * Implementation of the ENV Texture Loader.
  46191. * @hidden
  46192. */
  46193. export class _ENVTextureLoader implements IInternalTextureLoader {
  46194. /**
  46195. * Defines wether the loader supports cascade loading the different faces.
  46196. */
  46197. readonly supportCascades: boolean;
  46198. /**
  46199. * This returns if the loader support the current file information.
  46200. * @param extension defines the file extension of the file being loaded
  46201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46202. * @param fallback defines the fallback internal texture if any
  46203. * @param isBase64 defines whether the texture is encoded as a base64
  46204. * @param isBuffer defines whether the texture data are stored as a buffer
  46205. * @returns true if the loader can load the specified file
  46206. */
  46207. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46208. /**
  46209. * Transform the url before loading if required.
  46210. * @param rootUrl the url of the texture
  46211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46212. * @returns the transformed texture
  46213. */
  46214. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46215. /**
  46216. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46217. * @param rootUrl the url of the texture
  46218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46219. * @returns the fallback texture
  46220. */
  46221. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46222. /**
  46223. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46224. * @param data contains the texture data
  46225. * @param texture defines the BabylonJS internal texture
  46226. * @param createPolynomials will be true if polynomials have been requested
  46227. * @param onLoad defines the callback to trigger once the texture is ready
  46228. * @param onError defines the callback to trigger in case of error
  46229. */
  46230. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46231. /**
  46232. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46233. * @param data contains the texture data
  46234. * @param texture defines the BabylonJS internal texture
  46235. * @param callback defines the method to call once ready to upload
  46236. */
  46237. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46238. }
  46239. }
  46240. declare module "babylonjs/Misc/khronosTextureContainer" {
  46241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46242. /**
  46243. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46244. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46245. */
  46246. export class KhronosTextureContainer {
  46247. /** contents of the KTX container file */
  46248. arrayBuffer: any;
  46249. private static HEADER_LEN;
  46250. private static COMPRESSED_2D;
  46251. private static COMPRESSED_3D;
  46252. private static TEX_2D;
  46253. private static TEX_3D;
  46254. /**
  46255. * Gets the openGL type
  46256. */
  46257. glType: number;
  46258. /**
  46259. * Gets the openGL type size
  46260. */
  46261. glTypeSize: number;
  46262. /**
  46263. * Gets the openGL format
  46264. */
  46265. glFormat: number;
  46266. /**
  46267. * Gets the openGL internal format
  46268. */
  46269. glInternalFormat: number;
  46270. /**
  46271. * Gets the base internal format
  46272. */
  46273. glBaseInternalFormat: number;
  46274. /**
  46275. * Gets image width in pixel
  46276. */
  46277. pixelWidth: number;
  46278. /**
  46279. * Gets image height in pixel
  46280. */
  46281. pixelHeight: number;
  46282. /**
  46283. * Gets image depth in pixels
  46284. */
  46285. pixelDepth: number;
  46286. /**
  46287. * Gets the number of array elements
  46288. */
  46289. numberOfArrayElements: number;
  46290. /**
  46291. * Gets the number of faces
  46292. */
  46293. numberOfFaces: number;
  46294. /**
  46295. * Gets the number of mipmap levels
  46296. */
  46297. numberOfMipmapLevels: number;
  46298. /**
  46299. * Gets the bytes of key value data
  46300. */
  46301. bytesOfKeyValueData: number;
  46302. /**
  46303. * Gets the load type
  46304. */
  46305. loadType: number;
  46306. /**
  46307. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46308. */
  46309. isInvalid: boolean;
  46310. /**
  46311. * Creates a new KhronosTextureContainer
  46312. * @param arrayBuffer contents of the KTX container file
  46313. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46314. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46315. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46316. */
  46317. constructor(
  46318. /** contents of the KTX container file */
  46319. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46320. /**
  46321. * Uploads KTX content to a Babylon Texture.
  46322. * It is assumed that the texture has already been created & is currently bound
  46323. * @hidden
  46324. */
  46325. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46326. private _upload2DCompressedLevels;
  46327. }
  46328. }
  46329. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46330. import { Nullable } from "babylonjs/types";
  46331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46332. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46333. /**
  46334. * Implementation of the KTX Texture Loader.
  46335. * @hidden
  46336. */
  46337. export class _KTXTextureLoader implements IInternalTextureLoader {
  46338. /**
  46339. * Defines wether the loader supports cascade loading the different faces.
  46340. */
  46341. readonly supportCascades: boolean;
  46342. /**
  46343. * This returns if the loader support the current file information.
  46344. * @param extension defines the file extension of the file being loaded
  46345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46346. * @param fallback defines the fallback internal texture if any
  46347. * @param isBase64 defines whether the texture is encoded as a base64
  46348. * @param isBuffer defines whether the texture data are stored as a buffer
  46349. * @returns true if the loader can load the specified file
  46350. */
  46351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46352. /**
  46353. * Transform the url before loading if required.
  46354. * @param rootUrl the url of the texture
  46355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46356. * @returns the transformed texture
  46357. */
  46358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46359. /**
  46360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46361. * @param rootUrl the url of the texture
  46362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46363. * @returns the fallback texture
  46364. */
  46365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46366. /**
  46367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46368. * @param data contains the texture data
  46369. * @param texture defines the BabylonJS internal texture
  46370. * @param createPolynomials will be true if polynomials have been requested
  46371. * @param onLoad defines the callback to trigger once the texture is ready
  46372. * @param onError defines the callback to trigger in case of error
  46373. */
  46374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46375. /**
  46376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46377. * @param data contains the texture data
  46378. * @param texture defines the BabylonJS internal texture
  46379. * @param callback defines the method to call once ready to upload
  46380. */
  46381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46382. }
  46383. }
  46384. declare module "babylonjs/Helpers/sceneHelpers" {
  46385. import { Nullable } from "babylonjs/types";
  46386. import { Mesh } from "babylonjs/Meshes/mesh";
  46387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46388. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46389. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46390. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46391. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46392. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46393. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46394. import "babylonjs/Meshes/Builders/boxBuilder";
  46395. /** @hidden */
  46396. export var _forceSceneHelpersToBundle: boolean;
  46397. module "babylonjs/scene" {
  46398. interface Scene {
  46399. /**
  46400. * Creates a default light for the scene.
  46401. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46402. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46403. */
  46404. createDefaultLight(replace?: boolean): void;
  46405. /**
  46406. * Creates a default camera for the scene.
  46407. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46408. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46409. * @param replace has default false, when true replaces the active camera in the scene
  46410. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46411. */
  46412. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46413. /**
  46414. * Creates a default camera and a default light.
  46415. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46416. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46417. * @param replace has the default false, when true replaces the active camera/light in the scene
  46418. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46419. */
  46420. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46421. /**
  46422. * Creates a new sky box
  46423. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46424. * @param environmentTexture defines the texture to use as environment texture
  46425. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46426. * @param scale defines the overall scale of the skybox
  46427. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46428. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46429. * @returns a new mesh holding the sky box
  46430. */
  46431. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46432. /**
  46433. * Creates a new environment
  46434. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46435. * @param options defines the options you can use to configure the environment
  46436. * @returns the new EnvironmentHelper
  46437. */
  46438. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46439. /**
  46440. * Creates a new VREXperienceHelper
  46441. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46442. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46443. * @returns a new VREXperienceHelper
  46444. */
  46445. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46446. /**
  46447. * Creates a new XREXperienceHelper
  46448. * @see http://doc.babylonjs.com/how_to/webxr
  46449. * @returns a promise for a new XREXperienceHelper
  46450. */
  46451. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46452. }
  46453. }
  46454. }
  46455. declare module "babylonjs/Helpers/videoDome" {
  46456. import { Scene } from "babylonjs/scene";
  46457. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46458. import { Mesh } from "babylonjs/Meshes/mesh";
  46459. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46460. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46461. import "babylonjs/Meshes/Builders/sphereBuilder";
  46462. /**
  46463. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46464. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46465. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46466. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46467. */
  46468. export class VideoDome extends TransformNode {
  46469. /**
  46470. * Define the video source as a Monoscopic panoramic 360 video.
  46471. */
  46472. static readonly MODE_MONOSCOPIC: number;
  46473. /**
  46474. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46475. */
  46476. static readonly MODE_TOPBOTTOM: number;
  46477. /**
  46478. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46479. */
  46480. static readonly MODE_SIDEBYSIDE: number;
  46481. private _useDirectMapping;
  46482. /**
  46483. * The video texture being displayed on the sphere
  46484. */
  46485. protected _videoTexture: VideoTexture;
  46486. /**
  46487. * Gets the video texture being displayed on the sphere
  46488. */
  46489. readonly videoTexture: VideoTexture;
  46490. /**
  46491. * The skybox material
  46492. */
  46493. protected _material: BackgroundMaterial;
  46494. /**
  46495. * The surface used for the skybox
  46496. */
  46497. protected _mesh: Mesh;
  46498. /**
  46499. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46500. * Also see the options.resolution property.
  46501. */
  46502. fovMultiplier: number;
  46503. private _videoMode;
  46504. /**
  46505. * Gets or set the current video mode for the video. It can be:
  46506. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46507. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46508. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46509. */
  46510. videoMode: number;
  46511. /**
  46512. * Oberserver used in Stereoscopic VR Mode.
  46513. */
  46514. private _onBeforeCameraRenderObserver;
  46515. /**
  46516. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46517. * @param name Element's name, child elements will append suffixes for their own names.
  46518. * @param urlsOrVideo defines the url(s) or the video element to use
  46519. * @param options An object containing optional or exposed sub element properties
  46520. */
  46521. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46522. resolution?: number;
  46523. clickToPlay?: boolean;
  46524. autoPlay?: boolean;
  46525. loop?: boolean;
  46526. size?: number;
  46527. poster?: string;
  46528. useDirectMapping?: boolean;
  46529. }, scene: Scene);
  46530. private _changeVideoMode;
  46531. /**
  46532. * Releases resources associated with this node.
  46533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46535. */
  46536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46537. }
  46538. }
  46539. declare module "babylonjs/Helpers/index" {
  46540. export * from "babylonjs/Helpers/environmentHelper";
  46541. export * from "babylonjs/Helpers/photoDome";
  46542. export * from "babylonjs/Helpers/sceneHelpers";
  46543. export * from "babylonjs/Helpers/videoDome";
  46544. }
  46545. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46546. import { PerfCounter } from "babylonjs/Misc/tools";
  46547. import { IDisposable } from "babylonjs/scene";
  46548. import { Engine } from "babylonjs/Engines/engine";
  46549. /**
  46550. * This class can be used to get instrumentation data from a Babylon engine
  46551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46552. */
  46553. export class EngineInstrumentation implements IDisposable {
  46554. /**
  46555. * Define the instrumented engine.
  46556. */
  46557. engine: Engine;
  46558. private _captureGPUFrameTime;
  46559. private _gpuFrameTimeToken;
  46560. private _gpuFrameTime;
  46561. private _captureShaderCompilationTime;
  46562. private _shaderCompilationTime;
  46563. private _onBeginFrameObserver;
  46564. private _onEndFrameObserver;
  46565. private _onBeforeShaderCompilationObserver;
  46566. private _onAfterShaderCompilationObserver;
  46567. /**
  46568. * Gets the perf counter used for GPU frame time
  46569. */
  46570. readonly gpuFrameTimeCounter: PerfCounter;
  46571. /**
  46572. * Gets the GPU frame time capture status
  46573. */
  46574. /**
  46575. * Enable or disable the GPU frame time capture
  46576. */
  46577. captureGPUFrameTime: boolean;
  46578. /**
  46579. * Gets the perf counter used for shader compilation time
  46580. */
  46581. readonly shaderCompilationTimeCounter: PerfCounter;
  46582. /**
  46583. * Gets the shader compilation time capture status
  46584. */
  46585. /**
  46586. * Enable or disable the shader compilation time capture
  46587. */
  46588. captureShaderCompilationTime: boolean;
  46589. /**
  46590. * Instantiates a new engine instrumentation.
  46591. * This class can be used to get instrumentation data from a Babylon engine
  46592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46593. * @param engine Defines the engine to instrument
  46594. */
  46595. constructor(
  46596. /**
  46597. * Define the instrumented engine.
  46598. */
  46599. engine: Engine);
  46600. /**
  46601. * Dispose and release associated resources.
  46602. */
  46603. dispose(): void;
  46604. }
  46605. }
  46606. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46607. import { PerfCounter } from "babylonjs/Misc/tools";
  46608. import { Scene, IDisposable } from "babylonjs/scene";
  46609. /**
  46610. * This class can be used to get instrumentation data from a Babylon engine
  46611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46612. */
  46613. export class SceneInstrumentation implements IDisposable {
  46614. /**
  46615. * Defines the scene to instrument
  46616. */
  46617. scene: Scene;
  46618. private _captureActiveMeshesEvaluationTime;
  46619. private _activeMeshesEvaluationTime;
  46620. private _captureRenderTargetsRenderTime;
  46621. private _renderTargetsRenderTime;
  46622. private _captureFrameTime;
  46623. private _frameTime;
  46624. private _captureRenderTime;
  46625. private _renderTime;
  46626. private _captureInterFrameTime;
  46627. private _interFrameTime;
  46628. private _captureParticlesRenderTime;
  46629. private _particlesRenderTime;
  46630. private _captureSpritesRenderTime;
  46631. private _spritesRenderTime;
  46632. private _capturePhysicsTime;
  46633. private _physicsTime;
  46634. private _captureAnimationsTime;
  46635. private _animationsTime;
  46636. private _captureCameraRenderTime;
  46637. private _cameraRenderTime;
  46638. private _onBeforeActiveMeshesEvaluationObserver;
  46639. private _onAfterActiveMeshesEvaluationObserver;
  46640. private _onBeforeRenderTargetsRenderObserver;
  46641. private _onAfterRenderTargetsRenderObserver;
  46642. private _onAfterRenderObserver;
  46643. private _onBeforeDrawPhaseObserver;
  46644. private _onAfterDrawPhaseObserver;
  46645. private _onBeforeAnimationsObserver;
  46646. private _onBeforeParticlesRenderingObserver;
  46647. private _onAfterParticlesRenderingObserver;
  46648. private _onBeforeSpritesRenderingObserver;
  46649. private _onAfterSpritesRenderingObserver;
  46650. private _onBeforePhysicsObserver;
  46651. private _onAfterPhysicsObserver;
  46652. private _onAfterAnimationsObserver;
  46653. private _onBeforeCameraRenderObserver;
  46654. private _onAfterCameraRenderObserver;
  46655. /**
  46656. * Gets the perf counter used for active meshes evaluation time
  46657. */
  46658. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46659. /**
  46660. * Gets the active meshes evaluation time capture status
  46661. */
  46662. /**
  46663. * Enable or disable the active meshes evaluation time capture
  46664. */
  46665. captureActiveMeshesEvaluationTime: boolean;
  46666. /**
  46667. * Gets the perf counter used for render targets render time
  46668. */
  46669. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46670. /**
  46671. * Gets the render targets render time capture status
  46672. */
  46673. /**
  46674. * Enable or disable the render targets render time capture
  46675. */
  46676. captureRenderTargetsRenderTime: boolean;
  46677. /**
  46678. * Gets the perf counter used for particles render time
  46679. */
  46680. readonly particlesRenderTimeCounter: PerfCounter;
  46681. /**
  46682. * Gets the particles render time capture status
  46683. */
  46684. /**
  46685. * Enable or disable the particles render time capture
  46686. */
  46687. captureParticlesRenderTime: boolean;
  46688. /**
  46689. * Gets the perf counter used for sprites render time
  46690. */
  46691. readonly spritesRenderTimeCounter: PerfCounter;
  46692. /**
  46693. * Gets the sprites render time capture status
  46694. */
  46695. /**
  46696. * Enable or disable the sprites render time capture
  46697. */
  46698. captureSpritesRenderTime: boolean;
  46699. /**
  46700. * Gets the perf counter used for physics time
  46701. */
  46702. readonly physicsTimeCounter: PerfCounter;
  46703. /**
  46704. * Gets the physics time capture status
  46705. */
  46706. /**
  46707. * Enable or disable the physics time capture
  46708. */
  46709. capturePhysicsTime: boolean;
  46710. /**
  46711. * Gets the perf counter used for animations time
  46712. */
  46713. readonly animationsTimeCounter: PerfCounter;
  46714. /**
  46715. * Gets the animations time capture status
  46716. */
  46717. /**
  46718. * Enable or disable the animations time capture
  46719. */
  46720. captureAnimationsTime: boolean;
  46721. /**
  46722. * Gets the perf counter used for frame time capture
  46723. */
  46724. readonly frameTimeCounter: PerfCounter;
  46725. /**
  46726. * Gets the frame time capture status
  46727. */
  46728. /**
  46729. * Enable or disable the frame time capture
  46730. */
  46731. captureFrameTime: boolean;
  46732. /**
  46733. * Gets the perf counter used for inter-frames time capture
  46734. */
  46735. readonly interFrameTimeCounter: PerfCounter;
  46736. /**
  46737. * Gets the inter-frames time capture status
  46738. */
  46739. /**
  46740. * Enable or disable the inter-frames time capture
  46741. */
  46742. captureInterFrameTime: boolean;
  46743. /**
  46744. * Gets the perf counter used for render time capture
  46745. */
  46746. readonly renderTimeCounter: PerfCounter;
  46747. /**
  46748. * Gets the render time capture status
  46749. */
  46750. /**
  46751. * Enable or disable the render time capture
  46752. */
  46753. captureRenderTime: boolean;
  46754. /**
  46755. * Gets the perf counter used for camera render time capture
  46756. */
  46757. readonly cameraRenderTimeCounter: PerfCounter;
  46758. /**
  46759. * Gets the camera render time capture status
  46760. */
  46761. /**
  46762. * Enable or disable the camera render time capture
  46763. */
  46764. captureCameraRenderTime: boolean;
  46765. /**
  46766. * Gets the perf counter used for draw calls
  46767. */
  46768. readonly drawCallsCounter: PerfCounter;
  46769. /**
  46770. * Gets the perf counter used for texture collisions
  46771. */
  46772. readonly textureCollisionsCounter: PerfCounter;
  46773. /**
  46774. * Instantiates a new scene instrumentation.
  46775. * This class can be used to get instrumentation data from a Babylon engine
  46776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46777. * @param scene Defines the scene to instrument
  46778. */
  46779. constructor(
  46780. /**
  46781. * Defines the scene to instrument
  46782. */
  46783. scene: Scene);
  46784. /**
  46785. * Dispose and release associated resources.
  46786. */
  46787. dispose(): void;
  46788. }
  46789. }
  46790. declare module "babylonjs/Instrumentation/index" {
  46791. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46792. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46793. export * from "babylonjs/Instrumentation/timeToken";
  46794. }
  46795. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46796. /** @hidden */
  46797. export var glowMapGenerationPixelShader: {
  46798. name: string;
  46799. shader: string;
  46800. };
  46801. }
  46802. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46803. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46804. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46805. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46806. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46807. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46808. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46809. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46810. /** @hidden */
  46811. export var glowMapGenerationVertexShader: {
  46812. name: string;
  46813. shader: string;
  46814. };
  46815. }
  46816. declare module "babylonjs/Layers/effectLayer" {
  46817. import { Observable } from "babylonjs/Misc/observable";
  46818. import { Nullable } from "babylonjs/types";
  46819. import { Camera } from "babylonjs/Cameras/camera";
  46820. import { Scene } from "babylonjs/scene";
  46821. import { Color4, ISize } from "babylonjs/Maths/math";
  46822. import { Engine } from "babylonjs/Engines/engine";
  46823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46825. import { Mesh } from "babylonjs/Meshes/mesh";
  46826. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46829. import { Effect } from "babylonjs/Materials/effect";
  46830. import { Material } from "babylonjs/Materials/material";
  46831. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46832. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46833. /**
  46834. * Effect layer options. This helps customizing the behaviour
  46835. * of the effect layer.
  46836. */
  46837. export interface IEffectLayerOptions {
  46838. /**
  46839. * Multiplication factor apply to the canvas size to compute the render target size
  46840. * used to generated the objects (the smaller the faster).
  46841. */
  46842. mainTextureRatio: number;
  46843. /**
  46844. * Enforces a fixed size texture to ensure effect stability across devices.
  46845. */
  46846. mainTextureFixedSize?: number;
  46847. /**
  46848. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46849. */
  46850. alphaBlendingMode: number;
  46851. /**
  46852. * The camera attached to the layer.
  46853. */
  46854. camera: Nullable<Camera>;
  46855. /**
  46856. * The rendering group to draw the layer in.
  46857. */
  46858. renderingGroupId: number;
  46859. }
  46860. /**
  46861. * The effect layer Helps adding post process effect blended with the main pass.
  46862. *
  46863. * This can be for instance use to generate glow or higlight effects on the scene.
  46864. *
  46865. * The effect layer class can not be used directly and is intented to inherited from to be
  46866. * customized per effects.
  46867. */
  46868. export abstract class EffectLayer {
  46869. private _vertexBuffers;
  46870. private _indexBuffer;
  46871. private _cachedDefines;
  46872. private _effectLayerMapGenerationEffect;
  46873. private _effectLayerOptions;
  46874. private _mergeEffect;
  46875. protected _scene: Scene;
  46876. protected _engine: Engine;
  46877. protected _maxSize: number;
  46878. protected _mainTextureDesiredSize: ISize;
  46879. protected _mainTexture: RenderTargetTexture;
  46880. protected _shouldRender: boolean;
  46881. protected _postProcesses: PostProcess[];
  46882. protected _textures: BaseTexture[];
  46883. protected _emissiveTextureAndColor: {
  46884. texture: Nullable<BaseTexture>;
  46885. color: Color4;
  46886. };
  46887. /**
  46888. * The name of the layer
  46889. */
  46890. name: string;
  46891. /**
  46892. * The clear color of the texture used to generate the glow map.
  46893. */
  46894. neutralColor: Color4;
  46895. /**
  46896. * Specifies wether the highlight layer is enabled or not.
  46897. */
  46898. isEnabled: boolean;
  46899. /**
  46900. * Gets the camera attached to the layer.
  46901. */
  46902. readonly camera: Nullable<Camera>;
  46903. /**
  46904. * Gets the rendering group id the layer should render in.
  46905. */
  46906. readonly renderingGroupId: number;
  46907. /**
  46908. * An event triggered when the effect layer has been disposed.
  46909. */
  46910. onDisposeObservable: Observable<EffectLayer>;
  46911. /**
  46912. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46913. */
  46914. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46915. /**
  46916. * An event triggered when the generated texture is being merged in the scene.
  46917. */
  46918. onBeforeComposeObservable: Observable<EffectLayer>;
  46919. /**
  46920. * An event triggered when the generated texture has been merged in the scene.
  46921. */
  46922. onAfterComposeObservable: Observable<EffectLayer>;
  46923. /**
  46924. * An event triggered when the efffect layer changes its size.
  46925. */
  46926. onSizeChangedObservable: Observable<EffectLayer>;
  46927. /** @hidden */
  46928. static _SceneComponentInitialization: (scene: Scene) => void;
  46929. /**
  46930. * Instantiates a new effect Layer and references it in the scene.
  46931. * @param name The name of the layer
  46932. * @param scene The scene to use the layer in
  46933. */
  46934. constructor(
  46935. /** The Friendly of the effect in the scene */
  46936. name: string, scene: Scene);
  46937. /**
  46938. * Get the effect name of the layer.
  46939. * @return The effect name
  46940. */
  46941. abstract getEffectName(): string;
  46942. /**
  46943. * Checks for the readiness of the element composing the layer.
  46944. * @param subMesh the mesh to check for
  46945. * @param useInstances specify wether or not to use instances to render the mesh
  46946. * @return true if ready otherwise, false
  46947. */
  46948. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46949. /**
  46950. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46951. * @returns true if the effect requires stencil during the main canvas render pass.
  46952. */
  46953. abstract needStencil(): boolean;
  46954. /**
  46955. * Create the merge effect. This is the shader use to blit the information back
  46956. * to the main canvas at the end of the scene rendering.
  46957. * @returns The effect containing the shader used to merge the effect on the main canvas
  46958. */
  46959. protected abstract _createMergeEffect(): Effect;
  46960. /**
  46961. * Creates the render target textures and post processes used in the effect layer.
  46962. */
  46963. protected abstract _createTextureAndPostProcesses(): void;
  46964. /**
  46965. * Implementation specific of rendering the generating effect on the main canvas.
  46966. * @param effect The effect used to render through
  46967. */
  46968. protected abstract _internalRender(effect: Effect): void;
  46969. /**
  46970. * Sets the required values for both the emissive texture and and the main color.
  46971. */
  46972. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46973. /**
  46974. * Free any resources and references associated to a mesh.
  46975. * Internal use
  46976. * @param mesh The mesh to free.
  46977. */
  46978. abstract _disposeMesh(mesh: Mesh): void;
  46979. /**
  46980. * Serializes this layer (Glow or Highlight for example)
  46981. * @returns a serialized layer object
  46982. */
  46983. abstract serialize?(): any;
  46984. /**
  46985. * Initializes the effect layer with the required options.
  46986. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46987. */
  46988. protected _init(options: Partial<IEffectLayerOptions>): void;
  46989. /**
  46990. * Generates the index buffer of the full screen quad blending to the main canvas.
  46991. */
  46992. private _generateIndexBuffer;
  46993. /**
  46994. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46995. */
  46996. private _genrateVertexBuffer;
  46997. /**
  46998. * Sets the main texture desired size which is the closest power of two
  46999. * of the engine canvas size.
  47000. */
  47001. private _setMainTextureSize;
  47002. /**
  47003. * Creates the main texture for the effect layer.
  47004. */
  47005. protected _createMainTexture(): void;
  47006. /**
  47007. * Adds specific effects defines.
  47008. * @param defines The defines to add specifics to.
  47009. */
  47010. protected _addCustomEffectDefines(defines: string[]): void;
  47011. /**
  47012. * Checks for the readiness of the element composing the layer.
  47013. * @param subMesh the mesh to check for
  47014. * @param useInstances specify wether or not to use instances to render the mesh
  47015. * @param emissiveTexture the associated emissive texture used to generate the glow
  47016. * @return true if ready otherwise, false
  47017. */
  47018. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47019. /**
  47020. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47021. */
  47022. render(): void;
  47023. /**
  47024. * Determine if a given mesh will be used in the current effect.
  47025. * @param mesh mesh to test
  47026. * @returns true if the mesh will be used
  47027. */
  47028. hasMesh(mesh: AbstractMesh): boolean;
  47029. /**
  47030. * Returns true if the layer contains information to display, otherwise false.
  47031. * @returns true if the glow layer should be rendered
  47032. */
  47033. shouldRender(): boolean;
  47034. /**
  47035. * Returns true if the mesh should render, otherwise false.
  47036. * @param mesh The mesh to render
  47037. * @returns true if it should render otherwise false
  47038. */
  47039. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47040. /**
  47041. * Returns true if the mesh can be rendered, otherwise false.
  47042. * @param mesh The mesh to render
  47043. * @param material The material used on the mesh
  47044. * @returns true if it can be rendered otherwise false
  47045. */
  47046. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47047. /**
  47048. * Returns true if the mesh should render, otherwise false.
  47049. * @param mesh The mesh to render
  47050. * @returns true if it should render otherwise false
  47051. */
  47052. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47053. /**
  47054. * Renders the submesh passed in parameter to the generation map.
  47055. */
  47056. protected _renderSubMesh(subMesh: SubMesh): void;
  47057. /**
  47058. * Rebuild the required buffers.
  47059. * @hidden Internal use only.
  47060. */
  47061. _rebuild(): void;
  47062. /**
  47063. * Dispose only the render target textures and post process.
  47064. */
  47065. private _disposeTextureAndPostProcesses;
  47066. /**
  47067. * Dispose the highlight layer and free resources.
  47068. */
  47069. dispose(): void;
  47070. /**
  47071. * Gets the class name of the effect layer
  47072. * @returns the string with the class name of the effect layer
  47073. */
  47074. getClassName(): string;
  47075. /**
  47076. * Creates an effect layer from parsed effect layer data
  47077. * @param parsedEffectLayer defines effect layer data
  47078. * @param scene defines the current scene
  47079. * @param rootUrl defines the root URL containing the effect layer information
  47080. * @returns a parsed effect Layer
  47081. */
  47082. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47083. }
  47084. }
  47085. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47086. import { Scene } from "babylonjs/scene";
  47087. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47088. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47089. import { AbstractScene } from "babylonjs/abstractScene";
  47090. module "babylonjs/abstractScene" {
  47091. interface AbstractScene {
  47092. /**
  47093. * The list of effect layers (highlights/glow) added to the scene
  47094. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47095. * @see http://doc.babylonjs.com/how_to/glow_layer
  47096. */
  47097. effectLayers: Array<EffectLayer>;
  47098. /**
  47099. * Removes the given effect layer from this scene.
  47100. * @param toRemove defines the effect layer to remove
  47101. * @returns the index of the removed effect layer
  47102. */
  47103. removeEffectLayer(toRemove: EffectLayer): number;
  47104. /**
  47105. * Adds the given effect layer to this scene
  47106. * @param newEffectLayer defines the effect layer to add
  47107. */
  47108. addEffectLayer(newEffectLayer: EffectLayer): void;
  47109. }
  47110. }
  47111. /**
  47112. * Defines the layer scene component responsible to manage any effect layers
  47113. * in a given scene.
  47114. */
  47115. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47116. /**
  47117. * The component name helpfull to identify the component in the list of scene components.
  47118. */
  47119. readonly name: string;
  47120. /**
  47121. * The scene the component belongs to.
  47122. */
  47123. scene: Scene;
  47124. private _engine;
  47125. private _renderEffects;
  47126. private _needStencil;
  47127. private _previousStencilState;
  47128. /**
  47129. * Creates a new instance of the component for the given scene
  47130. * @param scene Defines the scene to register the component in
  47131. */
  47132. constructor(scene: Scene);
  47133. /**
  47134. * Registers the component in a given scene
  47135. */
  47136. register(): void;
  47137. /**
  47138. * Rebuilds the elements related to this component in case of
  47139. * context lost for instance.
  47140. */
  47141. rebuild(): void;
  47142. /**
  47143. * Serializes the component data to the specified json object
  47144. * @param serializationObject The object to serialize to
  47145. */
  47146. serialize(serializationObject: any): void;
  47147. /**
  47148. * Adds all the element from the container to the scene
  47149. * @param container the container holding the elements
  47150. */
  47151. addFromContainer(container: AbstractScene): void;
  47152. /**
  47153. * Removes all the elements in the container from the scene
  47154. * @param container contains the elements to remove
  47155. */
  47156. removeFromContainer(container: AbstractScene): void;
  47157. /**
  47158. * Disposes the component and the associated ressources.
  47159. */
  47160. dispose(): void;
  47161. private _isReadyForMesh;
  47162. private _renderMainTexture;
  47163. private _setStencil;
  47164. private _setStencilBack;
  47165. private _draw;
  47166. private _drawCamera;
  47167. private _drawRenderingGroup;
  47168. }
  47169. }
  47170. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47171. /** @hidden */
  47172. export var glowMapMergePixelShader: {
  47173. name: string;
  47174. shader: string;
  47175. };
  47176. }
  47177. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47178. /** @hidden */
  47179. export var glowMapMergeVertexShader: {
  47180. name: string;
  47181. shader: string;
  47182. };
  47183. }
  47184. declare module "babylonjs/Layers/glowLayer" {
  47185. import { Nullable } from "babylonjs/types";
  47186. import { Camera } from "babylonjs/Cameras/camera";
  47187. import { Scene } from "babylonjs/scene";
  47188. import { Color4 } from "babylonjs/Maths/math";
  47189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47191. import { Mesh } from "babylonjs/Meshes/mesh";
  47192. import { Texture } from "babylonjs/Materials/Textures/texture";
  47193. import { Effect } from "babylonjs/Materials/effect";
  47194. import { Material } from "babylonjs/Materials/material";
  47195. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47196. import "babylonjs/Shaders/glowMapMerge.fragment";
  47197. import "babylonjs/Shaders/glowMapMerge.vertex";
  47198. import "babylonjs/Layers/effectLayerSceneComponent";
  47199. module "babylonjs/abstractScene" {
  47200. interface AbstractScene {
  47201. /**
  47202. * Return a the first highlight layer of the scene with a given name.
  47203. * @param name The name of the highlight layer to look for.
  47204. * @return The highlight layer if found otherwise null.
  47205. */
  47206. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47207. }
  47208. }
  47209. /**
  47210. * Glow layer options. This helps customizing the behaviour
  47211. * of the glow layer.
  47212. */
  47213. export interface IGlowLayerOptions {
  47214. /**
  47215. * Multiplication factor apply to the canvas size to compute the render target size
  47216. * used to generated the glowing objects (the smaller the faster).
  47217. */
  47218. mainTextureRatio: number;
  47219. /**
  47220. * Enforces a fixed size texture to ensure resize independant blur.
  47221. */
  47222. mainTextureFixedSize?: number;
  47223. /**
  47224. * How big is the kernel of the blur texture.
  47225. */
  47226. blurKernelSize: number;
  47227. /**
  47228. * The camera attached to the layer.
  47229. */
  47230. camera: Nullable<Camera>;
  47231. /**
  47232. * Enable MSAA by chosing the number of samples.
  47233. */
  47234. mainTextureSamples?: number;
  47235. /**
  47236. * The rendering group to draw the layer in.
  47237. */
  47238. renderingGroupId: number;
  47239. }
  47240. /**
  47241. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47242. *
  47243. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47244. * glowy meshes to your scene.
  47245. *
  47246. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47247. */
  47248. export class GlowLayer extends EffectLayer {
  47249. /**
  47250. * Effect Name of the layer.
  47251. */
  47252. static readonly EffectName: string;
  47253. /**
  47254. * The default blur kernel size used for the glow.
  47255. */
  47256. static DefaultBlurKernelSize: number;
  47257. /**
  47258. * The default texture size ratio used for the glow.
  47259. */
  47260. static DefaultTextureRatio: number;
  47261. /**
  47262. * Sets the kernel size of the blur.
  47263. */
  47264. /**
  47265. * Gets the kernel size of the blur.
  47266. */
  47267. blurKernelSize: number;
  47268. /**
  47269. * Sets the glow intensity.
  47270. */
  47271. /**
  47272. * Gets the glow intensity.
  47273. */
  47274. intensity: number;
  47275. private _options;
  47276. private _intensity;
  47277. private _horizontalBlurPostprocess1;
  47278. private _verticalBlurPostprocess1;
  47279. private _horizontalBlurPostprocess2;
  47280. private _verticalBlurPostprocess2;
  47281. private _blurTexture1;
  47282. private _blurTexture2;
  47283. private _postProcesses1;
  47284. private _postProcesses2;
  47285. private _includedOnlyMeshes;
  47286. private _excludedMeshes;
  47287. /**
  47288. * Callback used to let the user override the color selection on a per mesh basis
  47289. */
  47290. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47291. /**
  47292. * Callback used to let the user override the texture selection on a per mesh basis
  47293. */
  47294. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47295. /**
  47296. * Instantiates a new glow Layer and references it to the scene.
  47297. * @param name The name of the layer
  47298. * @param scene The scene to use the layer in
  47299. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47300. */
  47301. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47302. /**
  47303. * Get the effect name of the layer.
  47304. * @return The effect name
  47305. */
  47306. getEffectName(): string;
  47307. /**
  47308. * Create the merge effect. This is the shader use to blit the information back
  47309. * to the main canvas at the end of the scene rendering.
  47310. */
  47311. protected _createMergeEffect(): Effect;
  47312. /**
  47313. * Creates the render target textures and post processes used in the glow layer.
  47314. */
  47315. protected _createTextureAndPostProcesses(): void;
  47316. /**
  47317. * Checks for the readiness of the element composing the layer.
  47318. * @param subMesh the mesh to check for
  47319. * @param useInstances specify wether or not to use instances to render the mesh
  47320. * @param emissiveTexture the associated emissive texture used to generate the glow
  47321. * @return true if ready otherwise, false
  47322. */
  47323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47324. /**
  47325. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47326. */
  47327. needStencil(): boolean;
  47328. /**
  47329. * Returns true if the mesh can be rendered, otherwise false.
  47330. * @param mesh The mesh to render
  47331. * @param material The material used on the mesh
  47332. * @returns true if it can be rendered otherwise false
  47333. */
  47334. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47335. /**
  47336. * Implementation specific of rendering the generating effect on the main canvas.
  47337. * @param effect The effect used to render through
  47338. */
  47339. protected _internalRender(effect: Effect): void;
  47340. /**
  47341. * Sets the required values for both the emissive texture and and the main color.
  47342. */
  47343. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47344. /**
  47345. * Returns true if the mesh should render, otherwise false.
  47346. * @param mesh The mesh to render
  47347. * @returns true if it should render otherwise false
  47348. */
  47349. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47350. /**
  47351. * Adds specific effects defines.
  47352. * @param defines The defines to add specifics to.
  47353. */
  47354. protected _addCustomEffectDefines(defines: string[]): void;
  47355. /**
  47356. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47357. * @param mesh The mesh to exclude from the glow layer
  47358. */
  47359. addExcludedMesh(mesh: Mesh): void;
  47360. /**
  47361. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47362. * @param mesh The mesh to remove
  47363. */
  47364. removeExcludedMesh(mesh: Mesh): void;
  47365. /**
  47366. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47367. * @param mesh The mesh to include in the glow layer
  47368. */
  47369. addIncludedOnlyMesh(mesh: Mesh): void;
  47370. /**
  47371. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47372. * @param mesh The mesh to remove
  47373. */
  47374. removeIncludedOnlyMesh(mesh: Mesh): void;
  47375. /**
  47376. * Determine if a given mesh will be used in the glow layer
  47377. * @param mesh The mesh to test
  47378. * @returns true if the mesh will be highlighted by the current glow layer
  47379. */
  47380. hasMesh(mesh: AbstractMesh): boolean;
  47381. /**
  47382. * Free any resources and references associated to a mesh.
  47383. * Internal use
  47384. * @param mesh The mesh to free.
  47385. * @hidden
  47386. */
  47387. _disposeMesh(mesh: Mesh): void;
  47388. /**
  47389. * Gets the class name of the effect layer
  47390. * @returns the string with the class name of the effect layer
  47391. */
  47392. getClassName(): string;
  47393. /**
  47394. * Serializes this glow layer
  47395. * @returns a serialized glow layer object
  47396. */
  47397. serialize(): any;
  47398. /**
  47399. * Creates a Glow Layer from parsed glow layer data
  47400. * @param parsedGlowLayer defines glow layer data
  47401. * @param scene defines the current scene
  47402. * @param rootUrl defines the root URL containing the glow layer information
  47403. * @returns a parsed Glow Layer
  47404. */
  47405. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47406. }
  47407. }
  47408. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47409. /** @hidden */
  47410. export var glowBlurPostProcessPixelShader: {
  47411. name: string;
  47412. shader: string;
  47413. };
  47414. }
  47415. declare module "babylonjs/Layers/highlightLayer" {
  47416. import { Observable } from "babylonjs/Misc/observable";
  47417. import { Nullable } from "babylonjs/types";
  47418. import { Camera } from "babylonjs/Cameras/camera";
  47419. import { Scene } from "babylonjs/scene";
  47420. import { Color3, Color4 } from "babylonjs/Maths/math";
  47421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47423. import { Mesh } from "babylonjs/Meshes/mesh";
  47424. import { Effect } from "babylonjs/Materials/effect";
  47425. import { Material } from "babylonjs/Materials/material";
  47426. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47427. import "babylonjs/Shaders/glowMapMerge.fragment";
  47428. import "babylonjs/Shaders/glowMapMerge.vertex";
  47429. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47430. module "babylonjs/abstractScene" {
  47431. interface AbstractScene {
  47432. /**
  47433. * Return a the first highlight layer of the scene with a given name.
  47434. * @param name The name of the highlight layer to look for.
  47435. * @return The highlight layer if found otherwise null.
  47436. */
  47437. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47438. }
  47439. }
  47440. /**
  47441. * Highlight layer options. This helps customizing the behaviour
  47442. * of the highlight layer.
  47443. */
  47444. export interface IHighlightLayerOptions {
  47445. /**
  47446. * Multiplication factor apply to the canvas size to compute the render target size
  47447. * used to generated the glowing objects (the smaller the faster).
  47448. */
  47449. mainTextureRatio: number;
  47450. /**
  47451. * Enforces a fixed size texture to ensure resize independant blur.
  47452. */
  47453. mainTextureFixedSize?: number;
  47454. /**
  47455. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47456. * of the picture to blur (the smaller the faster).
  47457. */
  47458. blurTextureSizeRatio: number;
  47459. /**
  47460. * How big in texel of the blur texture is the vertical blur.
  47461. */
  47462. blurVerticalSize: number;
  47463. /**
  47464. * How big in texel of the blur texture is the horizontal blur.
  47465. */
  47466. blurHorizontalSize: number;
  47467. /**
  47468. * Alpha blending mode used to apply the blur. Default is combine.
  47469. */
  47470. alphaBlendingMode: number;
  47471. /**
  47472. * The camera attached to the layer.
  47473. */
  47474. camera: Nullable<Camera>;
  47475. /**
  47476. * Should we display highlight as a solid stroke?
  47477. */
  47478. isStroke?: boolean;
  47479. /**
  47480. * The rendering group to draw the layer in.
  47481. */
  47482. renderingGroupId: number;
  47483. }
  47484. /**
  47485. * The highlight layer Helps adding a glow effect around a mesh.
  47486. *
  47487. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47488. * glowy meshes to your scene.
  47489. *
  47490. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47491. */
  47492. export class HighlightLayer extends EffectLayer {
  47493. name: string;
  47494. /**
  47495. * Effect Name of the highlight layer.
  47496. */
  47497. static readonly EffectName: string;
  47498. /**
  47499. * The neutral color used during the preparation of the glow effect.
  47500. * This is black by default as the blend operation is a blend operation.
  47501. */
  47502. static NeutralColor: Color4;
  47503. /**
  47504. * Stencil value used for glowing meshes.
  47505. */
  47506. static GlowingMeshStencilReference: number;
  47507. /**
  47508. * Stencil value used for the other meshes in the scene.
  47509. */
  47510. static NormalMeshStencilReference: number;
  47511. /**
  47512. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47513. */
  47514. innerGlow: boolean;
  47515. /**
  47516. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47517. */
  47518. outerGlow: boolean;
  47519. /**
  47520. * Specifies the horizontal size of the blur.
  47521. */
  47522. /**
  47523. * Gets the horizontal size of the blur.
  47524. */
  47525. blurHorizontalSize: number;
  47526. /**
  47527. * Specifies the vertical size of the blur.
  47528. */
  47529. /**
  47530. * Gets the vertical size of the blur.
  47531. */
  47532. blurVerticalSize: number;
  47533. /**
  47534. * An event triggered when the highlight layer is being blurred.
  47535. */
  47536. onBeforeBlurObservable: Observable<HighlightLayer>;
  47537. /**
  47538. * An event triggered when the highlight layer has been blurred.
  47539. */
  47540. onAfterBlurObservable: Observable<HighlightLayer>;
  47541. private _instanceGlowingMeshStencilReference;
  47542. private _options;
  47543. private _downSamplePostprocess;
  47544. private _horizontalBlurPostprocess;
  47545. private _verticalBlurPostprocess;
  47546. private _blurTexture;
  47547. private _meshes;
  47548. private _excludedMeshes;
  47549. /**
  47550. * Instantiates a new highlight Layer and references it to the scene..
  47551. * @param name The name of the layer
  47552. * @param scene The scene to use the layer in
  47553. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47554. */
  47555. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47556. /**
  47557. * Get the effect name of the layer.
  47558. * @return The effect name
  47559. */
  47560. getEffectName(): string;
  47561. /**
  47562. * Create the merge effect. This is the shader use to blit the information back
  47563. * to the main canvas at the end of the scene rendering.
  47564. */
  47565. protected _createMergeEffect(): Effect;
  47566. /**
  47567. * Creates the render target textures and post processes used in the highlight layer.
  47568. */
  47569. protected _createTextureAndPostProcesses(): void;
  47570. /**
  47571. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47572. */
  47573. needStencil(): boolean;
  47574. /**
  47575. * Checks for the readiness of the element composing the layer.
  47576. * @param subMesh the mesh to check for
  47577. * @param useInstances specify wether or not to use instances to render the mesh
  47578. * @param emissiveTexture the associated emissive texture used to generate the glow
  47579. * @return true if ready otherwise, false
  47580. */
  47581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47582. /**
  47583. * Implementation specific of rendering the generating effect on the main canvas.
  47584. * @param effect The effect used to render through
  47585. */
  47586. protected _internalRender(effect: Effect): void;
  47587. /**
  47588. * Returns true if the layer contains information to display, otherwise false.
  47589. */
  47590. shouldRender(): boolean;
  47591. /**
  47592. * Returns true if the mesh should render, otherwise false.
  47593. * @param mesh The mesh to render
  47594. * @returns true if it should render otherwise false
  47595. */
  47596. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47597. /**
  47598. * Sets the required values for both the emissive texture and and the main color.
  47599. */
  47600. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47601. /**
  47602. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47603. * @param mesh The mesh to exclude from the highlight layer
  47604. */
  47605. addExcludedMesh(mesh: Mesh): void;
  47606. /**
  47607. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47608. * @param mesh The mesh to highlight
  47609. */
  47610. removeExcludedMesh(mesh: Mesh): void;
  47611. /**
  47612. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47613. * @param mesh mesh to test
  47614. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47615. */
  47616. hasMesh(mesh: AbstractMesh): boolean;
  47617. /**
  47618. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47619. * @param mesh The mesh to highlight
  47620. * @param color The color of the highlight
  47621. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47622. */
  47623. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47624. /**
  47625. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47626. * @param mesh The mesh to highlight
  47627. */
  47628. removeMesh(mesh: Mesh): void;
  47629. /**
  47630. * Force the stencil to the normal expected value for none glowing parts
  47631. */
  47632. private _defaultStencilReference;
  47633. /**
  47634. * Free any resources and references associated to a mesh.
  47635. * Internal use
  47636. * @param mesh The mesh to free.
  47637. * @hidden
  47638. */
  47639. _disposeMesh(mesh: Mesh): void;
  47640. /**
  47641. * Dispose the highlight layer and free resources.
  47642. */
  47643. dispose(): void;
  47644. /**
  47645. * Gets the class name of the effect layer
  47646. * @returns the string with the class name of the effect layer
  47647. */
  47648. getClassName(): string;
  47649. /**
  47650. * Serializes this Highlight layer
  47651. * @returns a serialized Highlight layer object
  47652. */
  47653. serialize(): any;
  47654. /**
  47655. * Creates a Highlight layer from parsed Highlight layer data
  47656. * @param parsedHightlightLayer defines the Highlight layer data
  47657. * @param scene defines the current scene
  47658. * @param rootUrl defines the root URL containing the Highlight layer information
  47659. * @returns a parsed Highlight layer
  47660. */
  47661. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47662. }
  47663. }
  47664. declare module "babylonjs/Layers/index" {
  47665. export * from "babylonjs/Layers/effectLayer";
  47666. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47667. export * from "babylonjs/Layers/glowLayer";
  47668. export * from "babylonjs/Layers/highlightLayer";
  47669. export * from "babylonjs/Layers/layer";
  47670. export * from "babylonjs/Layers/layerSceneComponent";
  47671. }
  47672. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47673. /** @hidden */
  47674. export var lensFlarePixelShader: {
  47675. name: string;
  47676. shader: string;
  47677. };
  47678. }
  47679. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47680. /** @hidden */
  47681. export var lensFlareVertexShader: {
  47682. name: string;
  47683. shader: string;
  47684. };
  47685. }
  47686. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47687. import { Scene } from "babylonjs/scene";
  47688. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47690. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47691. import "babylonjs/Shaders/lensFlare.fragment";
  47692. import "babylonjs/Shaders/lensFlare.vertex";
  47693. /**
  47694. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47695. * It is usually composed of several `lensFlare`.
  47696. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47697. */
  47698. export class LensFlareSystem {
  47699. /**
  47700. * Define the name of the lens flare system
  47701. */
  47702. name: string;
  47703. /**
  47704. * List of lens flares used in this system.
  47705. */
  47706. lensFlares: LensFlare[];
  47707. /**
  47708. * Define a limit from the border the lens flare can be visible.
  47709. */
  47710. borderLimit: number;
  47711. /**
  47712. * Define a viewport border we do not want to see the lens flare in.
  47713. */
  47714. viewportBorder: number;
  47715. /**
  47716. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47717. */
  47718. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47719. /**
  47720. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47721. */
  47722. layerMask: number;
  47723. /**
  47724. * Define the id of the lens flare system in the scene.
  47725. * (equal to name by default)
  47726. */
  47727. id: string;
  47728. private _scene;
  47729. private _emitter;
  47730. private _vertexBuffers;
  47731. private _indexBuffer;
  47732. private _effect;
  47733. private _positionX;
  47734. private _positionY;
  47735. private _isEnabled;
  47736. /** @hidden */
  47737. static _SceneComponentInitialization: (scene: Scene) => void;
  47738. /**
  47739. * Instantiates a lens flare system.
  47740. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47741. * It is usually composed of several `lensFlare`.
  47742. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47743. * @param name Define the name of the lens flare system in the scene
  47744. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47745. * @param scene Define the scene the lens flare system belongs to
  47746. */
  47747. constructor(
  47748. /**
  47749. * Define the name of the lens flare system
  47750. */
  47751. name: string, emitter: any, scene: Scene);
  47752. /**
  47753. * Define if the lens flare system is enabled.
  47754. */
  47755. isEnabled: boolean;
  47756. /**
  47757. * Get the scene the effects belongs to.
  47758. * @returns the scene holding the lens flare system
  47759. */
  47760. getScene(): Scene;
  47761. /**
  47762. * Get the emitter of the lens flare system.
  47763. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47764. * @returns the emitter of the lens flare system
  47765. */
  47766. getEmitter(): any;
  47767. /**
  47768. * Set the emitter of the lens flare system.
  47769. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47770. * @param newEmitter Define the new emitter of the system
  47771. */
  47772. setEmitter(newEmitter: any): void;
  47773. /**
  47774. * Get the lens flare system emitter position.
  47775. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47776. * @returns the position
  47777. */
  47778. getEmitterPosition(): Vector3;
  47779. /**
  47780. * @hidden
  47781. */
  47782. computeEffectivePosition(globalViewport: Viewport): boolean;
  47783. /** @hidden */
  47784. _isVisible(): boolean;
  47785. /**
  47786. * @hidden
  47787. */
  47788. render(): boolean;
  47789. /**
  47790. * Dispose and release the lens flare with its associated resources.
  47791. */
  47792. dispose(): void;
  47793. /**
  47794. * Parse a lens flare system from a JSON repressentation
  47795. * @param parsedLensFlareSystem Define the JSON to parse
  47796. * @param scene Define the scene the parsed system should be instantiated in
  47797. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47798. * @returns the parsed system
  47799. */
  47800. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47801. /**
  47802. * Serialize the current Lens Flare System into a JSON representation.
  47803. * @returns the serialized JSON
  47804. */
  47805. serialize(): any;
  47806. }
  47807. }
  47808. declare module "babylonjs/LensFlares/lensFlare" {
  47809. import { Nullable } from "babylonjs/types";
  47810. import { Color3 } from "babylonjs/Maths/math";
  47811. import { Texture } from "babylonjs/Materials/Textures/texture";
  47812. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47813. /**
  47814. * This represents one of the lens effect in a `lensFlareSystem`.
  47815. * It controls one of the indiviual texture used in the effect.
  47816. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47817. */
  47818. export class LensFlare {
  47819. /**
  47820. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47821. */
  47822. size: number;
  47823. /**
  47824. * 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.
  47825. */
  47826. position: number;
  47827. /**
  47828. * Define the lens color.
  47829. */
  47830. color: Color3;
  47831. /**
  47832. * Define the lens texture.
  47833. */
  47834. texture: Nullable<Texture>;
  47835. /**
  47836. * Define the alpha mode to render this particular lens.
  47837. */
  47838. alphaMode: number;
  47839. private _system;
  47840. /**
  47841. * Creates a new Lens Flare.
  47842. * This represents one of the lens effect in a `lensFlareSystem`.
  47843. * It controls one of the indiviual texture used in the effect.
  47844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47845. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47846. * @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.
  47847. * @param color Define the lens color
  47848. * @param imgUrl Define the lens texture url
  47849. * @param system Define the `lensFlareSystem` this flare is part of
  47850. * @returns The newly created Lens Flare
  47851. */
  47852. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47853. /**
  47854. * Instantiates a new Lens Flare.
  47855. * This represents one of the lens effect in a `lensFlareSystem`.
  47856. * It controls one of the indiviual texture used in the effect.
  47857. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47858. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47859. * @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.
  47860. * @param color Define the lens color
  47861. * @param imgUrl Define the lens texture url
  47862. * @param system Define the `lensFlareSystem` this flare is part of
  47863. */
  47864. constructor(
  47865. /**
  47866. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47867. */
  47868. size: number,
  47869. /**
  47870. * 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.
  47871. */
  47872. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47873. /**
  47874. * Dispose and release the lens flare with its associated resources.
  47875. */
  47876. dispose(): void;
  47877. }
  47878. }
  47879. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47880. import { Nullable } from "babylonjs/types";
  47881. import { Scene } from "babylonjs/scene";
  47882. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47883. import { AbstractScene } from "babylonjs/abstractScene";
  47884. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47885. module "babylonjs/abstractScene" {
  47886. interface AbstractScene {
  47887. /**
  47888. * The list of lens flare system added to the scene
  47889. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47890. */
  47891. lensFlareSystems: Array<LensFlareSystem>;
  47892. /**
  47893. * Removes the given lens flare system from this scene.
  47894. * @param toRemove The lens flare system to remove
  47895. * @returns The index of the removed lens flare system
  47896. */
  47897. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47898. /**
  47899. * Adds the given lens flare system to this scene
  47900. * @param newLensFlareSystem The lens flare system to add
  47901. */
  47902. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47903. /**
  47904. * Gets a lens flare system using its name
  47905. * @param name defines the name to look for
  47906. * @returns the lens flare system or null if not found
  47907. */
  47908. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47909. /**
  47910. * Gets a lens flare system using its id
  47911. * @param id defines the id to look for
  47912. * @returns the lens flare system or null if not found
  47913. */
  47914. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47915. }
  47916. }
  47917. /**
  47918. * Defines the lens flare scene component responsible to manage any lens flares
  47919. * in a given scene.
  47920. */
  47921. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47922. /**
  47923. * The component name helpfull to identify the component in the list of scene components.
  47924. */
  47925. readonly name: string;
  47926. /**
  47927. * The scene the component belongs to.
  47928. */
  47929. scene: Scene;
  47930. /**
  47931. * Creates a new instance of the component for the given scene
  47932. * @param scene Defines the scene to register the component in
  47933. */
  47934. constructor(scene: Scene);
  47935. /**
  47936. * Registers the component in a given scene
  47937. */
  47938. register(): void;
  47939. /**
  47940. * Rebuilds the elements related to this component in case of
  47941. * context lost for instance.
  47942. */
  47943. rebuild(): void;
  47944. /**
  47945. * Adds all the element from the container to the scene
  47946. * @param container the container holding the elements
  47947. */
  47948. addFromContainer(container: AbstractScene): void;
  47949. /**
  47950. * Removes all the elements in the container from the scene
  47951. * @param container contains the elements to remove
  47952. */
  47953. removeFromContainer(container: AbstractScene): void;
  47954. /**
  47955. * Serializes the component data to the specified json object
  47956. * @param serializationObject The object to serialize to
  47957. */
  47958. serialize(serializationObject: any): void;
  47959. /**
  47960. * Disposes the component and the associated ressources.
  47961. */
  47962. dispose(): void;
  47963. private _draw;
  47964. }
  47965. }
  47966. declare module "babylonjs/LensFlares/index" {
  47967. export * from "babylonjs/LensFlares/lensFlare";
  47968. export * from "babylonjs/LensFlares/lensFlareSystem";
  47969. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47970. }
  47971. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47972. import { Scene } from "babylonjs/scene";
  47973. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47974. import { AbstractScene } from "babylonjs/abstractScene";
  47975. /**
  47976. * Defines the shadow generator component responsible to manage any shadow generators
  47977. * in a given scene.
  47978. */
  47979. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47980. /**
  47981. * The component name helpfull to identify the component in the list of scene components.
  47982. */
  47983. readonly name: string;
  47984. /**
  47985. * The scene the component belongs to.
  47986. */
  47987. scene: Scene;
  47988. /**
  47989. * Creates a new instance of the component for the given scene
  47990. * @param scene Defines the scene to register the component in
  47991. */
  47992. constructor(scene: Scene);
  47993. /**
  47994. * Registers the component in a given scene
  47995. */
  47996. register(): void;
  47997. /**
  47998. * Rebuilds the elements related to this component in case of
  47999. * context lost for instance.
  48000. */
  48001. rebuild(): void;
  48002. /**
  48003. * Serializes the component data to the specified json object
  48004. * @param serializationObject The object to serialize to
  48005. */
  48006. serialize(serializationObject: any): void;
  48007. /**
  48008. * Adds all the element from the container to the scene
  48009. * @param container the container holding the elements
  48010. */
  48011. addFromContainer(container: AbstractScene): void;
  48012. /**
  48013. * Removes all the elements in the container from the scene
  48014. * @param container contains the elements to remove
  48015. */
  48016. removeFromContainer(container: AbstractScene): void;
  48017. /**
  48018. * Rebuilds the elements related to this component in case of
  48019. * context lost for instance.
  48020. */
  48021. dispose(): void;
  48022. private _gatherRenderTargets;
  48023. }
  48024. }
  48025. declare module "babylonjs/Lights/Shadows/index" {
  48026. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48027. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48028. }
  48029. declare module "babylonjs/Lights/directionalLight" {
  48030. import { Camera } from "babylonjs/Cameras/camera";
  48031. import { Scene } from "babylonjs/scene";
  48032. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48034. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48035. import { Effect } from "babylonjs/Materials/effect";
  48036. /**
  48037. * A directional light is defined by a direction (what a surprise!).
  48038. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48039. * 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.
  48040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48041. */
  48042. export class DirectionalLight extends ShadowLight {
  48043. private _shadowFrustumSize;
  48044. /**
  48045. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48046. */
  48047. /**
  48048. * Specifies a fix frustum size for the shadow generation.
  48049. */
  48050. shadowFrustumSize: number;
  48051. private _shadowOrthoScale;
  48052. /**
  48053. * Gets the shadow projection scale against the optimal computed one.
  48054. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48055. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48056. */
  48057. /**
  48058. * Sets the shadow projection scale against the optimal computed one.
  48059. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48060. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48061. */
  48062. shadowOrthoScale: number;
  48063. /**
  48064. * Automatically compute the projection matrix to best fit (including all the casters)
  48065. * on each frame.
  48066. */
  48067. autoUpdateExtends: boolean;
  48068. private _orthoLeft;
  48069. private _orthoRight;
  48070. private _orthoTop;
  48071. private _orthoBottom;
  48072. /**
  48073. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48074. * The directional light is emitted from everywhere in the given direction.
  48075. * It can cast shadows.
  48076. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48077. * @param name The friendly name of the light
  48078. * @param direction The direction of the light
  48079. * @param scene The scene the light belongs to
  48080. */
  48081. constructor(name: string, direction: Vector3, scene: Scene);
  48082. /**
  48083. * Returns the string "DirectionalLight".
  48084. * @return The class name
  48085. */
  48086. getClassName(): string;
  48087. /**
  48088. * Returns the integer 1.
  48089. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48090. */
  48091. getTypeID(): number;
  48092. /**
  48093. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48094. * Returns the DirectionalLight Shadow projection matrix.
  48095. */
  48096. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48097. /**
  48098. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48099. * Returns the DirectionalLight Shadow projection matrix.
  48100. */
  48101. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48102. /**
  48103. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48104. * Returns the DirectionalLight Shadow projection matrix.
  48105. */
  48106. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48107. protected _buildUniformLayout(): void;
  48108. /**
  48109. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48110. * @param effect The effect to update
  48111. * @param lightIndex The index of the light in the effect to update
  48112. * @returns The directional light
  48113. */
  48114. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48115. /**
  48116. * Gets the minZ used for shadow according to both the scene and the light.
  48117. *
  48118. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48119. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48120. * @param activeCamera The camera we are returning the min for
  48121. * @returns the depth min z
  48122. */
  48123. getDepthMinZ(activeCamera: Camera): number;
  48124. /**
  48125. * Gets the maxZ used for shadow according to both the scene and the light.
  48126. *
  48127. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48128. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48129. * @param activeCamera The camera we are returning the max for
  48130. * @returns the depth max z
  48131. */
  48132. getDepthMaxZ(activeCamera: Camera): number;
  48133. /**
  48134. * Prepares the list of defines specific to the light type.
  48135. * @param defines the list of defines
  48136. * @param lightIndex defines the index of the light for the effect
  48137. */
  48138. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48139. }
  48140. }
  48141. declare module "babylonjs/Lights/pointLight" {
  48142. import { Scene } from "babylonjs/scene";
  48143. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48145. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48146. import { Effect } from "babylonjs/Materials/effect";
  48147. /**
  48148. * A point light is a light defined by an unique point in world space.
  48149. * The light is emitted in every direction from this point.
  48150. * A good example of a point light is a standard light bulb.
  48151. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48152. */
  48153. export class PointLight extends ShadowLight {
  48154. private _shadowAngle;
  48155. /**
  48156. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48157. * This specifies what angle the shadow will use to be created.
  48158. *
  48159. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48160. */
  48161. /**
  48162. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48163. * This specifies what angle the shadow will use to be created.
  48164. *
  48165. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48166. */
  48167. shadowAngle: number;
  48168. /**
  48169. * Gets the direction if it has been set.
  48170. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48171. */
  48172. /**
  48173. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48174. */
  48175. direction: Vector3;
  48176. /**
  48177. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48178. * A PointLight emits the light in every direction.
  48179. * It can cast shadows.
  48180. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48181. * ```javascript
  48182. * var pointLight = new PointLight("pl", camera.position, scene);
  48183. * ```
  48184. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48185. * @param name The light friendly name
  48186. * @param position The position of the point light in the scene
  48187. * @param scene The scene the lights belongs to
  48188. */
  48189. constructor(name: string, position: Vector3, scene: Scene);
  48190. /**
  48191. * Returns the string "PointLight"
  48192. * @returns the class name
  48193. */
  48194. getClassName(): string;
  48195. /**
  48196. * Returns the integer 0.
  48197. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48198. */
  48199. getTypeID(): number;
  48200. /**
  48201. * Specifies wether or not the shadowmap should be a cube texture.
  48202. * @returns true if the shadowmap needs to be a cube texture.
  48203. */
  48204. needCube(): boolean;
  48205. /**
  48206. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48207. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48208. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48209. */
  48210. getShadowDirection(faceIndex?: number): Vector3;
  48211. /**
  48212. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48213. * - fov = PI / 2
  48214. * - aspect ratio : 1.0
  48215. * - z-near and far equal to the active camera minZ and maxZ.
  48216. * Returns the PointLight.
  48217. */
  48218. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48219. protected _buildUniformLayout(): void;
  48220. /**
  48221. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48222. * @param effect The effect to update
  48223. * @param lightIndex The index of the light in the effect to update
  48224. * @returns The point light
  48225. */
  48226. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48227. /**
  48228. * Prepares the list of defines specific to the light type.
  48229. * @param defines the list of defines
  48230. * @param lightIndex defines the index of the light for the effect
  48231. */
  48232. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48233. }
  48234. }
  48235. declare module "babylonjs/Lights/spotLight" {
  48236. import { Nullable } from "babylonjs/types";
  48237. import { Scene } from "babylonjs/scene";
  48238. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48240. import { Effect } from "babylonjs/Materials/effect";
  48241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48242. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48243. /**
  48244. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48245. * These values define a cone of light starting from the position, emitting toward the direction.
  48246. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48247. * and the exponent defines the speed of the decay of the light with distance (reach).
  48248. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48249. */
  48250. export class SpotLight extends ShadowLight {
  48251. private _angle;
  48252. private _innerAngle;
  48253. private _cosHalfAngle;
  48254. private _lightAngleScale;
  48255. private _lightAngleOffset;
  48256. /**
  48257. * Gets the cone angle of the spot light in Radians.
  48258. */
  48259. /**
  48260. * Sets the cone angle of the spot light in Radians.
  48261. */
  48262. angle: number;
  48263. /**
  48264. * Only used in gltf falloff mode, this defines the angle where
  48265. * the directional falloff will start before cutting at angle which could be seen
  48266. * as outer angle.
  48267. */
  48268. /**
  48269. * Only used in gltf falloff mode, this defines the angle where
  48270. * the directional falloff will start before cutting at angle which could be seen
  48271. * as outer angle.
  48272. */
  48273. innerAngle: number;
  48274. private _shadowAngleScale;
  48275. /**
  48276. * Allows scaling the angle of the light for shadow generation only.
  48277. */
  48278. /**
  48279. * Allows scaling the angle of the light for shadow generation only.
  48280. */
  48281. shadowAngleScale: number;
  48282. /**
  48283. * The light decay speed with the distance from the emission spot.
  48284. */
  48285. exponent: number;
  48286. private _projectionTextureMatrix;
  48287. /**
  48288. * Allows reading the projecton texture
  48289. */
  48290. readonly projectionTextureMatrix: Matrix;
  48291. protected _projectionTextureLightNear: number;
  48292. /**
  48293. * Gets the near clip of the Spotlight for texture projection.
  48294. */
  48295. /**
  48296. * Sets the near clip of the Spotlight for texture projection.
  48297. */
  48298. projectionTextureLightNear: number;
  48299. protected _projectionTextureLightFar: number;
  48300. /**
  48301. * Gets the far clip of the Spotlight for texture projection.
  48302. */
  48303. /**
  48304. * Sets the far clip of the Spotlight for texture projection.
  48305. */
  48306. projectionTextureLightFar: number;
  48307. protected _projectionTextureUpDirection: Vector3;
  48308. /**
  48309. * Gets the Up vector of the Spotlight for texture projection.
  48310. */
  48311. /**
  48312. * Sets the Up vector of the Spotlight for texture projection.
  48313. */
  48314. projectionTextureUpDirection: Vector3;
  48315. private _projectionTexture;
  48316. /**
  48317. * Gets the projection texture of the light.
  48318. */
  48319. /**
  48320. * Sets the projection texture of the light.
  48321. */
  48322. projectionTexture: Nullable<BaseTexture>;
  48323. private _projectionTextureViewLightDirty;
  48324. private _projectionTextureProjectionLightDirty;
  48325. private _projectionTextureDirty;
  48326. private _projectionTextureViewTargetVector;
  48327. private _projectionTextureViewLightMatrix;
  48328. private _projectionTextureProjectionLightMatrix;
  48329. private _projectionTextureScalingMatrix;
  48330. /**
  48331. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48332. * It can cast shadows.
  48333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48334. * @param name The light friendly name
  48335. * @param position The position of the spot light in the scene
  48336. * @param direction The direction of the light in the scene
  48337. * @param angle The cone angle of the light in Radians
  48338. * @param exponent The light decay speed with the distance from the emission spot
  48339. * @param scene The scene the lights belongs to
  48340. */
  48341. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48342. /**
  48343. * Returns the string "SpotLight".
  48344. * @returns the class name
  48345. */
  48346. getClassName(): string;
  48347. /**
  48348. * Returns the integer 2.
  48349. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48350. */
  48351. getTypeID(): number;
  48352. /**
  48353. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48354. */
  48355. protected _setDirection(value: Vector3): void;
  48356. /**
  48357. * Overrides the position setter to recompute the projection texture view light Matrix.
  48358. */
  48359. protected _setPosition(value: Vector3): void;
  48360. /**
  48361. * 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.
  48362. * Returns the SpotLight.
  48363. */
  48364. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48365. protected _computeProjectionTextureViewLightMatrix(): void;
  48366. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48367. /**
  48368. * Main function for light texture projection matrix computing.
  48369. */
  48370. protected _computeProjectionTextureMatrix(): void;
  48371. protected _buildUniformLayout(): void;
  48372. private _computeAngleValues;
  48373. /**
  48374. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48375. * @param effect The effect to update
  48376. * @param lightIndex The index of the light in the effect to update
  48377. * @returns The spot light
  48378. */
  48379. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48380. /**
  48381. * Disposes the light and the associated resources.
  48382. */
  48383. dispose(): void;
  48384. /**
  48385. * Prepares the list of defines specific to the light type.
  48386. * @param defines the list of defines
  48387. * @param lightIndex defines the index of the light for the effect
  48388. */
  48389. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48390. }
  48391. }
  48392. declare module "babylonjs/Lights/index" {
  48393. export * from "babylonjs/Lights/light";
  48394. export * from "babylonjs/Lights/shadowLight";
  48395. export * from "babylonjs/Lights/Shadows/index";
  48396. export * from "babylonjs/Lights/directionalLight";
  48397. export * from "babylonjs/Lights/hemisphericLight";
  48398. export * from "babylonjs/Lights/pointLight";
  48399. export * from "babylonjs/Lights/spotLight";
  48400. }
  48401. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48402. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48403. /**
  48404. * Header information of HDR texture files.
  48405. */
  48406. export interface HDRInfo {
  48407. /**
  48408. * The height of the texture in pixels.
  48409. */
  48410. height: number;
  48411. /**
  48412. * The width of the texture in pixels.
  48413. */
  48414. width: number;
  48415. /**
  48416. * The index of the beginning of the data in the binary file.
  48417. */
  48418. dataPosition: number;
  48419. }
  48420. /**
  48421. * This groups tools to convert HDR texture to native colors array.
  48422. */
  48423. export class HDRTools {
  48424. private static Ldexp;
  48425. private static Rgbe2float;
  48426. private static readStringLine;
  48427. /**
  48428. * Reads header information from an RGBE texture stored in a native array.
  48429. * More information on this format are available here:
  48430. * https://en.wikipedia.org/wiki/RGBE_image_format
  48431. *
  48432. * @param uint8array The binary file stored in native array.
  48433. * @return The header information.
  48434. */
  48435. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48436. /**
  48437. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48438. * This RGBE texture needs to store the information as a panorama.
  48439. *
  48440. * More information on this format are available here:
  48441. * https://en.wikipedia.org/wiki/RGBE_image_format
  48442. *
  48443. * @param buffer The binary file stored in an array buffer.
  48444. * @param size The expected size of the extracted cubemap.
  48445. * @return The Cube Map information.
  48446. */
  48447. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48448. /**
  48449. * Returns the pixels data extracted from an RGBE texture.
  48450. * This pixels will be stored left to right up to down in the R G B order in one array.
  48451. *
  48452. * More information on this format are available here:
  48453. * https://en.wikipedia.org/wiki/RGBE_image_format
  48454. *
  48455. * @param uint8array The binary file stored in an array buffer.
  48456. * @param hdrInfo The header information of the file.
  48457. * @return The pixels data in RGB right to left up to down order.
  48458. */
  48459. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48460. private static RGBE_ReadPixels_RLE;
  48461. }
  48462. }
  48463. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48464. import { Nullable } from "babylonjs/types";
  48465. import { Scene } from "babylonjs/scene";
  48466. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48468. /**
  48469. * This represents a texture coming from an HDR input.
  48470. *
  48471. * The only supported format is currently panorama picture stored in RGBE format.
  48472. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48473. */
  48474. export class HDRCubeTexture extends BaseTexture {
  48475. private static _facesMapping;
  48476. private _generateHarmonics;
  48477. private _noMipmap;
  48478. private _textureMatrix;
  48479. private _size;
  48480. private _onLoad;
  48481. private _onError;
  48482. /**
  48483. * The texture URL.
  48484. */
  48485. url: string;
  48486. /**
  48487. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48488. */
  48489. coordinatesMode: number;
  48490. protected _isBlocking: boolean;
  48491. /**
  48492. * Sets wether or not the texture is blocking during loading.
  48493. */
  48494. /**
  48495. * Gets wether or not the texture is blocking during loading.
  48496. */
  48497. isBlocking: boolean;
  48498. protected _rotationY: number;
  48499. /**
  48500. * Sets texture matrix rotation angle around Y axis in radians.
  48501. */
  48502. /**
  48503. * Gets texture matrix rotation angle around Y axis radians.
  48504. */
  48505. rotationY: number;
  48506. /**
  48507. * Gets or sets the center of the bounding box associated with the cube texture
  48508. * It must define where the camera used to render the texture was set
  48509. */
  48510. boundingBoxPosition: Vector3;
  48511. private _boundingBoxSize;
  48512. /**
  48513. * Gets or sets the size of the bounding box associated with the cube texture
  48514. * When defined, the cubemap will switch to local mode
  48515. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48516. * @example https://www.babylonjs-playground.com/#RNASML
  48517. */
  48518. boundingBoxSize: Vector3;
  48519. /**
  48520. * Instantiates an HDRTexture from the following parameters.
  48521. *
  48522. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48523. * @param scene The scene the texture will be used in
  48524. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48525. * @param noMipmap Forces to not generate the mipmap if true
  48526. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48527. * @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)
  48528. * @param reserved Reserved flag for internal use.
  48529. */
  48530. 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>);
  48531. /**
  48532. * Get the current class name of the texture useful for serialization or dynamic coding.
  48533. * @returns "HDRCubeTexture"
  48534. */
  48535. getClassName(): string;
  48536. /**
  48537. * Occurs when the file is raw .hdr file.
  48538. */
  48539. private loadTexture;
  48540. clone(): HDRCubeTexture;
  48541. delayLoad(): void;
  48542. /**
  48543. * Get the texture reflection matrix used to rotate/transform the reflection.
  48544. * @returns the reflection matrix
  48545. */
  48546. getReflectionTextureMatrix(): Matrix;
  48547. /**
  48548. * Set the texture reflection matrix used to rotate/transform the reflection.
  48549. * @param value Define the reflection matrix to set
  48550. */
  48551. setReflectionTextureMatrix(value: Matrix): void;
  48552. /**
  48553. * Parses a JSON representation of an HDR Texture in order to create the texture
  48554. * @param parsedTexture Define the JSON representation
  48555. * @param scene Define the scene the texture should be created in
  48556. * @param rootUrl Define the root url in case we need to load relative dependencies
  48557. * @returns the newly created texture after parsing
  48558. */
  48559. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48560. serialize(): any;
  48561. }
  48562. }
  48563. declare module "babylonjs/Physics/physicsEngine" {
  48564. import { Nullable } from "babylonjs/types";
  48565. import { Vector3 } from "babylonjs/Maths/math";
  48566. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48567. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48568. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48569. /**
  48570. * Class used to control physics engine
  48571. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48572. */
  48573. export class PhysicsEngine implements IPhysicsEngine {
  48574. private _physicsPlugin;
  48575. /**
  48576. * Global value used to control the smallest number supported by the simulation
  48577. */
  48578. static Epsilon: number;
  48579. private _impostors;
  48580. private _joints;
  48581. /**
  48582. * Gets the gravity vector used by the simulation
  48583. */
  48584. gravity: Vector3;
  48585. /**
  48586. * Factory used to create the default physics plugin.
  48587. * @returns The default physics plugin
  48588. */
  48589. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48590. /**
  48591. * Creates a new Physics Engine
  48592. * @param gravity defines the gravity vector used by the simulation
  48593. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48594. */
  48595. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48596. /**
  48597. * Sets the gravity vector used by the simulation
  48598. * @param gravity defines the gravity vector to use
  48599. */
  48600. setGravity(gravity: Vector3): void;
  48601. /**
  48602. * Set the time step of the physics engine.
  48603. * Default is 1/60.
  48604. * To slow it down, enter 1/600 for example.
  48605. * To speed it up, 1/30
  48606. * @param newTimeStep defines the new timestep to apply to this world.
  48607. */
  48608. setTimeStep(newTimeStep?: number): void;
  48609. /**
  48610. * Get the time step of the physics engine.
  48611. * @returns the current time step
  48612. */
  48613. getTimeStep(): number;
  48614. /**
  48615. * Release all resources
  48616. */
  48617. dispose(): void;
  48618. /**
  48619. * Gets the name of the current physics plugin
  48620. * @returns the name of the plugin
  48621. */
  48622. getPhysicsPluginName(): string;
  48623. /**
  48624. * Adding a new impostor for the impostor tracking.
  48625. * This will be done by the impostor itself.
  48626. * @param impostor the impostor to add
  48627. */
  48628. addImpostor(impostor: PhysicsImpostor): void;
  48629. /**
  48630. * Remove an impostor from the engine.
  48631. * This impostor and its mesh will not longer be updated by the physics engine.
  48632. * @param impostor the impostor to remove
  48633. */
  48634. removeImpostor(impostor: PhysicsImpostor): void;
  48635. /**
  48636. * Add a joint to the physics engine
  48637. * @param mainImpostor defines the main impostor to which the joint is added.
  48638. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48639. * @param joint defines the joint that will connect both impostors.
  48640. */
  48641. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48642. /**
  48643. * Removes a joint from the simulation
  48644. * @param mainImpostor defines the impostor used with the joint
  48645. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48646. * @param joint defines the joint to remove
  48647. */
  48648. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48649. /**
  48650. * Called by the scene. No need to call it.
  48651. * @param delta defines the timespam between frames
  48652. */
  48653. _step(delta: number): void;
  48654. /**
  48655. * Gets the current plugin used to run the simulation
  48656. * @returns current plugin
  48657. */
  48658. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48659. /**
  48660. * Gets the list of physic impostors
  48661. * @returns an array of PhysicsImpostor
  48662. */
  48663. getImpostors(): Array<PhysicsImpostor>;
  48664. /**
  48665. * Gets the impostor for a physics enabled object
  48666. * @param object defines the object impersonated by the impostor
  48667. * @returns the PhysicsImpostor or null if not found
  48668. */
  48669. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48670. /**
  48671. * Gets the impostor for a physics body object
  48672. * @param body defines physics body used by the impostor
  48673. * @returns the PhysicsImpostor or null if not found
  48674. */
  48675. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48676. }
  48677. }
  48678. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48679. import { Nullable } from "babylonjs/types";
  48680. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48682. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48683. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48684. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48685. /** @hidden */
  48686. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48687. private _useDeltaForWorldStep;
  48688. world: any;
  48689. name: string;
  48690. private _physicsMaterials;
  48691. private _fixedTimeStep;
  48692. BJSCANNON: any;
  48693. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48694. setGravity(gravity: Vector3): void;
  48695. setTimeStep(timeStep: number): void;
  48696. getTimeStep(): number;
  48697. executeStep(delta: number): void;
  48698. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48699. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48700. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48701. private _processChildMeshes;
  48702. removePhysicsBody(impostor: PhysicsImpostor): void;
  48703. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48704. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48705. private _addMaterial;
  48706. private _checkWithEpsilon;
  48707. private _createShape;
  48708. private _createHeightmap;
  48709. private _minus90X;
  48710. private _plus90X;
  48711. private _tmpPosition;
  48712. private _tmpDeltaPosition;
  48713. private _tmpUnityRotation;
  48714. private _updatePhysicsBodyTransformation;
  48715. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48716. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48717. isSupported(): boolean;
  48718. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48719. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48720. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48721. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48722. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48723. getBodyMass(impostor: PhysicsImpostor): number;
  48724. getBodyFriction(impostor: PhysicsImpostor): number;
  48725. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48726. getBodyRestitution(impostor: PhysicsImpostor): number;
  48727. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48728. sleepBody(impostor: PhysicsImpostor): void;
  48729. wakeUpBody(impostor: PhysicsImpostor): void;
  48730. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48731. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48732. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48733. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48734. getRadius(impostor: PhysicsImpostor): number;
  48735. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48736. dispose(): void;
  48737. private _extendNamespace;
  48738. }
  48739. }
  48740. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48741. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48742. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48743. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48745. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48746. import { Nullable } from "babylonjs/types";
  48747. /** @hidden */
  48748. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48749. world: any;
  48750. name: string;
  48751. BJSOIMO: any;
  48752. constructor(iterations?: number, oimoInjection?: any);
  48753. setGravity(gravity: Vector3): void;
  48754. setTimeStep(timeStep: number): void;
  48755. getTimeStep(): number;
  48756. private _tmpImpostorsArray;
  48757. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48758. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48759. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48760. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48761. private _tmpPositionVector;
  48762. removePhysicsBody(impostor: PhysicsImpostor): void;
  48763. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48764. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48765. isSupported(): boolean;
  48766. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48767. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48768. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48769. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48770. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48771. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48772. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48773. getBodyMass(impostor: PhysicsImpostor): number;
  48774. getBodyFriction(impostor: PhysicsImpostor): number;
  48775. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48776. getBodyRestitution(impostor: PhysicsImpostor): number;
  48777. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48778. sleepBody(impostor: PhysicsImpostor): void;
  48779. wakeUpBody(impostor: PhysicsImpostor): void;
  48780. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48781. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48783. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48784. getRadius(impostor: PhysicsImpostor): number;
  48785. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48786. dispose(): void;
  48787. }
  48788. }
  48789. declare module "babylonjs/Probes/reflectionProbe" {
  48790. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48791. import { Vector3 } from "babylonjs/Maths/math";
  48792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48793. import { Nullable } from "babylonjs/types";
  48794. import { Scene } from "babylonjs/scene";
  48795. module "babylonjs/abstractScene" {
  48796. interface AbstractScene {
  48797. /**
  48798. * The list of reflection probes added to the scene
  48799. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48800. */
  48801. reflectionProbes: Array<ReflectionProbe>;
  48802. /**
  48803. * Removes the given reflection probe from this scene.
  48804. * @param toRemove The reflection probe to remove
  48805. * @returns The index of the removed reflection probe
  48806. */
  48807. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48808. /**
  48809. * Adds the given reflection probe to this scene.
  48810. * @param newReflectionProbe The reflection probe to add
  48811. */
  48812. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48813. }
  48814. }
  48815. /**
  48816. * Class used to generate realtime reflection / refraction cube textures
  48817. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48818. */
  48819. export class ReflectionProbe {
  48820. /** defines the name of the probe */
  48821. name: string;
  48822. private _scene;
  48823. private _renderTargetTexture;
  48824. private _projectionMatrix;
  48825. private _viewMatrix;
  48826. private _target;
  48827. private _add;
  48828. private _attachedMesh;
  48829. private _invertYAxis;
  48830. /** Gets or sets probe position (center of the cube map) */
  48831. position: Vector3;
  48832. /**
  48833. * Creates a new reflection probe
  48834. * @param name defines the name of the probe
  48835. * @param size defines the texture resolution (for each face)
  48836. * @param scene defines the hosting scene
  48837. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48838. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48839. */
  48840. constructor(
  48841. /** defines the name of the probe */
  48842. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48843. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48844. samples: number;
  48845. /** Gets or sets the refresh rate to use (on every frame by default) */
  48846. refreshRate: number;
  48847. /**
  48848. * Gets the hosting scene
  48849. * @returns a Scene
  48850. */
  48851. getScene(): Scene;
  48852. /** Gets the internal CubeTexture used to render to */
  48853. readonly cubeTexture: RenderTargetTexture;
  48854. /** Gets the list of meshes to render */
  48855. readonly renderList: Nullable<AbstractMesh[]>;
  48856. /**
  48857. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48858. * @param mesh defines the mesh to attach to
  48859. */
  48860. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48861. /**
  48862. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48863. * @param renderingGroupId The rendering group id corresponding to its index
  48864. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48865. */
  48866. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48867. /**
  48868. * Clean all associated resources
  48869. */
  48870. dispose(): void;
  48871. /**
  48872. * Converts the reflection probe information to a readable string for debug purpose.
  48873. * @param fullDetails Supports for multiple levels of logging within scene loading
  48874. * @returns the human readable reflection probe info
  48875. */
  48876. toString(fullDetails?: boolean): string;
  48877. /**
  48878. * Get the class name of the relfection probe.
  48879. * @returns "ReflectionProbe"
  48880. */
  48881. getClassName(): string;
  48882. /**
  48883. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48884. * @returns The JSON representation of the texture
  48885. */
  48886. serialize(): any;
  48887. /**
  48888. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48889. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48890. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48891. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48892. * @returns The parsed reflection probe if successful
  48893. */
  48894. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48895. }
  48896. }
  48897. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48898. /** @hidden */
  48899. export var _BabylonLoaderRegistered: boolean;
  48900. }
  48901. declare module "babylonjs/Loading/Plugins/index" {
  48902. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48903. }
  48904. declare module "babylonjs/Loading/index" {
  48905. export * from "babylonjs/Loading/loadingScreen";
  48906. export * from "babylonjs/Loading/Plugins/index";
  48907. export * from "babylonjs/Loading/sceneLoader";
  48908. export * from "babylonjs/Loading/sceneLoaderFlags";
  48909. }
  48910. declare module "babylonjs/Materials/Background/index" {
  48911. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48912. }
  48913. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48914. import { Scene } from "babylonjs/scene";
  48915. import { Color3 } from "babylonjs/Maths/math";
  48916. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48918. /**
  48919. * The Physically based simple base material of BJS.
  48920. *
  48921. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48922. * It is used as the base class for both the specGloss and metalRough conventions.
  48923. */
  48924. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48925. /**
  48926. * Number of Simultaneous lights allowed on the material.
  48927. */
  48928. maxSimultaneousLights: number;
  48929. /**
  48930. * If sets to true, disables all the lights affecting the material.
  48931. */
  48932. disableLighting: boolean;
  48933. /**
  48934. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48935. */
  48936. environmentTexture: BaseTexture;
  48937. /**
  48938. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48939. */
  48940. invertNormalMapX: boolean;
  48941. /**
  48942. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48943. */
  48944. invertNormalMapY: boolean;
  48945. /**
  48946. * Normal map used in the model.
  48947. */
  48948. normalTexture: BaseTexture;
  48949. /**
  48950. * Emissivie color used to self-illuminate the model.
  48951. */
  48952. emissiveColor: Color3;
  48953. /**
  48954. * Emissivie texture used to self-illuminate the model.
  48955. */
  48956. emissiveTexture: BaseTexture;
  48957. /**
  48958. * Occlusion Channel Strenght.
  48959. */
  48960. occlusionStrength: number;
  48961. /**
  48962. * Occlusion Texture of the material (adding extra occlusion effects).
  48963. */
  48964. occlusionTexture: BaseTexture;
  48965. /**
  48966. * Defines the alpha limits in alpha test mode.
  48967. */
  48968. alphaCutOff: number;
  48969. /**
  48970. * Gets the current double sided mode.
  48971. */
  48972. /**
  48973. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48974. */
  48975. doubleSided: boolean;
  48976. /**
  48977. * Stores the pre-calculated light information of a mesh in a texture.
  48978. */
  48979. lightmapTexture: BaseTexture;
  48980. /**
  48981. * If true, the light map contains occlusion information instead of lighting info.
  48982. */
  48983. useLightmapAsShadowmap: boolean;
  48984. /**
  48985. * Instantiates a new PBRMaterial instance.
  48986. *
  48987. * @param name The material name
  48988. * @param scene The scene the material will be use in.
  48989. */
  48990. constructor(name: string, scene: Scene);
  48991. getClassName(): string;
  48992. }
  48993. }
  48994. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48995. import { Scene } from "babylonjs/scene";
  48996. import { Color3 } from "babylonjs/Maths/math";
  48997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48998. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48999. /**
  49000. * The PBR material of BJS following the metal roughness convention.
  49001. *
  49002. * This fits to the PBR convention in the GLTF definition:
  49003. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49004. */
  49005. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49006. /**
  49007. * The base color has two different interpretations depending on the value of metalness.
  49008. * When the material is a metal, the base color is the specific measured reflectance value
  49009. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49010. * of the material.
  49011. */
  49012. baseColor: Color3;
  49013. /**
  49014. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49015. * well as opacity information in the alpha channel.
  49016. */
  49017. baseTexture: BaseTexture;
  49018. /**
  49019. * Specifies the metallic scalar value of the material.
  49020. * Can also be used to scale the metalness values of the metallic texture.
  49021. */
  49022. metallic: number;
  49023. /**
  49024. * Specifies the roughness scalar value of the material.
  49025. * Can also be used to scale the roughness values of the metallic texture.
  49026. */
  49027. roughness: number;
  49028. /**
  49029. * Texture containing both the metallic value in the B channel and the
  49030. * roughness value in the G channel to keep better precision.
  49031. */
  49032. metallicRoughnessTexture: BaseTexture;
  49033. /**
  49034. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49035. *
  49036. * @param name The material name
  49037. * @param scene The scene the material will be use in.
  49038. */
  49039. constructor(name: string, scene: Scene);
  49040. /**
  49041. * Return the currrent class name of the material.
  49042. */
  49043. getClassName(): string;
  49044. /**
  49045. * Makes a duplicate of the current material.
  49046. * @param name - name to use for the new material.
  49047. */
  49048. clone(name: string): PBRMetallicRoughnessMaterial;
  49049. /**
  49050. * Serialize the material to a parsable JSON object.
  49051. */
  49052. serialize(): any;
  49053. /**
  49054. * Parses a JSON object correponding to the serialize function.
  49055. */
  49056. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49057. }
  49058. }
  49059. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49060. import { Scene } from "babylonjs/scene";
  49061. import { Color3 } from "babylonjs/Maths/math";
  49062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49063. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49064. /**
  49065. * The PBR material of BJS following the specular glossiness convention.
  49066. *
  49067. * This fits to the PBR convention in the GLTF definition:
  49068. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49069. */
  49070. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49071. /**
  49072. * Specifies the diffuse color of the material.
  49073. */
  49074. diffuseColor: Color3;
  49075. /**
  49076. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49077. * channel.
  49078. */
  49079. diffuseTexture: BaseTexture;
  49080. /**
  49081. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49082. */
  49083. specularColor: Color3;
  49084. /**
  49085. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49086. */
  49087. glossiness: number;
  49088. /**
  49089. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49090. */
  49091. specularGlossinessTexture: BaseTexture;
  49092. /**
  49093. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49094. *
  49095. * @param name The material name
  49096. * @param scene The scene the material will be use in.
  49097. */
  49098. constructor(name: string, scene: Scene);
  49099. /**
  49100. * Return the currrent class name of the material.
  49101. */
  49102. getClassName(): string;
  49103. /**
  49104. * Makes a duplicate of the current material.
  49105. * @param name - name to use for the new material.
  49106. */
  49107. clone(name: string): PBRSpecularGlossinessMaterial;
  49108. /**
  49109. * Serialize the material to a parsable JSON object.
  49110. */
  49111. serialize(): any;
  49112. /**
  49113. * Parses a JSON object correponding to the serialize function.
  49114. */
  49115. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49116. }
  49117. }
  49118. declare module "babylonjs/Materials/PBR/index" {
  49119. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49120. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49121. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49122. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49123. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49124. }
  49125. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49126. import { Nullable } from "babylonjs/types";
  49127. import { Scene } from "babylonjs/scene";
  49128. import { Matrix } from "babylonjs/Maths/math";
  49129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49130. /**
  49131. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49132. * It can help converting any input color in a desired output one. This can then be used to create effects
  49133. * from sepia, black and white to sixties or futuristic rendering...
  49134. *
  49135. * The only supported format is currently 3dl.
  49136. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49137. */
  49138. export class ColorGradingTexture extends BaseTexture {
  49139. /**
  49140. * The current texture matrix. (will always be identity in color grading texture)
  49141. */
  49142. private _textureMatrix;
  49143. /**
  49144. * The texture URL.
  49145. */
  49146. url: string;
  49147. /**
  49148. * Empty line regex stored for GC.
  49149. */
  49150. private static _noneEmptyLineRegex;
  49151. private _engine;
  49152. /**
  49153. * Instantiates a ColorGradingTexture from the following parameters.
  49154. *
  49155. * @param url The location of the color gradind data (currently only supporting 3dl)
  49156. * @param scene The scene the texture will be used in
  49157. */
  49158. constructor(url: string, scene: Scene);
  49159. /**
  49160. * Returns the texture matrix used in most of the material.
  49161. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49162. */
  49163. getTextureMatrix(): Matrix;
  49164. /**
  49165. * Occurs when the file being loaded is a .3dl LUT file.
  49166. */
  49167. private load3dlTexture;
  49168. /**
  49169. * Starts the loading process of the texture.
  49170. */
  49171. private loadTexture;
  49172. /**
  49173. * Clones the color gradind texture.
  49174. */
  49175. clone(): ColorGradingTexture;
  49176. /**
  49177. * Called during delayed load for textures.
  49178. */
  49179. delayLoad(): void;
  49180. /**
  49181. * Parses a color grading texture serialized by Babylon.
  49182. * @param parsedTexture The texture information being parsedTexture
  49183. * @param scene The scene to load the texture in
  49184. * @param rootUrl The root url of the data assets to load
  49185. * @return A color gradind texture
  49186. */
  49187. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49188. /**
  49189. * Serializes the LUT texture to json format.
  49190. */
  49191. serialize(): any;
  49192. }
  49193. }
  49194. declare module "babylonjs/Misc/tga" {
  49195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49196. /**
  49197. * Based on jsTGALoader - Javascript loader for TGA file
  49198. * By Vincent Thibault
  49199. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49200. */
  49201. export class TGATools {
  49202. private static _TYPE_INDEXED;
  49203. private static _TYPE_RGB;
  49204. private static _TYPE_GREY;
  49205. private static _TYPE_RLE_INDEXED;
  49206. private static _TYPE_RLE_RGB;
  49207. private static _TYPE_RLE_GREY;
  49208. private static _ORIGIN_MASK;
  49209. private static _ORIGIN_SHIFT;
  49210. private static _ORIGIN_BL;
  49211. private static _ORIGIN_BR;
  49212. private static _ORIGIN_UL;
  49213. private static _ORIGIN_UR;
  49214. /**
  49215. * Gets the header of a TGA file
  49216. * @param data defines the TGA data
  49217. * @returns the header
  49218. */
  49219. static GetTGAHeader(data: Uint8Array): any;
  49220. /**
  49221. * Uploads TGA content to a Babylon Texture
  49222. * @hidden
  49223. */
  49224. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49225. /** @hidden */
  49226. 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;
  49227. /** @hidden */
  49228. 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;
  49229. /** @hidden */
  49230. 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;
  49231. /** @hidden */
  49232. 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;
  49233. /** @hidden */
  49234. 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;
  49235. /** @hidden */
  49236. 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;
  49237. }
  49238. }
  49239. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49240. import { Nullable } from "babylonjs/types";
  49241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49242. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49243. /**
  49244. * Implementation of the TGA Texture Loader.
  49245. * @hidden
  49246. */
  49247. export class _TGATextureLoader implements IInternalTextureLoader {
  49248. /**
  49249. * Defines wether the loader supports cascade loading the different faces.
  49250. */
  49251. readonly supportCascades: boolean;
  49252. /**
  49253. * This returns if the loader support the current file information.
  49254. * @param extension defines the file extension of the file being loaded
  49255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49256. * @param fallback defines the fallback internal texture if any
  49257. * @param isBase64 defines whether the texture is encoded as a base64
  49258. * @param isBuffer defines whether the texture data are stored as a buffer
  49259. * @returns true if the loader can load the specified file
  49260. */
  49261. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49262. /**
  49263. * Transform the url before loading if required.
  49264. * @param rootUrl the url of the texture
  49265. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49266. * @returns the transformed texture
  49267. */
  49268. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49269. /**
  49270. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49271. * @param rootUrl the url of the texture
  49272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49273. * @returns the fallback texture
  49274. */
  49275. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49276. /**
  49277. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49278. * @param data contains the texture data
  49279. * @param texture defines the BabylonJS internal texture
  49280. * @param createPolynomials will be true if polynomials have been requested
  49281. * @param onLoad defines the callback to trigger once the texture is ready
  49282. * @param onError defines the callback to trigger in case of error
  49283. */
  49284. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49285. /**
  49286. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49287. * @param data contains the texture data
  49288. * @param texture defines the BabylonJS internal texture
  49289. * @param callback defines the method to call once ready to upload
  49290. */
  49291. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49292. }
  49293. }
  49294. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49295. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49296. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49297. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49298. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49299. }
  49300. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49301. import { Scene } from "babylonjs/scene";
  49302. import { Texture } from "babylonjs/Materials/Textures/texture";
  49303. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49304. /**
  49305. * 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.
  49306. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49307. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49308. */
  49309. export class CustomProceduralTexture extends ProceduralTexture {
  49310. private _animate;
  49311. private _time;
  49312. private _config;
  49313. private _texturePath;
  49314. /**
  49315. * Instantiates a new Custom Procedural Texture.
  49316. * 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.
  49317. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49318. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49319. * @param name Define the name of the texture
  49320. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49321. * @param size Define the size of the texture to create
  49322. * @param scene Define the scene the texture belongs to
  49323. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49324. * @param generateMipMaps Define if the texture should creates mip maps or not
  49325. */
  49326. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49327. private _loadJson;
  49328. /**
  49329. * Is the texture ready to be used ? (rendered at least once)
  49330. * @returns true if ready, otherwise, false.
  49331. */
  49332. isReady(): boolean;
  49333. /**
  49334. * Render the texture to its associated render target.
  49335. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49336. */
  49337. render(useCameraPostProcess?: boolean): void;
  49338. /**
  49339. * Update the list of dependant textures samplers in the shader.
  49340. */
  49341. updateTextures(): void;
  49342. /**
  49343. * Update the uniform values of the procedural texture in the shader.
  49344. */
  49345. updateShaderUniforms(): void;
  49346. /**
  49347. * Define if the texture animates or not.
  49348. */
  49349. animate: boolean;
  49350. }
  49351. }
  49352. declare module "babylonjs/Shaders/noise.fragment" {
  49353. /** @hidden */
  49354. export var noisePixelShader: {
  49355. name: string;
  49356. shader: string;
  49357. };
  49358. }
  49359. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49360. import { Nullable } from "babylonjs/types";
  49361. import { Scene } from "babylonjs/scene";
  49362. import { Texture } from "babylonjs/Materials/Textures/texture";
  49363. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49364. import "babylonjs/Shaders/noise.fragment";
  49365. /**
  49366. * Class used to generate noise procedural textures
  49367. */
  49368. export class NoiseProceduralTexture extends ProceduralTexture {
  49369. private _time;
  49370. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49371. brightness: number;
  49372. /** Defines the number of octaves to process */
  49373. octaves: number;
  49374. /** Defines the level of persistence (0.8 by default) */
  49375. persistence: number;
  49376. /** Gets or sets animation speed factor (default is 1) */
  49377. animationSpeedFactor: number;
  49378. /**
  49379. * Creates a new NoiseProceduralTexture
  49380. * @param name defines the name fo the texture
  49381. * @param size defines the size of the texture (default is 256)
  49382. * @param scene defines the hosting scene
  49383. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49384. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49385. */
  49386. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49387. private _updateShaderUniforms;
  49388. protected _getDefines(): string;
  49389. /** Generate the current state of the procedural texture */
  49390. render(useCameraPostProcess?: boolean): void;
  49391. /**
  49392. * Serializes this noise procedural texture
  49393. * @returns a serialized noise procedural texture object
  49394. */
  49395. serialize(): any;
  49396. /**
  49397. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49398. * @param parsedTexture defines parsed texture data
  49399. * @param scene defines the current scene
  49400. * @param rootUrl defines the root URL containing noise procedural texture information
  49401. * @returns a parsed NoiseProceduralTexture
  49402. */
  49403. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49404. }
  49405. }
  49406. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49407. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49408. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49409. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49410. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49411. }
  49412. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49413. import { Nullable } from "babylonjs/types";
  49414. import { Scene } from "babylonjs/scene";
  49415. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49416. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49417. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49418. /**
  49419. * Raw cube texture where the raw buffers are passed in
  49420. */
  49421. export class RawCubeTexture extends CubeTexture {
  49422. /**
  49423. * Creates a cube texture where the raw buffers are passed in.
  49424. * @param scene defines the scene the texture is attached to
  49425. * @param data defines the array of data to use to create each face
  49426. * @param size defines the size of the textures
  49427. * @param format defines the format of the data
  49428. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49429. * @param generateMipMaps defines if the engine should generate the mip levels
  49430. * @param invertY defines if data must be stored with Y axis inverted
  49431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49432. * @param compression defines the compression used (null by default)
  49433. */
  49434. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49435. /**
  49436. * Updates the raw cube texture.
  49437. * @param data defines the data to store
  49438. * @param format defines the data format
  49439. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49440. * @param invertY defines if data must be stored with Y axis inverted
  49441. * @param compression defines the compression used (null by default)
  49442. * @param level defines which level of the texture to update
  49443. */
  49444. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49445. /**
  49446. * Updates a raw cube texture with RGBD encoded data.
  49447. * @param data defines the array of data [mipmap][face] to use to create each face
  49448. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49449. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49450. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49451. * @returns a promsie that resolves when the operation is complete
  49452. */
  49453. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49454. /**
  49455. * Clones the raw cube texture.
  49456. * @return a new cube texture
  49457. */
  49458. clone(): CubeTexture;
  49459. /** @hidden */
  49460. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49461. }
  49462. }
  49463. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49464. import { Scene } from "babylonjs/scene";
  49465. import { Texture } from "babylonjs/Materials/Textures/texture";
  49466. /**
  49467. * Class used to store 3D textures containing user data
  49468. */
  49469. export class RawTexture3D extends Texture {
  49470. /** Gets or sets the texture format to use */
  49471. format: number;
  49472. private _engine;
  49473. /**
  49474. * Create a new RawTexture3D
  49475. * @param data defines the data of the texture
  49476. * @param width defines the width of the texture
  49477. * @param height defines the height of the texture
  49478. * @param depth defines the depth of the texture
  49479. * @param format defines the texture format to use
  49480. * @param scene defines the hosting scene
  49481. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49482. * @param invertY defines if texture must be stored with Y axis inverted
  49483. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49484. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49485. */
  49486. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49487. /** Gets or sets the texture format to use */
  49488. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49489. /**
  49490. * Update the texture with new data
  49491. * @param data defines the data to store in the texture
  49492. */
  49493. update(data: ArrayBufferView): void;
  49494. }
  49495. }
  49496. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49497. import { Scene } from "babylonjs/scene";
  49498. import { Plane } from "babylonjs/Maths/math";
  49499. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49500. /**
  49501. * Creates a refraction texture used by refraction channel of the standard material.
  49502. * It is like a mirror but to see through a material.
  49503. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49504. */
  49505. export class RefractionTexture extends RenderTargetTexture {
  49506. /**
  49507. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49508. * 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.
  49509. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49510. */
  49511. refractionPlane: Plane;
  49512. /**
  49513. * Define how deep under the surface we should see.
  49514. */
  49515. depth: number;
  49516. /**
  49517. * Creates a refraction texture used by refraction channel of the standard material.
  49518. * It is like a mirror but to see through a material.
  49519. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49520. * @param name Define the texture name
  49521. * @param size Define the size of the underlying texture
  49522. * @param scene Define the scene the refraction belongs to
  49523. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49524. */
  49525. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49526. /**
  49527. * Clone the refraction texture.
  49528. * @returns the cloned texture
  49529. */
  49530. clone(): RefractionTexture;
  49531. /**
  49532. * Serialize the texture to a JSON representation you could use in Parse later on
  49533. * @returns the serialized JSON representation
  49534. */
  49535. serialize(): any;
  49536. }
  49537. }
  49538. declare module "babylonjs/Materials/Textures/index" {
  49539. export * from "babylonjs/Materials/Textures/baseTexture";
  49540. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49541. export * from "babylonjs/Materials/Textures/cubeTexture";
  49542. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49543. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49544. export * from "babylonjs/Materials/Textures/internalTexture";
  49545. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49546. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49547. export * from "babylonjs/Materials/Textures/Loaders/index";
  49548. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49549. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49550. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49551. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49552. export * from "babylonjs/Materials/Textures/rawTexture";
  49553. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49554. export * from "babylonjs/Materials/Textures/refractionTexture";
  49555. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49556. export * from "babylonjs/Materials/Textures/texture";
  49557. export * from "babylonjs/Materials/Textures/videoTexture";
  49558. }
  49559. declare module "babylonjs/Materials/index" {
  49560. export * from "babylonjs/Materials/Background/index";
  49561. export * from "babylonjs/Materials/colorCurves";
  49562. export * from "babylonjs/Materials/effect";
  49563. export * from "babylonjs/Materials/fresnelParameters";
  49564. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49565. export * from "babylonjs/Materials/material";
  49566. export * from "babylonjs/Materials/materialDefines";
  49567. export * from "babylonjs/Materials/materialHelper";
  49568. export * from "babylonjs/Materials/multiMaterial";
  49569. export * from "babylonjs/Materials/PBR/index";
  49570. export * from "babylonjs/Materials/pushMaterial";
  49571. export * from "babylonjs/Materials/shaderMaterial";
  49572. export * from "babylonjs/Materials/standardMaterial";
  49573. export * from "babylonjs/Materials/Textures/index";
  49574. export * from "babylonjs/Materials/uniformBuffer";
  49575. export * from "babylonjs/Materials/materialFlags";
  49576. }
  49577. declare module "babylonjs/Maths/index" {
  49578. export * from "babylonjs/Maths/math.scalar";
  49579. export * from "babylonjs/Maths/math";
  49580. export * from "babylonjs/Maths/sphericalPolynomial";
  49581. }
  49582. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49583. import { IDisposable } from "babylonjs/scene";
  49584. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49585. /**
  49586. * Configuration for Draco compression
  49587. */
  49588. export interface IDracoCompressionConfiguration {
  49589. /**
  49590. * Configuration for the decoder.
  49591. */
  49592. decoder?: {
  49593. /**
  49594. * The url to the WebAssembly module.
  49595. */
  49596. wasmUrl?: string;
  49597. /**
  49598. * The url to the WebAssembly binary.
  49599. */
  49600. wasmBinaryUrl?: string;
  49601. /**
  49602. * The url to the fallback JavaScript module.
  49603. */
  49604. fallbackUrl?: string;
  49605. };
  49606. }
  49607. /**
  49608. * Draco compression (https://google.github.io/draco/)
  49609. *
  49610. * This class wraps the Draco module.
  49611. *
  49612. * **Encoder**
  49613. *
  49614. * The encoder is not currently implemented.
  49615. *
  49616. * **Decoder**
  49617. *
  49618. * 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.
  49619. *
  49620. * To update the configuration, use the following code:
  49621. * ```javascript
  49622. * DracoCompression.Configuration = {
  49623. * decoder: {
  49624. * wasmUrl: "<url to the WebAssembly library>",
  49625. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49626. * fallbackUrl: "<url to the fallback JavaScript library>",
  49627. * }
  49628. * };
  49629. * ```
  49630. *
  49631. * 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.
  49632. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49633. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49634. *
  49635. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49636. * ```javascript
  49637. * var dracoCompression = new DracoCompression();
  49638. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49639. * [VertexBuffer.PositionKind]: 0
  49640. * });
  49641. * ```
  49642. *
  49643. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49644. */
  49645. export class DracoCompression implements IDisposable {
  49646. private static _DecoderModulePromise;
  49647. /**
  49648. * The configuration. Defaults to the following urls:
  49649. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49650. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49651. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49652. */
  49653. static Configuration: IDracoCompressionConfiguration;
  49654. /**
  49655. * Returns true if the decoder is available.
  49656. */
  49657. static readonly DecoderAvailable: boolean;
  49658. /**
  49659. * Constructor
  49660. */
  49661. constructor();
  49662. /**
  49663. * Stop all async operations and release resources.
  49664. */
  49665. dispose(): void;
  49666. /**
  49667. * Decode Draco compressed mesh data to vertex data.
  49668. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49669. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49670. * @returns A promise that resolves with the decoded vertex data
  49671. */
  49672. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49673. [kind: string]: number;
  49674. }): Promise<VertexData>;
  49675. private static _GetDecoderModule;
  49676. private static _LoadScriptAsync;
  49677. private static _LoadFileAsync;
  49678. }
  49679. }
  49680. declare module "babylonjs/Meshes/Compression/index" {
  49681. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49682. }
  49683. declare module "babylonjs/Meshes/csg" {
  49684. import { Nullable } from "babylonjs/types";
  49685. import { Scene } from "babylonjs/scene";
  49686. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49687. import { Mesh } from "babylonjs/Meshes/mesh";
  49688. import { Material } from "babylonjs/Materials/material";
  49689. /**
  49690. * Class for building Constructive Solid Geometry
  49691. */
  49692. export class CSG {
  49693. private polygons;
  49694. /**
  49695. * The world matrix
  49696. */
  49697. matrix: Matrix;
  49698. /**
  49699. * Stores the position
  49700. */
  49701. position: Vector3;
  49702. /**
  49703. * Stores the rotation
  49704. */
  49705. rotation: Vector3;
  49706. /**
  49707. * Stores the rotation quaternion
  49708. */
  49709. rotationQuaternion: Nullable<Quaternion>;
  49710. /**
  49711. * Stores the scaling vector
  49712. */
  49713. scaling: Vector3;
  49714. /**
  49715. * Convert the Mesh to CSG
  49716. * @param mesh The Mesh to convert to CSG
  49717. * @returns A new CSG from the Mesh
  49718. */
  49719. static FromMesh(mesh: Mesh): CSG;
  49720. /**
  49721. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49722. * @param polygons Polygons used to construct a CSG solid
  49723. */
  49724. private static FromPolygons;
  49725. /**
  49726. * Clones, or makes a deep copy, of the CSG
  49727. * @returns A new CSG
  49728. */
  49729. clone(): CSG;
  49730. /**
  49731. * Unions this CSG with another CSG
  49732. * @param csg The CSG to union against this CSG
  49733. * @returns The unioned CSG
  49734. */
  49735. union(csg: CSG): CSG;
  49736. /**
  49737. * Unions this CSG with another CSG in place
  49738. * @param csg The CSG to union against this CSG
  49739. */
  49740. unionInPlace(csg: CSG): void;
  49741. /**
  49742. * Subtracts this CSG with another CSG
  49743. * @param csg The CSG to subtract against this CSG
  49744. * @returns A new CSG
  49745. */
  49746. subtract(csg: CSG): CSG;
  49747. /**
  49748. * Subtracts this CSG with another CSG in place
  49749. * @param csg The CSG to subtact against this CSG
  49750. */
  49751. subtractInPlace(csg: CSG): void;
  49752. /**
  49753. * Intersect this CSG with another CSG
  49754. * @param csg The CSG to intersect against this CSG
  49755. * @returns A new CSG
  49756. */
  49757. intersect(csg: CSG): CSG;
  49758. /**
  49759. * Intersects this CSG with another CSG in place
  49760. * @param csg The CSG to intersect against this CSG
  49761. */
  49762. intersectInPlace(csg: CSG): void;
  49763. /**
  49764. * Return a new CSG solid with solid and empty space switched. This solid is
  49765. * not modified.
  49766. * @returns A new CSG solid with solid and empty space switched
  49767. */
  49768. inverse(): CSG;
  49769. /**
  49770. * Inverses the CSG in place
  49771. */
  49772. inverseInPlace(): void;
  49773. /**
  49774. * This is used to keep meshes transformations so they can be restored
  49775. * when we build back a Babylon Mesh
  49776. * NB : All CSG operations are performed in world coordinates
  49777. * @param csg The CSG to copy the transform attributes from
  49778. * @returns This CSG
  49779. */
  49780. copyTransformAttributes(csg: CSG): CSG;
  49781. /**
  49782. * Build Raw mesh from CSG
  49783. * Coordinates here are in world space
  49784. * @param name The name of the mesh geometry
  49785. * @param scene The Scene
  49786. * @param keepSubMeshes Specifies if the submeshes should be kept
  49787. * @returns A new Mesh
  49788. */
  49789. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49790. /**
  49791. * Build Mesh from CSG taking material and transforms into account
  49792. * @param name The name of the Mesh
  49793. * @param material The material of the Mesh
  49794. * @param scene The Scene
  49795. * @param keepSubMeshes Specifies if submeshes should be kept
  49796. * @returns The new Mesh
  49797. */
  49798. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49799. }
  49800. }
  49801. declare module "babylonjs/Meshes/trailMesh" {
  49802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49803. import { Mesh } from "babylonjs/Meshes/mesh";
  49804. import { Scene } from "babylonjs/scene";
  49805. /**
  49806. * Class used to create a trail following a mesh
  49807. */
  49808. export class TrailMesh extends Mesh {
  49809. private _generator;
  49810. private _autoStart;
  49811. private _running;
  49812. private _diameter;
  49813. private _length;
  49814. private _sectionPolygonPointsCount;
  49815. private _sectionVectors;
  49816. private _sectionNormalVectors;
  49817. private _beforeRenderObserver;
  49818. /**
  49819. * @constructor
  49820. * @param name The value used by scene.getMeshByName() to do a lookup.
  49821. * @param generator The mesh to generate a trail.
  49822. * @param scene The scene to add this mesh to.
  49823. * @param diameter Diameter of trailing mesh. Default is 1.
  49824. * @param length Length of trailing mesh. Default is 60.
  49825. * @param autoStart Automatically start trailing mesh. Default true.
  49826. */
  49827. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49828. /**
  49829. * "TrailMesh"
  49830. * @returns "TrailMesh"
  49831. */
  49832. getClassName(): string;
  49833. private _createMesh;
  49834. /**
  49835. * Start trailing mesh.
  49836. */
  49837. start(): void;
  49838. /**
  49839. * Stop trailing mesh.
  49840. */
  49841. stop(): void;
  49842. /**
  49843. * Update trailing mesh geometry.
  49844. */
  49845. update(): void;
  49846. /**
  49847. * Returns a new TrailMesh object.
  49848. * @param name is a string, the name given to the new mesh
  49849. * @param newGenerator use new generator object for cloned trail mesh
  49850. * @returns a new mesh
  49851. */
  49852. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49853. /**
  49854. * Serializes this trail mesh
  49855. * @param serializationObject object to write serialization to
  49856. */
  49857. serialize(serializationObject: any): void;
  49858. /**
  49859. * Parses a serialized trail mesh
  49860. * @param parsedMesh the serialized mesh
  49861. * @param scene the scene to create the trail mesh in
  49862. * @returns the created trail mesh
  49863. */
  49864. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49865. }
  49866. }
  49867. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49868. import { Nullable } from "babylonjs/types";
  49869. import { Scene } from "babylonjs/scene";
  49870. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49871. import { Mesh } from "babylonjs/Meshes/mesh";
  49872. /**
  49873. * Class containing static functions to help procedurally build meshes
  49874. */
  49875. export class RibbonBuilder {
  49876. /**
  49877. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49878. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49879. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49880. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49881. * * 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
  49882. * * 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
  49883. * * 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
  49884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49887. * * The 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
  49888. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49889. * * 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
  49890. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49892. * @param name defines the name of the mesh
  49893. * @param options defines the options used to create the mesh
  49894. * @param scene defines the hosting scene
  49895. * @returns the ribbon mesh
  49896. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49898. */
  49899. static CreateRibbon(name: string, options: {
  49900. pathArray: Vector3[][];
  49901. closeArray?: boolean;
  49902. closePath?: boolean;
  49903. offset?: number;
  49904. updatable?: boolean;
  49905. sideOrientation?: number;
  49906. frontUVs?: Vector4;
  49907. backUVs?: Vector4;
  49908. instance?: Mesh;
  49909. invertUV?: boolean;
  49910. uvs?: Vector2[];
  49911. colors?: Color4[];
  49912. }, scene?: Nullable<Scene>): Mesh;
  49913. }
  49914. }
  49915. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49916. import { Vector4 } from "babylonjs/Maths/math";
  49917. import { Mesh } from "babylonjs/Meshes/mesh";
  49918. /**
  49919. * Class containing static functions to help procedurally build meshes
  49920. */
  49921. export class TorusKnotBuilder {
  49922. /**
  49923. * Creates a torus knot mesh
  49924. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49925. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49926. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49927. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49929. * * If you create a double-sided mesh, you can choose what parts of 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
  49930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49931. * @param name defines the name of the mesh
  49932. * @param options defines the options used to create the mesh
  49933. * @param scene defines the hosting scene
  49934. * @returns the torus knot mesh
  49935. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49936. */
  49937. static CreateTorusKnot(name: string, options: {
  49938. radius?: number;
  49939. tube?: number;
  49940. radialSegments?: number;
  49941. tubularSegments?: number;
  49942. p?: number;
  49943. q?: number;
  49944. updatable?: boolean;
  49945. sideOrientation?: number;
  49946. frontUVs?: Vector4;
  49947. backUVs?: Vector4;
  49948. }, scene: any): Mesh;
  49949. }
  49950. }
  49951. declare module "babylonjs/Meshes/polygonMesh" {
  49952. import { Scene } from "babylonjs/scene";
  49953. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49954. import { Mesh } from "babylonjs/Meshes/mesh";
  49955. /**
  49956. * Polygon
  49957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49958. */
  49959. export class Polygon {
  49960. /**
  49961. * Creates a rectangle
  49962. * @param xmin bottom X coord
  49963. * @param ymin bottom Y coord
  49964. * @param xmax top X coord
  49965. * @param ymax top Y coord
  49966. * @returns points that make the resulting rectation
  49967. */
  49968. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49969. /**
  49970. * Creates a circle
  49971. * @param radius radius of circle
  49972. * @param cx scale in x
  49973. * @param cy scale in y
  49974. * @param numberOfSides number of sides that make up the circle
  49975. * @returns points that make the resulting circle
  49976. */
  49977. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49978. /**
  49979. * Creates a polygon from input string
  49980. * @param input Input polygon data
  49981. * @returns the parsed points
  49982. */
  49983. static Parse(input: string): Vector2[];
  49984. /**
  49985. * Starts building a polygon from x and y coordinates
  49986. * @param x x coordinate
  49987. * @param y y coordinate
  49988. * @returns the started path2
  49989. */
  49990. static StartingAt(x: number, y: number): Path2;
  49991. }
  49992. /**
  49993. * Builds a polygon
  49994. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49995. */
  49996. export class PolygonMeshBuilder {
  49997. private _points;
  49998. private _outlinepoints;
  49999. private _holes;
  50000. private _name;
  50001. private _scene;
  50002. private _epoints;
  50003. private _eholes;
  50004. private _addToepoint;
  50005. /**
  50006. * Babylon reference to the earcut plugin.
  50007. */
  50008. bjsEarcut: any;
  50009. /**
  50010. * Creates a PolygonMeshBuilder
  50011. * @param name name of the builder
  50012. * @param contours Path of the polygon
  50013. * @param scene scene to add to
  50014. * @param earcutInjection can be used to inject your own earcut reference
  50015. */
  50016. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50017. /**
  50018. * Adds a whole within the polygon
  50019. * @param hole Array of points defining the hole
  50020. * @returns this
  50021. */
  50022. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50023. /**
  50024. * Creates the polygon
  50025. * @param updatable If the mesh should be updatable
  50026. * @param depth The depth of the mesh created
  50027. * @returns the created mesh
  50028. */
  50029. build(updatable?: boolean, depth?: number): Mesh;
  50030. /**
  50031. * Adds a side to the polygon
  50032. * @param positions points that make the polygon
  50033. * @param normals normals of the polygon
  50034. * @param uvs uvs of the polygon
  50035. * @param indices indices of the polygon
  50036. * @param bounds bounds of the polygon
  50037. * @param points points of the polygon
  50038. * @param depth depth of the polygon
  50039. * @param flip flip of the polygon
  50040. */
  50041. private addSide;
  50042. }
  50043. }
  50044. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50045. import { Scene } from "babylonjs/scene";
  50046. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50047. import { Mesh } from "babylonjs/Meshes/mesh";
  50048. /**
  50049. * Class containing static functions to help procedurally build meshes
  50050. */
  50051. export class PolygonBuilder {
  50052. /**
  50053. * Creates a polygon mesh
  50054. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50055. * * 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
  50056. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50059. * * Remember you can only change the shape positions, not their number when updating a polygon
  50060. * @param name defines the name of the mesh
  50061. * @param options defines the options used to create the mesh
  50062. * @param scene defines the hosting scene
  50063. * @param earcutInjection can be used to inject your own earcut reference
  50064. * @returns the polygon mesh
  50065. */
  50066. static CreatePolygon(name: string, options: {
  50067. shape: Vector3[];
  50068. holes?: Vector3[][];
  50069. depth?: number;
  50070. faceUV?: Vector4[];
  50071. faceColors?: Color4[];
  50072. updatable?: boolean;
  50073. sideOrientation?: number;
  50074. frontUVs?: Vector4;
  50075. backUVs?: Vector4;
  50076. }, scene: Scene, earcutInjection?: any): Mesh;
  50077. /**
  50078. * Creates an extruded polygon mesh, with depth in the Y direction.
  50079. * * 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)
  50080. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50081. * @param name defines the name of the mesh
  50082. * @param options defines the options used to create the mesh
  50083. * @param scene defines the hosting scene
  50084. * @param earcutInjection can be used to inject your own earcut reference
  50085. * @returns the polygon mesh
  50086. */
  50087. static ExtrudePolygon(name: string, options: {
  50088. shape: Vector3[];
  50089. holes?: Vector3[][];
  50090. depth?: number;
  50091. faceUV?: Vector4[];
  50092. faceColors?: Color4[];
  50093. updatable?: boolean;
  50094. sideOrientation?: number;
  50095. frontUVs?: Vector4;
  50096. backUVs?: Vector4;
  50097. }, scene: Scene, earcutInjection?: any): Mesh;
  50098. }
  50099. }
  50100. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50101. import { Nullable } from "babylonjs/types";
  50102. import { Scene } from "babylonjs/scene";
  50103. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50104. import { Mesh } from "babylonjs/Meshes/mesh";
  50105. /**
  50106. * Class containing static functions to help procedurally build meshes
  50107. */
  50108. export class ShapeBuilder {
  50109. /**
  50110. * 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.
  50111. * * 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.
  50112. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50113. * * 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.
  50114. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50115. * * 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
  50116. * * 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
  50117. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50119. * * If you create a double-sided mesh, you can choose what parts of 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
  50120. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50122. * @param name defines the name of the mesh
  50123. * @param options defines the options used to create the mesh
  50124. * @param scene defines the hosting scene
  50125. * @returns the extruded shape mesh
  50126. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50128. */
  50129. static ExtrudeShape(name: string, options: {
  50130. shape: Vector3[];
  50131. path: Vector3[];
  50132. scale?: number;
  50133. rotation?: number;
  50134. cap?: number;
  50135. updatable?: boolean;
  50136. sideOrientation?: number;
  50137. frontUVs?: Vector4;
  50138. backUVs?: Vector4;
  50139. instance?: Mesh;
  50140. invertUV?: boolean;
  50141. }, scene?: Nullable<Scene>): Mesh;
  50142. /**
  50143. * Creates an custom extruded shape mesh.
  50144. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50145. * * 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.
  50146. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50147. * * 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
  50148. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50149. * * 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
  50150. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50151. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50152. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50153. * * 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
  50154. * * 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
  50155. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50157. * * If you create a double-sided mesh, you can choose what parts of 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
  50158. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50160. * @param name defines the name of the mesh
  50161. * @param options defines the options used to create the mesh
  50162. * @param scene defines the hosting scene
  50163. * @returns the custom extruded shape mesh
  50164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50165. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50167. */
  50168. static ExtrudeShapeCustom(name: string, options: {
  50169. shape: Vector3[];
  50170. path: Vector3[];
  50171. scaleFunction?: any;
  50172. rotationFunction?: any;
  50173. ribbonCloseArray?: boolean;
  50174. ribbonClosePath?: boolean;
  50175. cap?: number;
  50176. updatable?: boolean;
  50177. sideOrientation?: number;
  50178. frontUVs?: Vector4;
  50179. backUVs?: Vector4;
  50180. instance?: Mesh;
  50181. invertUV?: boolean;
  50182. }, scene: Scene): Mesh;
  50183. private static _ExtrudeShapeGeneric;
  50184. }
  50185. }
  50186. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50187. import { Scene } from "babylonjs/scene";
  50188. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50189. import { Mesh } from "babylonjs/Meshes/mesh";
  50190. /**
  50191. * Class containing static functions to help procedurally build meshes
  50192. */
  50193. export class LatheBuilder {
  50194. /**
  50195. * Creates lathe mesh.
  50196. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50197. * * 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
  50198. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50199. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50200. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50201. * * 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
  50202. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50203. * * 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
  50204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50205. * * If you create a double-sided mesh, you can choose what parts of 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
  50206. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50208. * @param name defines the name of the mesh
  50209. * @param options defines the options used to create the mesh
  50210. * @param scene defines the hosting scene
  50211. * @returns the lathe mesh
  50212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50213. */
  50214. static CreateLathe(name: string, options: {
  50215. shape: Vector3[];
  50216. radius?: number;
  50217. tessellation?: number;
  50218. clip?: number;
  50219. arc?: number;
  50220. closed?: boolean;
  50221. updatable?: boolean;
  50222. sideOrientation?: number;
  50223. frontUVs?: Vector4;
  50224. backUVs?: Vector4;
  50225. cap?: number;
  50226. invertUV?: boolean;
  50227. }, scene: Scene): Mesh;
  50228. }
  50229. }
  50230. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50231. import { Scene } from "babylonjs/scene";
  50232. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50233. import { Mesh } from "babylonjs/Meshes/mesh";
  50234. /**
  50235. * Class containing static functions to help procedurally build meshes
  50236. */
  50237. export class TubeBuilder {
  50238. /**
  50239. * Creates a tube mesh.
  50240. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50241. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50242. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50243. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50244. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50245. * * 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)
  50246. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50247. * * 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
  50248. * * 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
  50249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50250. * * If you create a double-sided mesh, you can choose what parts of 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
  50251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50253. * @param name defines the name of the mesh
  50254. * @param options defines the options used to create the mesh
  50255. * @param scene defines the hosting scene
  50256. * @returns the tube mesh
  50257. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50258. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50259. */
  50260. static CreateTube(name: string, options: {
  50261. path: Vector3[];
  50262. radius?: number;
  50263. tessellation?: number;
  50264. radiusFunction?: {
  50265. (i: number, distance: number): number;
  50266. };
  50267. cap?: number;
  50268. arc?: number;
  50269. updatable?: boolean;
  50270. sideOrientation?: number;
  50271. frontUVs?: Vector4;
  50272. backUVs?: Vector4;
  50273. instance?: Mesh;
  50274. invertUV?: boolean;
  50275. }, scene: Scene): Mesh;
  50276. }
  50277. }
  50278. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50279. import { Scene } from "babylonjs/scene";
  50280. import { Vector4 } from "babylonjs/Maths/math";
  50281. import { Mesh } from "babylonjs/Meshes/mesh";
  50282. /**
  50283. * Class containing static functions to help procedurally build meshes
  50284. */
  50285. export class IcoSphereBuilder {
  50286. /**
  50287. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50288. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50289. * * 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`)
  50290. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50291. * * 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
  50292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50293. * * If you create a double-sided mesh, you can choose what parts of 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
  50294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50295. * @param name defines the name of the mesh
  50296. * @param options defines the options used to create the mesh
  50297. * @param scene defines the hosting scene
  50298. * @returns the icosahedron mesh
  50299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50300. */
  50301. static CreateIcoSphere(name: string, options: {
  50302. radius?: number;
  50303. radiusX?: number;
  50304. radiusY?: number;
  50305. radiusZ?: number;
  50306. flat?: boolean;
  50307. subdivisions?: number;
  50308. sideOrientation?: number;
  50309. frontUVs?: Vector4;
  50310. backUVs?: Vector4;
  50311. updatable?: boolean;
  50312. }, scene: Scene): Mesh;
  50313. }
  50314. }
  50315. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50316. import { Vector3 } from "babylonjs/Maths/math";
  50317. import { Mesh } from "babylonjs/Meshes/mesh";
  50318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50319. /**
  50320. * Class containing static functions to help procedurally build meshes
  50321. */
  50322. export class DecalBuilder {
  50323. /**
  50324. * Creates a decal mesh.
  50325. * 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
  50326. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50327. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50328. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50329. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50330. * @param name defines the name of the mesh
  50331. * @param sourceMesh defines the mesh where the decal must be applied
  50332. * @param options defines the options used to create the mesh
  50333. * @param scene defines the hosting scene
  50334. * @returns the decal mesh
  50335. * @see https://doc.babylonjs.com/how_to/decals
  50336. */
  50337. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50338. position?: Vector3;
  50339. normal?: Vector3;
  50340. size?: Vector3;
  50341. angle?: number;
  50342. }): Mesh;
  50343. }
  50344. }
  50345. declare module "babylonjs/Meshes/meshBuilder" {
  50346. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50347. import { Nullable } from "babylonjs/types";
  50348. import { Scene } from "babylonjs/scene";
  50349. import { Mesh } from "babylonjs/Meshes/mesh";
  50350. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50351. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50353. /**
  50354. * Class containing static functions to help procedurally build meshes
  50355. */
  50356. export class MeshBuilder {
  50357. /**
  50358. * Creates a box mesh
  50359. * * The parameter `size` sets the size (float) of each box side (default 1)
  50360. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50361. * * 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)
  50362. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50364. * * If you create a double-sided mesh, you can choose what parts of 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
  50365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50366. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50367. * @param name defines the name of the mesh
  50368. * @param options defines the options used to create the mesh
  50369. * @param scene defines the hosting scene
  50370. * @returns the box mesh
  50371. */
  50372. static CreateBox(name: string, options: {
  50373. size?: number;
  50374. width?: number;
  50375. height?: number;
  50376. depth?: number;
  50377. faceUV?: Vector4[];
  50378. faceColors?: Color4[];
  50379. sideOrientation?: number;
  50380. frontUVs?: Vector4;
  50381. backUVs?: Vector4;
  50382. updatable?: boolean;
  50383. }, scene?: Nullable<Scene>): Mesh;
  50384. /**
  50385. * Creates a sphere mesh
  50386. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50387. * * 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`)
  50388. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50389. * * 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
  50390. * * 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)
  50391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50392. * * If you create a double-sided mesh, you can choose what parts of 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
  50393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50394. * @param name defines the name of the mesh
  50395. * @param options defines the options used to create the mesh
  50396. * @param scene defines the hosting scene
  50397. * @returns the sphere mesh
  50398. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50399. */
  50400. static CreateSphere(name: string, options: {
  50401. segments?: number;
  50402. diameter?: number;
  50403. diameterX?: number;
  50404. diameterY?: number;
  50405. diameterZ?: number;
  50406. arc?: number;
  50407. slice?: number;
  50408. sideOrientation?: number;
  50409. frontUVs?: Vector4;
  50410. backUVs?: Vector4;
  50411. updatable?: boolean;
  50412. }, scene: any): Mesh;
  50413. /**
  50414. * Creates a plane polygonal mesh. By default, this is a disc
  50415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50416. * * 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
  50417. * * 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
  50418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50419. * * If you create a double-sided mesh, you can choose what parts of 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
  50420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50421. * @param name defines the name of the mesh
  50422. * @param options defines the options used to create the mesh
  50423. * @param scene defines the hosting scene
  50424. * @returns the plane polygonal mesh
  50425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50426. */
  50427. static CreateDisc(name: string, options: {
  50428. radius?: number;
  50429. tessellation?: number;
  50430. arc?: number;
  50431. updatable?: boolean;
  50432. sideOrientation?: number;
  50433. frontUVs?: Vector4;
  50434. backUVs?: Vector4;
  50435. }, scene?: Nullable<Scene>): Mesh;
  50436. /**
  50437. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50438. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50439. * * 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`)
  50440. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50441. * * 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
  50442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50443. * * If you create a double-sided mesh, you can choose what parts of 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
  50444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50445. * @param name defines the name of the mesh
  50446. * @param options defines the options used to create the mesh
  50447. * @param scene defines the hosting scene
  50448. * @returns the icosahedron mesh
  50449. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50450. */
  50451. static CreateIcoSphere(name: string, options: {
  50452. radius?: number;
  50453. radiusX?: number;
  50454. radiusY?: number;
  50455. radiusZ?: number;
  50456. flat?: boolean;
  50457. subdivisions?: number;
  50458. sideOrientation?: number;
  50459. frontUVs?: Vector4;
  50460. backUVs?: Vector4;
  50461. updatable?: boolean;
  50462. }, scene: Scene): Mesh;
  50463. /**
  50464. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50465. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50466. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50467. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50468. * * 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
  50469. * * 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
  50470. * * 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
  50471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50472. * * If you create a double-sided mesh, you can choose what parts of 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
  50473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50474. * * 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
  50475. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50476. * * 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
  50477. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50479. * @param name defines the name of the mesh
  50480. * @param options defines the options used to create the mesh
  50481. * @param scene defines the hosting scene
  50482. * @returns the ribbon mesh
  50483. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50485. */
  50486. static CreateRibbon(name: string, options: {
  50487. pathArray: Vector3[][];
  50488. closeArray?: boolean;
  50489. closePath?: boolean;
  50490. offset?: number;
  50491. updatable?: boolean;
  50492. sideOrientation?: number;
  50493. frontUVs?: Vector4;
  50494. backUVs?: Vector4;
  50495. instance?: Mesh;
  50496. invertUV?: boolean;
  50497. uvs?: Vector2[];
  50498. colors?: Color4[];
  50499. }, scene?: Nullable<Scene>): Mesh;
  50500. /**
  50501. * Creates a cylinder or a cone mesh
  50502. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50503. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50504. * * 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.
  50505. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50506. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50507. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50508. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50509. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50510. * * 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).
  50511. * * 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
  50512. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50513. * * 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
  50514. * * 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.
  50515. * * If `enclose` is false, a ring surface is one element.
  50516. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50517. * * 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
  50518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50519. * * If you create a double-sided mesh, you can choose what parts of 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
  50520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50521. * @param name defines the name of the mesh
  50522. * @param options defines the options used to create the mesh
  50523. * @param scene defines the hosting scene
  50524. * @returns the cylinder mesh
  50525. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50526. */
  50527. static CreateCylinder(name: string, options: {
  50528. height?: number;
  50529. diameterTop?: number;
  50530. diameterBottom?: number;
  50531. diameter?: number;
  50532. tessellation?: number;
  50533. subdivisions?: number;
  50534. arc?: number;
  50535. faceColors?: Color4[];
  50536. faceUV?: Vector4[];
  50537. updatable?: boolean;
  50538. hasRings?: boolean;
  50539. enclose?: boolean;
  50540. sideOrientation?: number;
  50541. frontUVs?: Vector4;
  50542. backUVs?: Vector4;
  50543. }, scene: any): Mesh;
  50544. /**
  50545. * Creates a torus mesh
  50546. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50547. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50548. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50550. * * If you create a double-sided mesh, you can choose what parts of 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
  50551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50552. * @param name defines the name of the mesh
  50553. * @param options defines the options used to create the mesh
  50554. * @param scene defines the hosting scene
  50555. * @returns the torus mesh
  50556. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50557. */
  50558. static CreateTorus(name: string, options: {
  50559. diameter?: number;
  50560. thickness?: number;
  50561. tessellation?: number;
  50562. updatable?: boolean;
  50563. sideOrientation?: number;
  50564. frontUVs?: Vector4;
  50565. backUVs?: Vector4;
  50566. }, scene: any): Mesh;
  50567. /**
  50568. * Creates a torus knot mesh
  50569. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50570. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50571. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50572. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50574. * * If you create a double-sided mesh, you can choose what parts of 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
  50575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50576. * @param name defines the name of the mesh
  50577. * @param options defines the options used to create the mesh
  50578. * @param scene defines the hosting scene
  50579. * @returns the torus knot mesh
  50580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50581. */
  50582. static CreateTorusKnot(name: string, options: {
  50583. radius?: number;
  50584. tube?: number;
  50585. radialSegments?: number;
  50586. tubularSegments?: number;
  50587. p?: number;
  50588. q?: number;
  50589. updatable?: boolean;
  50590. sideOrientation?: number;
  50591. frontUVs?: Vector4;
  50592. backUVs?: Vector4;
  50593. }, scene: any): Mesh;
  50594. /**
  50595. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50596. * * 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
  50597. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50598. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50599. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50600. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50601. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50602. * * 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
  50603. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50606. * @param name defines the name of the new line system
  50607. * @param options defines the options used to create the line system
  50608. * @param scene defines the hosting scene
  50609. * @returns a new line system mesh
  50610. */
  50611. static CreateLineSystem(name: string, options: {
  50612. lines: Vector3[][];
  50613. updatable?: boolean;
  50614. instance?: Nullable<LinesMesh>;
  50615. colors?: Nullable<Color4[][]>;
  50616. useVertexAlpha?: boolean;
  50617. }, scene: Nullable<Scene>): LinesMesh;
  50618. /**
  50619. * Creates a line mesh
  50620. * 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
  50621. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50622. * * The parameter `points` is an array successive Vector3
  50623. * * 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
  50624. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50625. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50626. * * When updating an instance, remember that only point positions can change, not the number of points
  50627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50629. * @param name defines the name of the new line system
  50630. * @param options defines the options used to create the line system
  50631. * @param scene defines the hosting scene
  50632. * @returns a new line mesh
  50633. */
  50634. static CreateLines(name: string, options: {
  50635. points: Vector3[];
  50636. updatable?: boolean;
  50637. instance?: Nullable<LinesMesh>;
  50638. colors?: Color4[];
  50639. useVertexAlpha?: boolean;
  50640. }, scene?: Nullable<Scene>): LinesMesh;
  50641. /**
  50642. * Creates a dashed line mesh
  50643. * * 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
  50644. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50645. * * The parameter `points` is an array successive Vector3
  50646. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50647. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50648. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50649. * * 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
  50650. * * When updating an instance, remember that only point positions can change, not the number of points
  50651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50652. * @param name defines the name of the mesh
  50653. * @param options defines the options used to create the mesh
  50654. * @param scene defines the hosting scene
  50655. * @returns the dashed line mesh
  50656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50657. */
  50658. static CreateDashedLines(name: string, options: {
  50659. points: Vector3[];
  50660. dashSize?: number;
  50661. gapSize?: number;
  50662. dashNb?: number;
  50663. updatable?: boolean;
  50664. instance?: LinesMesh;
  50665. }, scene?: Nullable<Scene>): LinesMesh;
  50666. /**
  50667. * 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.
  50668. * * 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.
  50669. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50670. * * 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.
  50671. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50672. * * 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
  50673. * * 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
  50674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50676. * * If you create a double-sided mesh, you can choose what parts of 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
  50677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50679. * @param name defines the name of the mesh
  50680. * @param options defines the options used to create the mesh
  50681. * @param scene defines the hosting scene
  50682. * @returns the extruded shape mesh
  50683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50685. */
  50686. static ExtrudeShape(name: string, options: {
  50687. shape: Vector3[];
  50688. path: Vector3[];
  50689. scale?: number;
  50690. rotation?: number;
  50691. cap?: number;
  50692. updatable?: boolean;
  50693. sideOrientation?: number;
  50694. frontUVs?: Vector4;
  50695. backUVs?: Vector4;
  50696. instance?: Mesh;
  50697. invertUV?: boolean;
  50698. }, scene?: Nullable<Scene>): Mesh;
  50699. /**
  50700. * Creates an custom extruded shape mesh.
  50701. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50702. * * 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.
  50703. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50704. * * 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
  50705. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50706. * * 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
  50707. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50708. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50709. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50710. * * 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
  50711. * * 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
  50712. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50714. * * If you create a double-sided mesh, you can choose what parts of 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
  50715. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50717. * @param name defines the name of the mesh
  50718. * @param options defines the options used to create the mesh
  50719. * @param scene defines the hosting scene
  50720. * @returns the custom extruded shape mesh
  50721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50724. */
  50725. static ExtrudeShapeCustom(name: string, options: {
  50726. shape: Vector3[];
  50727. path: Vector3[];
  50728. scaleFunction?: any;
  50729. rotationFunction?: any;
  50730. ribbonCloseArray?: boolean;
  50731. ribbonClosePath?: boolean;
  50732. cap?: number;
  50733. updatable?: boolean;
  50734. sideOrientation?: number;
  50735. frontUVs?: Vector4;
  50736. backUVs?: Vector4;
  50737. instance?: Mesh;
  50738. invertUV?: boolean;
  50739. }, scene: Scene): Mesh;
  50740. /**
  50741. * Creates lathe mesh.
  50742. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50743. * * 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
  50744. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50745. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50746. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50747. * * 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
  50748. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50749. * * 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
  50750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50751. * * If you create a double-sided mesh, you can choose what parts of 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
  50752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50754. * @param name defines the name of the mesh
  50755. * @param options defines the options used to create the mesh
  50756. * @param scene defines the hosting scene
  50757. * @returns the lathe mesh
  50758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50759. */
  50760. static CreateLathe(name: string, options: {
  50761. shape: Vector3[];
  50762. radius?: number;
  50763. tessellation?: number;
  50764. clip?: number;
  50765. arc?: number;
  50766. closed?: boolean;
  50767. updatable?: boolean;
  50768. sideOrientation?: number;
  50769. frontUVs?: Vector4;
  50770. backUVs?: Vector4;
  50771. cap?: number;
  50772. invertUV?: boolean;
  50773. }, scene: Scene): Mesh;
  50774. /**
  50775. * Creates a plane mesh
  50776. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50777. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50778. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50780. * * If you create a double-sided mesh, you can choose what parts of 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
  50781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50782. * @param name defines the name of the mesh
  50783. * @param options defines the options used to create the mesh
  50784. * @param scene defines the hosting scene
  50785. * @returns the plane mesh
  50786. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50787. */
  50788. static CreatePlane(name: string, options: {
  50789. size?: number;
  50790. width?: number;
  50791. height?: number;
  50792. sideOrientation?: number;
  50793. frontUVs?: Vector4;
  50794. backUVs?: Vector4;
  50795. updatable?: boolean;
  50796. sourcePlane?: Plane;
  50797. }, scene: Scene): Mesh;
  50798. /**
  50799. * Creates a ground mesh
  50800. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50801. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50803. * @param name defines the name of the mesh
  50804. * @param options defines the options used to create the mesh
  50805. * @param scene defines the hosting scene
  50806. * @returns the ground mesh
  50807. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50808. */
  50809. static CreateGround(name: string, options: {
  50810. width?: number;
  50811. height?: number;
  50812. subdivisions?: number;
  50813. subdivisionsX?: number;
  50814. subdivisionsY?: number;
  50815. updatable?: boolean;
  50816. }, scene: any): Mesh;
  50817. /**
  50818. * Creates a tiled ground mesh
  50819. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50820. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50821. * * 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
  50822. * * 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
  50823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50824. * @param name defines the name of the mesh
  50825. * @param options defines the options used to create the mesh
  50826. * @param scene defines the hosting scene
  50827. * @returns the tiled ground mesh
  50828. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50829. */
  50830. static CreateTiledGround(name: string, options: {
  50831. xmin: number;
  50832. zmin: number;
  50833. xmax: number;
  50834. zmax: number;
  50835. subdivisions?: {
  50836. w: number;
  50837. h: number;
  50838. };
  50839. precision?: {
  50840. w: number;
  50841. h: number;
  50842. };
  50843. updatable?: boolean;
  50844. }, scene: Scene): Mesh;
  50845. /**
  50846. * Creates a ground mesh from a height map
  50847. * * The parameter `url` sets the URL of the height map image resource.
  50848. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50849. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50850. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50851. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50852. * * 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.
  50853. * * 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).
  50854. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50856. * @param name defines the name of the mesh
  50857. * @param url defines the url to the height map
  50858. * @param options defines the options used to create the mesh
  50859. * @param scene defines the hosting scene
  50860. * @returns the ground mesh
  50861. * @see https://doc.babylonjs.com/babylon101/height_map
  50862. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50863. */
  50864. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50865. width?: number;
  50866. height?: number;
  50867. subdivisions?: number;
  50868. minHeight?: number;
  50869. maxHeight?: number;
  50870. colorFilter?: Color3;
  50871. alphaFilter?: number;
  50872. updatable?: boolean;
  50873. onReady?: (mesh: GroundMesh) => void;
  50874. }, scene: Scene): GroundMesh;
  50875. /**
  50876. * Creates a polygon mesh
  50877. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50878. * * 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
  50879. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50882. * * Remember you can only change the shape positions, not their number when updating a polygon
  50883. * @param name defines the name of the mesh
  50884. * @param options defines the options used to create the mesh
  50885. * @param scene defines the hosting scene
  50886. * @param earcutInjection can be used to inject your own earcut reference
  50887. * @returns the polygon mesh
  50888. */
  50889. static CreatePolygon(name: string, options: {
  50890. shape: Vector3[];
  50891. holes?: Vector3[][];
  50892. depth?: number;
  50893. faceUV?: Vector4[];
  50894. faceColors?: Color4[];
  50895. updatable?: boolean;
  50896. sideOrientation?: number;
  50897. frontUVs?: Vector4;
  50898. backUVs?: Vector4;
  50899. }, scene: Scene, earcutInjection?: any): Mesh;
  50900. /**
  50901. * Creates an extruded polygon mesh, with depth in the Y direction.
  50902. * * 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)
  50903. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50904. * @param name defines the name of the mesh
  50905. * @param options defines the options used to create the mesh
  50906. * @param scene defines the hosting scene
  50907. * @param earcutInjection can be used to inject your own earcut reference
  50908. * @returns the polygon mesh
  50909. */
  50910. static ExtrudePolygon(name: string, options: {
  50911. shape: Vector3[];
  50912. holes?: Vector3[][];
  50913. depth?: number;
  50914. faceUV?: Vector4[];
  50915. faceColors?: Color4[];
  50916. updatable?: boolean;
  50917. sideOrientation?: number;
  50918. frontUVs?: Vector4;
  50919. backUVs?: Vector4;
  50920. }, scene: Scene, earcutInjection?: any): Mesh;
  50921. /**
  50922. * Creates a tube mesh.
  50923. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50924. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50925. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50926. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50927. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50928. * * 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)
  50929. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50930. * * 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
  50931. * * 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
  50932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50933. * * If you create a double-sided mesh, you can choose what parts of 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
  50934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50936. * @param name defines the name of the mesh
  50937. * @param options defines the options used to create the mesh
  50938. * @param scene defines the hosting scene
  50939. * @returns the tube mesh
  50940. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50941. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50942. */
  50943. static CreateTube(name: string, options: {
  50944. path: Vector3[];
  50945. radius?: number;
  50946. tessellation?: number;
  50947. radiusFunction?: {
  50948. (i: number, distance: number): number;
  50949. };
  50950. cap?: number;
  50951. arc?: number;
  50952. updatable?: boolean;
  50953. sideOrientation?: number;
  50954. frontUVs?: Vector4;
  50955. backUVs?: Vector4;
  50956. instance?: Mesh;
  50957. invertUV?: boolean;
  50958. }, scene: Scene): Mesh;
  50959. /**
  50960. * Creates a polyhedron mesh
  50961. * * 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
  50962. * * The parameter `size` (positive float, default 1) sets the polygon size
  50963. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50964. * * 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`
  50965. * * 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
  50966. * * 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)`)
  50967. * * 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
  50968. * * 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
  50969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50970. * * If you create a double-sided mesh, you can choose what parts of 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
  50971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50972. * @param name defines the name of the mesh
  50973. * @param options defines the options used to create the mesh
  50974. * @param scene defines the hosting scene
  50975. * @returns the polyhedron mesh
  50976. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50977. */
  50978. static CreatePolyhedron(name: string, options: {
  50979. type?: number;
  50980. size?: number;
  50981. sizeX?: number;
  50982. sizeY?: number;
  50983. sizeZ?: number;
  50984. custom?: any;
  50985. faceUV?: Vector4[];
  50986. faceColors?: Color4[];
  50987. flat?: boolean;
  50988. updatable?: boolean;
  50989. sideOrientation?: number;
  50990. frontUVs?: Vector4;
  50991. backUVs?: Vector4;
  50992. }, scene: Scene): Mesh;
  50993. /**
  50994. * Creates a decal mesh.
  50995. * 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
  50996. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50997. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50998. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50999. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51000. * @param name defines the name of the mesh
  51001. * @param sourceMesh defines the mesh where the decal must be applied
  51002. * @param options defines the options used to create the mesh
  51003. * @param scene defines the hosting scene
  51004. * @returns the decal mesh
  51005. * @see https://doc.babylonjs.com/how_to/decals
  51006. */
  51007. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51008. position?: Vector3;
  51009. normal?: Vector3;
  51010. size?: Vector3;
  51011. angle?: number;
  51012. }): Mesh;
  51013. }
  51014. }
  51015. declare module "babylonjs/Meshes/meshSimplification" {
  51016. import { Mesh } from "babylonjs/Meshes/mesh";
  51017. /**
  51018. * A simplifier interface for future simplification implementations
  51019. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51020. */
  51021. export interface ISimplifier {
  51022. /**
  51023. * Simplification of a given mesh according to the given settings.
  51024. * Since this requires computation, it is assumed that the function runs async.
  51025. * @param settings The settings of the simplification, including quality and distance
  51026. * @param successCallback A callback that will be called after the mesh was simplified.
  51027. * @param errorCallback in case of an error, this callback will be called. optional.
  51028. */
  51029. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51030. }
  51031. /**
  51032. * Expected simplification settings.
  51033. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51034. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51035. */
  51036. export interface ISimplificationSettings {
  51037. /**
  51038. * Gets or sets the expected quality
  51039. */
  51040. quality: number;
  51041. /**
  51042. * Gets or sets the distance when this optimized version should be used
  51043. */
  51044. distance: number;
  51045. /**
  51046. * Gets an already optimized mesh
  51047. */
  51048. optimizeMesh?: boolean;
  51049. }
  51050. /**
  51051. * Class used to specify simplification options
  51052. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51053. */
  51054. export class SimplificationSettings implements ISimplificationSettings {
  51055. /** expected quality */
  51056. quality: number;
  51057. /** distance when this optimized version should be used */
  51058. distance: number;
  51059. /** already optimized mesh */
  51060. optimizeMesh?: boolean | undefined;
  51061. /**
  51062. * Creates a SimplificationSettings
  51063. * @param quality expected quality
  51064. * @param distance distance when this optimized version should be used
  51065. * @param optimizeMesh already optimized mesh
  51066. */
  51067. constructor(
  51068. /** expected quality */
  51069. quality: number,
  51070. /** distance when this optimized version should be used */
  51071. distance: number,
  51072. /** already optimized mesh */
  51073. optimizeMesh?: boolean | undefined);
  51074. }
  51075. /**
  51076. * Interface used to define a simplification task
  51077. */
  51078. export interface ISimplificationTask {
  51079. /**
  51080. * Array of settings
  51081. */
  51082. settings: Array<ISimplificationSettings>;
  51083. /**
  51084. * Simplification type
  51085. */
  51086. simplificationType: SimplificationType;
  51087. /**
  51088. * Mesh to simplify
  51089. */
  51090. mesh: Mesh;
  51091. /**
  51092. * Callback called on success
  51093. */
  51094. successCallback?: () => void;
  51095. /**
  51096. * Defines if parallel processing can be used
  51097. */
  51098. parallelProcessing: boolean;
  51099. }
  51100. /**
  51101. * Queue used to order the simplification tasks
  51102. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51103. */
  51104. export class SimplificationQueue {
  51105. private _simplificationArray;
  51106. /**
  51107. * Gets a boolean indicating that the process is still running
  51108. */
  51109. running: boolean;
  51110. /**
  51111. * Creates a new queue
  51112. */
  51113. constructor();
  51114. /**
  51115. * Adds a new simplification task
  51116. * @param task defines a task to add
  51117. */
  51118. addTask(task: ISimplificationTask): void;
  51119. /**
  51120. * Execute next task
  51121. */
  51122. executeNext(): void;
  51123. /**
  51124. * Execute a simplification task
  51125. * @param task defines the task to run
  51126. */
  51127. runSimplification(task: ISimplificationTask): void;
  51128. private getSimplifier;
  51129. }
  51130. /**
  51131. * The implemented types of simplification
  51132. * At the moment only Quadratic Error Decimation is implemented
  51133. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51134. */
  51135. export enum SimplificationType {
  51136. /** Quadratic error decimation */
  51137. QUADRATIC = 0
  51138. }
  51139. }
  51140. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51141. import { Scene } from "babylonjs/scene";
  51142. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51143. import { ISceneComponent } from "babylonjs/sceneComponent";
  51144. module "babylonjs/scene" {
  51145. interface Scene {
  51146. /** @hidden (Backing field) */
  51147. _simplificationQueue: SimplificationQueue;
  51148. /**
  51149. * Gets or sets the simplification queue attached to the scene
  51150. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51151. */
  51152. simplificationQueue: SimplificationQueue;
  51153. }
  51154. }
  51155. module "babylonjs/Meshes/mesh" {
  51156. interface Mesh {
  51157. /**
  51158. * Simplify the mesh according to the given array of settings.
  51159. * Function will return immediately and will simplify async
  51160. * @param settings a collection of simplification settings
  51161. * @param parallelProcessing should all levels calculate parallel or one after the other
  51162. * @param simplificationType the type of simplification to run
  51163. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51164. * @returns the current mesh
  51165. */
  51166. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51167. }
  51168. }
  51169. /**
  51170. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51171. * created in a scene
  51172. */
  51173. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51174. /**
  51175. * The component name helpfull to identify the component in the list of scene components.
  51176. */
  51177. readonly name: string;
  51178. /**
  51179. * The scene the component belongs to.
  51180. */
  51181. scene: Scene;
  51182. /**
  51183. * Creates a new instance of the component for the given scene
  51184. * @param scene Defines the scene to register the component in
  51185. */
  51186. constructor(scene: Scene);
  51187. /**
  51188. * Registers the component in a given scene
  51189. */
  51190. register(): void;
  51191. /**
  51192. * Rebuilds the elements related to this component in case of
  51193. * context lost for instance.
  51194. */
  51195. rebuild(): void;
  51196. /**
  51197. * Disposes the component and the associated ressources
  51198. */
  51199. dispose(): void;
  51200. private _beforeCameraUpdate;
  51201. }
  51202. }
  51203. declare module "babylonjs/Meshes/Builders/index" {
  51204. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51205. export * from "babylonjs/Meshes/Builders/discBuilder";
  51206. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51207. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51208. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51209. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51210. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51211. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51212. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51213. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51214. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51215. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51216. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51217. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51218. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51219. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51220. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51221. }
  51222. declare module "babylonjs/Meshes/index" {
  51223. export * from "babylonjs/Meshes/abstractMesh";
  51224. export * from "babylonjs/Meshes/buffer";
  51225. export * from "babylonjs/Meshes/Compression/index";
  51226. export * from "babylonjs/Meshes/csg";
  51227. export * from "babylonjs/Meshes/geometry";
  51228. export * from "babylonjs/Meshes/groundMesh";
  51229. export * from "babylonjs/Meshes/trailMesh";
  51230. export * from "babylonjs/Meshes/instancedMesh";
  51231. export * from "babylonjs/Meshes/linesMesh";
  51232. export * from "babylonjs/Meshes/mesh";
  51233. export * from "babylonjs/Meshes/mesh.vertexData";
  51234. export * from "babylonjs/Meshes/meshBuilder";
  51235. export * from "babylonjs/Meshes/meshSimplification";
  51236. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51237. export * from "babylonjs/Meshes/polygonMesh";
  51238. export * from "babylonjs/Meshes/subMesh";
  51239. export * from "babylonjs/Meshes/transformNode";
  51240. export * from "babylonjs/Meshes/Builders/index";
  51241. }
  51242. declare module "babylonjs/Morph/index" {
  51243. export * from "babylonjs/Morph/morphTarget";
  51244. export * from "babylonjs/Morph/morphTargetManager";
  51245. }
  51246. declare module "babylonjs/Offline/database" {
  51247. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51248. /**
  51249. * Class used to enable access to IndexedDB
  51250. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51251. */
  51252. export class Database implements IOfflineProvider {
  51253. private _callbackManifestChecked;
  51254. private _currentSceneUrl;
  51255. private _db;
  51256. private _enableSceneOffline;
  51257. private _enableTexturesOffline;
  51258. private _manifestVersionFound;
  51259. private _mustUpdateRessources;
  51260. private _hasReachedQuota;
  51261. private _isSupported;
  51262. private _idbFactory;
  51263. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51264. private static IsUASupportingBlobStorage;
  51265. /**
  51266. * Gets a boolean indicating if Database storate is enabled (off by default)
  51267. */
  51268. static IDBStorageEnabled: boolean;
  51269. /**
  51270. * Gets a boolean indicating if scene must be saved in the database
  51271. */
  51272. readonly enableSceneOffline: boolean;
  51273. /**
  51274. * Gets a boolean indicating if textures must be saved in the database
  51275. */
  51276. readonly enableTexturesOffline: boolean;
  51277. /**
  51278. * Creates a new Database
  51279. * @param urlToScene defines the url to load the scene
  51280. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51281. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51282. */
  51283. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51284. private static _ParseURL;
  51285. private static _ReturnFullUrlLocation;
  51286. private _checkManifestFile;
  51287. /**
  51288. * Open the database and make it available
  51289. * @param successCallback defines the callback to call on success
  51290. * @param errorCallback defines the callback to call on error
  51291. */
  51292. open(successCallback: () => void, errorCallback: () => void): void;
  51293. /**
  51294. * Loads an image from the database
  51295. * @param url defines the url to load from
  51296. * @param image defines the target DOM image
  51297. */
  51298. loadImage(url: string, image: HTMLImageElement): void;
  51299. private _loadImageFromDBAsync;
  51300. private _saveImageIntoDBAsync;
  51301. private _checkVersionFromDB;
  51302. private _loadVersionFromDBAsync;
  51303. private _saveVersionIntoDBAsync;
  51304. /**
  51305. * Loads a file from database
  51306. * @param url defines the URL to load from
  51307. * @param sceneLoaded defines a callback to call on success
  51308. * @param progressCallBack defines a callback to call when progress changed
  51309. * @param errorCallback defines a callback to call on error
  51310. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51311. */
  51312. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51313. private _loadFileAsync;
  51314. private _saveFileAsync;
  51315. /**
  51316. * Validates if xhr data is correct
  51317. * @param xhr defines the request to validate
  51318. * @param dataType defines the expected data type
  51319. * @returns true if data is correct
  51320. */
  51321. private static _ValidateXHRData;
  51322. }
  51323. }
  51324. declare module "babylonjs/Offline/index" {
  51325. export * from "babylonjs/Offline/database";
  51326. export * from "babylonjs/Offline/IOfflineProvider";
  51327. }
  51328. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51329. /** @hidden */
  51330. export var gpuUpdateParticlesPixelShader: {
  51331. name: string;
  51332. shader: string;
  51333. };
  51334. }
  51335. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51336. /** @hidden */
  51337. export var gpuUpdateParticlesVertexShader: {
  51338. name: string;
  51339. shader: string;
  51340. };
  51341. }
  51342. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51343. /** @hidden */
  51344. export var clipPlaneFragmentDeclaration2: {
  51345. name: string;
  51346. shader: string;
  51347. };
  51348. }
  51349. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51351. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51353. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51354. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51355. /** @hidden */
  51356. export var gpuRenderParticlesPixelShader: {
  51357. name: string;
  51358. shader: string;
  51359. };
  51360. }
  51361. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51362. /** @hidden */
  51363. export var clipPlaneVertexDeclaration2: {
  51364. name: string;
  51365. shader: string;
  51366. };
  51367. }
  51368. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51369. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51371. /** @hidden */
  51372. export var gpuRenderParticlesVertexShader: {
  51373. name: string;
  51374. shader: string;
  51375. };
  51376. }
  51377. declare module "babylonjs/Particles/gpuParticleSystem" {
  51378. import { Nullable } from "babylonjs/types";
  51379. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51380. import { Observable } from "babylonjs/Misc/observable";
  51381. import { Color4, Color3 } from "babylonjs/Maths/math";
  51382. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51383. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51384. import { Scene, IDisposable } from "babylonjs/scene";
  51385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51386. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51387. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51388. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51389. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51390. /**
  51391. * This represents a GPU particle system in Babylon
  51392. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51393. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51394. */
  51395. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51396. /**
  51397. * The layer mask we are rendering the particles through.
  51398. */
  51399. layerMask: number;
  51400. private _capacity;
  51401. private _activeCount;
  51402. private _currentActiveCount;
  51403. private _accumulatedCount;
  51404. private _renderEffect;
  51405. private _updateEffect;
  51406. private _buffer0;
  51407. private _buffer1;
  51408. private _spriteBuffer;
  51409. private _updateVAO;
  51410. private _renderVAO;
  51411. private _targetIndex;
  51412. private _sourceBuffer;
  51413. private _targetBuffer;
  51414. private _engine;
  51415. private _currentRenderId;
  51416. private _started;
  51417. private _stopped;
  51418. private _timeDelta;
  51419. private _randomTexture;
  51420. private _randomTexture2;
  51421. private _attributesStrideSize;
  51422. private _updateEffectOptions;
  51423. private _randomTextureSize;
  51424. private _actualFrame;
  51425. private readonly _rawTextureWidth;
  51426. /**
  51427. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51428. */
  51429. static readonly IsSupported: boolean;
  51430. /**
  51431. * An event triggered when the system is disposed.
  51432. */
  51433. onDisposeObservable: Observable<GPUParticleSystem>;
  51434. /**
  51435. * Gets the maximum number of particles active at the same time.
  51436. * @returns The max number of active particles.
  51437. */
  51438. getCapacity(): number;
  51439. /**
  51440. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51441. * to override the particles.
  51442. */
  51443. forceDepthWrite: boolean;
  51444. /**
  51445. * Gets or set the number of active particles
  51446. */
  51447. activeParticleCount: number;
  51448. private _preWarmDone;
  51449. /**
  51450. * Is this system ready to be used/rendered
  51451. * @return true if the system is ready
  51452. */
  51453. isReady(): boolean;
  51454. /**
  51455. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51456. * @returns True if it has been started, otherwise false.
  51457. */
  51458. isStarted(): boolean;
  51459. /**
  51460. * Starts the particle system and begins to emit
  51461. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51462. */
  51463. start(delay?: number): void;
  51464. /**
  51465. * Stops the particle system.
  51466. */
  51467. stop(): void;
  51468. /**
  51469. * Remove all active particles
  51470. */
  51471. reset(): void;
  51472. /**
  51473. * Returns the string "GPUParticleSystem"
  51474. * @returns a string containing the class name
  51475. */
  51476. getClassName(): string;
  51477. private _colorGradientsTexture;
  51478. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51479. /**
  51480. * Adds a new color gradient
  51481. * @param gradient defines the gradient to use (between 0 and 1)
  51482. * @param color1 defines the color to affect to the specified gradient
  51483. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51484. * @returns the current particle system
  51485. */
  51486. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51487. /**
  51488. * Remove a specific color gradient
  51489. * @param gradient defines the gradient to remove
  51490. * @returns the current particle system
  51491. */
  51492. removeColorGradient(gradient: number): GPUParticleSystem;
  51493. private _angularSpeedGradientsTexture;
  51494. private _sizeGradientsTexture;
  51495. private _velocityGradientsTexture;
  51496. private _limitVelocityGradientsTexture;
  51497. private _dragGradientsTexture;
  51498. private _addFactorGradient;
  51499. /**
  51500. * Adds a new size gradient
  51501. * @param gradient defines the gradient to use (between 0 and 1)
  51502. * @param factor defines the size factor to affect to the specified gradient
  51503. * @returns the current particle system
  51504. */
  51505. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51506. /**
  51507. * Remove a specific size gradient
  51508. * @param gradient defines the gradient to remove
  51509. * @returns the current particle system
  51510. */
  51511. removeSizeGradient(gradient: number): GPUParticleSystem;
  51512. /**
  51513. * Adds a new angular speed gradient
  51514. * @param gradient defines the gradient to use (between 0 and 1)
  51515. * @param factor defines the angular speed to affect to the specified gradient
  51516. * @returns the current particle system
  51517. */
  51518. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51519. /**
  51520. * Remove a specific angular speed gradient
  51521. * @param gradient defines the gradient to remove
  51522. * @returns the current particle system
  51523. */
  51524. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51525. /**
  51526. * Adds a new velocity gradient
  51527. * @param gradient defines the gradient to use (between 0 and 1)
  51528. * @param factor defines the velocity to affect to the specified gradient
  51529. * @returns the current particle system
  51530. */
  51531. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51532. /**
  51533. * Remove a specific velocity gradient
  51534. * @param gradient defines the gradient to remove
  51535. * @returns the current particle system
  51536. */
  51537. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51538. /**
  51539. * Adds a new limit velocity gradient
  51540. * @param gradient defines the gradient to use (between 0 and 1)
  51541. * @param factor defines the limit velocity value to affect to the specified gradient
  51542. * @returns the current particle system
  51543. */
  51544. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51545. /**
  51546. * Remove a specific limit velocity gradient
  51547. * @param gradient defines the gradient to remove
  51548. * @returns the current particle system
  51549. */
  51550. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51551. /**
  51552. * Adds a new drag gradient
  51553. * @param gradient defines the gradient to use (between 0 and 1)
  51554. * @param factor defines the drag value to affect to the specified gradient
  51555. * @returns the current particle system
  51556. */
  51557. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51558. /**
  51559. * Remove a specific drag gradient
  51560. * @param gradient defines the gradient to remove
  51561. * @returns the current particle system
  51562. */
  51563. removeDragGradient(gradient: number): GPUParticleSystem;
  51564. /**
  51565. * Not supported by GPUParticleSystem
  51566. * @param gradient defines the gradient to use (between 0 and 1)
  51567. * @param factor defines the emit rate value to affect to the specified gradient
  51568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51569. * @returns the current particle system
  51570. */
  51571. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51572. /**
  51573. * Not supported by GPUParticleSystem
  51574. * @param gradient defines the gradient to remove
  51575. * @returns the current particle system
  51576. */
  51577. removeEmitRateGradient(gradient: number): IParticleSystem;
  51578. /**
  51579. * Not supported by GPUParticleSystem
  51580. * @param gradient defines the gradient to use (between 0 and 1)
  51581. * @param factor defines the start size value to affect to the specified gradient
  51582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51583. * @returns the current particle system
  51584. */
  51585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51586. /**
  51587. * Not supported by GPUParticleSystem
  51588. * @param gradient defines the gradient to remove
  51589. * @returns the current particle system
  51590. */
  51591. removeStartSizeGradient(gradient: number): IParticleSystem;
  51592. /**
  51593. * Not supported by GPUParticleSystem
  51594. * @param gradient defines the gradient to use (between 0 and 1)
  51595. * @param min defines the color remap minimal range
  51596. * @param max defines the color remap maximal range
  51597. * @returns the current particle system
  51598. */
  51599. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51600. /**
  51601. * Not supported by GPUParticleSystem
  51602. * @param gradient defines the gradient to remove
  51603. * @returns the current particle system
  51604. */
  51605. removeColorRemapGradient(): IParticleSystem;
  51606. /**
  51607. * Not supported by GPUParticleSystem
  51608. * @param gradient defines the gradient to use (between 0 and 1)
  51609. * @param min defines the alpha remap minimal range
  51610. * @param max defines the alpha remap maximal range
  51611. * @returns the current particle system
  51612. */
  51613. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51614. /**
  51615. * Not supported by GPUParticleSystem
  51616. * @param gradient defines the gradient to remove
  51617. * @returns the current particle system
  51618. */
  51619. removeAlphaRemapGradient(): IParticleSystem;
  51620. /**
  51621. * Not supported by GPUParticleSystem
  51622. * @param gradient defines the gradient to use (between 0 and 1)
  51623. * @param color defines the color to affect to the specified gradient
  51624. * @returns the current particle system
  51625. */
  51626. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51627. /**
  51628. * Not supported by GPUParticleSystem
  51629. * @param gradient defines the gradient to remove
  51630. * @returns the current particle system
  51631. */
  51632. removeRampGradient(): IParticleSystem;
  51633. /**
  51634. * Not supported by GPUParticleSystem
  51635. * @returns the list of ramp gradients
  51636. */
  51637. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51638. /**
  51639. * Not supported by GPUParticleSystem
  51640. * Gets or sets a boolean indicating that ramp gradients must be used
  51641. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51642. */
  51643. useRampGradients: boolean;
  51644. /**
  51645. * Not supported by GPUParticleSystem
  51646. * @param gradient defines the gradient to use (between 0 and 1)
  51647. * @param factor defines the life time factor to affect to the specified gradient
  51648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51649. * @returns the current particle system
  51650. */
  51651. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51652. /**
  51653. * Not supported by GPUParticleSystem
  51654. * @param gradient defines the gradient to remove
  51655. * @returns the current particle system
  51656. */
  51657. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51658. /**
  51659. * Instantiates a GPU particle system.
  51660. * 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.
  51661. * @param name The name of the particle system
  51662. * @param options The options used to create the system
  51663. * @param scene The scene the particle system belongs to
  51664. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51665. */
  51666. constructor(name: string, options: Partial<{
  51667. capacity: number;
  51668. randomTextureSize: number;
  51669. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51670. protected _reset(): void;
  51671. private _createUpdateVAO;
  51672. private _createRenderVAO;
  51673. private _initialize;
  51674. /** @hidden */
  51675. _recreateUpdateEffect(): void;
  51676. /** @hidden */
  51677. _recreateRenderEffect(): void;
  51678. /**
  51679. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51680. * @param preWarm defines if we are in the pre-warmimg phase
  51681. */
  51682. animate(preWarm?: boolean): void;
  51683. private _createFactorGradientTexture;
  51684. private _createSizeGradientTexture;
  51685. private _createAngularSpeedGradientTexture;
  51686. private _createVelocityGradientTexture;
  51687. private _createLimitVelocityGradientTexture;
  51688. private _createDragGradientTexture;
  51689. private _createColorGradientTexture;
  51690. /**
  51691. * Renders the particle system in its current state
  51692. * @param preWarm defines if the system should only update the particles but not render them
  51693. * @returns the current number of particles
  51694. */
  51695. render(preWarm?: boolean): number;
  51696. /**
  51697. * Rebuilds the particle system
  51698. */
  51699. rebuild(): void;
  51700. private _releaseBuffers;
  51701. private _releaseVAOs;
  51702. /**
  51703. * Disposes the particle system and free the associated resources
  51704. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51705. */
  51706. dispose(disposeTexture?: boolean): void;
  51707. /**
  51708. * Clones the particle system.
  51709. * @param name The name of the cloned object
  51710. * @param newEmitter The new emitter to use
  51711. * @returns the cloned particle system
  51712. */
  51713. clone(name: string, newEmitter: any): GPUParticleSystem;
  51714. /**
  51715. * Serializes the particle system to a JSON object.
  51716. * @returns the JSON object
  51717. */
  51718. serialize(): any;
  51719. /**
  51720. * Parses a JSON object to create a GPU particle system.
  51721. * @param parsedParticleSystem The JSON object to parse
  51722. * @param scene The scene to create the particle system in
  51723. * @param rootUrl The root url to use to load external dependencies like texture
  51724. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51725. * @returns the parsed GPU particle system
  51726. */
  51727. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51728. }
  51729. }
  51730. declare module "babylonjs/Particles/particleSystemSet" {
  51731. import { Nullable } from "babylonjs/types";
  51732. import { Color3 } from "babylonjs/Maths/math";
  51733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51735. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51736. import { Scene, IDisposable } from "babylonjs/scene";
  51737. /**
  51738. * Represents a set of particle systems working together to create a specific effect
  51739. */
  51740. export class ParticleSystemSet implements IDisposable {
  51741. private _emitterCreationOptions;
  51742. private _emitterNode;
  51743. /**
  51744. * Gets the particle system list
  51745. */
  51746. systems: IParticleSystem[];
  51747. /**
  51748. * Gets the emitter node used with this set
  51749. */
  51750. readonly emitterNode: Nullable<TransformNode>;
  51751. /**
  51752. * Creates a new emitter mesh as a sphere
  51753. * @param options defines the options used to create the sphere
  51754. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51755. * @param scene defines the hosting scene
  51756. */
  51757. setEmitterAsSphere(options: {
  51758. diameter: number;
  51759. segments: number;
  51760. color: Color3;
  51761. }, renderingGroupId: number, scene: Scene): void;
  51762. /**
  51763. * Starts all particle systems of the set
  51764. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51765. */
  51766. start(emitter?: AbstractMesh): void;
  51767. /**
  51768. * Release all associated resources
  51769. */
  51770. dispose(): void;
  51771. /**
  51772. * Serialize the set into a JSON compatible object
  51773. * @returns a JSON compatible representation of the set
  51774. */
  51775. serialize(): any;
  51776. /**
  51777. * Parse a new ParticleSystemSet from a serialized source
  51778. * @param data defines a JSON compatible representation of the set
  51779. * @param scene defines the hosting scene
  51780. * @param gpu defines if we want GPU particles or CPU particles
  51781. * @returns a new ParticleSystemSet
  51782. */
  51783. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51784. }
  51785. }
  51786. declare module "babylonjs/Particles/particleHelper" {
  51787. import { Nullable } from "babylonjs/types";
  51788. import { Scene } from "babylonjs/scene";
  51789. import { Vector3 } from "babylonjs/Maths/math";
  51790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51791. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51792. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51793. /**
  51794. * This class is made for on one-liner static method to help creating particle system set.
  51795. */
  51796. export class ParticleHelper {
  51797. /**
  51798. * Gets or sets base Assets URL
  51799. */
  51800. static BaseAssetsUrl: string;
  51801. /**
  51802. * Create a default particle system that you can tweak
  51803. * @param emitter defines the emitter to use
  51804. * @param capacity defines the system capacity (default is 500 particles)
  51805. * @param scene defines the hosting scene
  51806. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51807. * @returns the new Particle system
  51808. */
  51809. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51810. /**
  51811. * This is the main static method (one-liner) of this helper to create different particle systems
  51812. * @param type This string represents the type to the particle system to create
  51813. * @param scene The scene where the particle system should live
  51814. * @param gpu If the system will use gpu
  51815. * @returns the ParticleSystemSet created
  51816. */
  51817. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51818. /**
  51819. * Static function used to export a particle system to a ParticleSystemSet variable.
  51820. * Please note that the emitter shape is not exported
  51821. * @param systems defines the particle systems to export
  51822. * @returns the created particle system set
  51823. */
  51824. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51825. }
  51826. }
  51827. declare module "babylonjs/Particles/particleSystemComponent" {
  51828. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51829. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51830. import "babylonjs/Shaders/particles.vertex";
  51831. module "babylonjs/Engines/engine" {
  51832. interface Engine {
  51833. /**
  51834. * Create an effect to use with particle systems.
  51835. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51836. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51837. * @param uniformsNames defines a list of attribute names
  51838. * @param samplers defines an array of string used to represent textures
  51839. * @param defines defines the string containing the defines to use to compile the shaders
  51840. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51841. * @param onCompiled defines a function to call when the effect creation is successful
  51842. * @param onError defines a function to call when the effect creation has failed
  51843. * @returns the new Effect
  51844. */
  51845. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51846. }
  51847. }
  51848. module "babylonjs/Meshes/mesh" {
  51849. interface Mesh {
  51850. /**
  51851. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51852. * @returns an array of IParticleSystem
  51853. */
  51854. getEmittedParticleSystems(): IParticleSystem[];
  51855. /**
  51856. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51857. * @returns an array of IParticleSystem
  51858. */
  51859. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51860. }
  51861. }
  51862. /**
  51863. * @hidden
  51864. */
  51865. export var _IDoNeedToBeInTheBuild: number;
  51866. }
  51867. declare module "babylonjs/Particles/index" {
  51868. export * from "babylonjs/Particles/baseParticleSystem";
  51869. export * from "babylonjs/Particles/EmitterTypes/index";
  51870. export * from "babylonjs/Particles/gpuParticleSystem";
  51871. export * from "babylonjs/Particles/IParticleSystem";
  51872. export * from "babylonjs/Particles/particle";
  51873. export * from "babylonjs/Particles/particleHelper";
  51874. export * from "babylonjs/Particles/particleSystem";
  51875. export * from "babylonjs/Particles/particleSystemComponent";
  51876. export * from "babylonjs/Particles/particleSystemSet";
  51877. export * from "babylonjs/Particles/solidParticle";
  51878. export * from "babylonjs/Particles/solidParticleSystem";
  51879. export * from "babylonjs/Particles/subEmitter";
  51880. }
  51881. declare module "babylonjs/Physics/physicsEngineComponent" {
  51882. import { Nullable } from "babylonjs/types";
  51883. import { Observable, Observer } from "babylonjs/Misc/observable";
  51884. import { Vector3 } from "babylonjs/Maths/math";
  51885. import { Mesh } from "babylonjs/Meshes/mesh";
  51886. import { ISceneComponent } from "babylonjs/sceneComponent";
  51887. import { Scene } from "babylonjs/scene";
  51888. import { Node } from "babylonjs/node";
  51889. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51890. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51891. module "babylonjs/scene" {
  51892. interface Scene {
  51893. /** @hidden (Backing field) */
  51894. _physicsEngine: Nullable<IPhysicsEngine>;
  51895. /**
  51896. * Gets the current physics engine
  51897. * @returns a IPhysicsEngine or null if none attached
  51898. */
  51899. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51900. /**
  51901. * Enables physics to the current scene
  51902. * @param gravity defines the scene's gravity for the physics engine
  51903. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51904. * @return a boolean indicating if the physics engine was initialized
  51905. */
  51906. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51907. /**
  51908. * Disables and disposes the physics engine associated with the scene
  51909. */
  51910. disablePhysicsEngine(): void;
  51911. /**
  51912. * Gets a boolean indicating if there is an active physics engine
  51913. * @returns a boolean indicating if there is an active physics engine
  51914. */
  51915. isPhysicsEnabled(): boolean;
  51916. /**
  51917. * Deletes a physics compound impostor
  51918. * @param compound defines the compound to delete
  51919. */
  51920. deleteCompoundImpostor(compound: any): void;
  51921. /**
  51922. * An event triggered when physic simulation is about to be run
  51923. */
  51924. onBeforePhysicsObservable: Observable<Scene>;
  51925. /**
  51926. * An event triggered when physic simulation has been done
  51927. */
  51928. onAfterPhysicsObservable: Observable<Scene>;
  51929. }
  51930. }
  51931. module "babylonjs/Meshes/abstractMesh" {
  51932. interface AbstractMesh {
  51933. /** @hidden */
  51934. _physicsImpostor: Nullable<PhysicsImpostor>;
  51935. /**
  51936. * Gets or sets impostor used for physic simulation
  51937. * @see http://doc.babylonjs.com/features/physics_engine
  51938. */
  51939. physicsImpostor: Nullable<PhysicsImpostor>;
  51940. /**
  51941. * Gets the current physics impostor
  51942. * @see http://doc.babylonjs.com/features/physics_engine
  51943. * @returns a physics impostor or null
  51944. */
  51945. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51946. /** Apply a physic impulse to the mesh
  51947. * @param force defines the force to apply
  51948. * @param contactPoint defines where to apply the force
  51949. * @returns the current mesh
  51950. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51951. */
  51952. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51953. /**
  51954. * Creates a physic joint between two meshes
  51955. * @param otherMesh defines the other mesh to use
  51956. * @param pivot1 defines the pivot to use on this mesh
  51957. * @param pivot2 defines the pivot to use on the other mesh
  51958. * @param options defines additional options (can be plugin dependent)
  51959. * @returns the current mesh
  51960. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51961. */
  51962. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51963. /** @hidden */
  51964. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51965. }
  51966. }
  51967. /**
  51968. * Defines the physics engine scene component responsible to manage a physics engine
  51969. */
  51970. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51971. /**
  51972. * The component name helpful to identify the component in the list of scene components.
  51973. */
  51974. readonly name: string;
  51975. /**
  51976. * The scene the component belongs to.
  51977. */
  51978. scene: Scene;
  51979. /**
  51980. * Creates a new instance of the component for the given scene
  51981. * @param scene Defines the scene to register the component in
  51982. */
  51983. constructor(scene: Scene);
  51984. /**
  51985. * Registers the component in a given scene
  51986. */
  51987. register(): void;
  51988. /**
  51989. * Rebuilds the elements related to this component in case of
  51990. * context lost for instance.
  51991. */
  51992. rebuild(): void;
  51993. /**
  51994. * Disposes the component and the associated ressources
  51995. */
  51996. dispose(): void;
  51997. }
  51998. }
  51999. declare module "babylonjs/Physics/physicsHelper" {
  52000. import { Nullable } from "babylonjs/types";
  52001. import { Vector3 } from "babylonjs/Maths/math";
  52002. import { Mesh } from "babylonjs/Meshes/mesh";
  52003. import { Ray } from "babylonjs/Culling/ray";
  52004. import { Scene } from "babylonjs/scene";
  52005. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52006. /**
  52007. * A helper for physics simulations
  52008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52009. */
  52010. export class PhysicsHelper {
  52011. private _scene;
  52012. private _physicsEngine;
  52013. /**
  52014. * Initializes the Physics helper
  52015. * @param scene Babylon.js scene
  52016. */
  52017. constructor(scene: Scene);
  52018. /**
  52019. * Applies a radial explosion impulse
  52020. * @param origin the origin of the explosion
  52021. * @param radius the explosion radius
  52022. * @param strength the explosion strength
  52023. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52024. * @returns A physics radial explosion event, or null
  52025. */
  52026. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52027. /**
  52028. * Applies a radial explosion force
  52029. * @param origin the origin of the explosion
  52030. * @param radius the explosion radius
  52031. * @param strength the explosion strength
  52032. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52033. * @returns A physics radial explosion event, or null
  52034. */
  52035. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52036. /**
  52037. * Creates a gravitational field
  52038. * @param origin the origin of the explosion
  52039. * @param radius the explosion radius
  52040. * @param strength the explosion strength
  52041. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52042. * @returns A physics gravitational field event, or null
  52043. */
  52044. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52045. /**
  52046. * Creates a physics updraft event
  52047. * @param origin the origin of the updraft
  52048. * @param radius the radius of the updraft
  52049. * @param strength the strength of the updraft
  52050. * @param height the height of the updraft
  52051. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52052. * @returns A physics updraft event, or null
  52053. */
  52054. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52055. /**
  52056. * Creates a physics vortex event
  52057. * @param origin the of the vortex
  52058. * @param radius the radius of the vortex
  52059. * @param strength the strength of the vortex
  52060. * @param height the height of the vortex
  52061. * @returns a Physics vortex event, or null
  52062. * A physics vortex event or null
  52063. */
  52064. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52065. }
  52066. /**
  52067. * Represents a physics radial explosion event
  52068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52069. */
  52070. export class PhysicsRadialExplosionEvent {
  52071. private _scene;
  52072. private _sphere;
  52073. private _sphereOptions;
  52074. private _rays;
  52075. private _dataFetched;
  52076. /**
  52077. * Initializes a radial explosioin event
  52078. * @param scene BabylonJS scene
  52079. */
  52080. constructor(scene: Scene);
  52081. /**
  52082. * Returns the data related to the radial explosion event (sphere & rays).
  52083. * @returns The radial explosion event data
  52084. */
  52085. getData(): PhysicsRadialExplosionEventData;
  52086. /**
  52087. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52088. * @param impostor A physics imposter
  52089. * @param origin the origin of the explosion
  52090. * @param radius the explosion radius
  52091. * @param strength the explosion strength
  52092. * @param falloff possible options: Constant & Linear
  52093. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52094. */
  52095. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52096. /**
  52097. * Disposes the sphere.
  52098. * @param force Specifies if the sphere should be disposed by force
  52099. */
  52100. dispose(force?: boolean): void;
  52101. /*** Helpers ***/
  52102. private _prepareSphere;
  52103. private _intersectsWithSphere;
  52104. }
  52105. /**
  52106. * Represents a gravitational field event
  52107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52108. */
  52109. export class PhysicsGravitationalFieldEvent {
  52110. private _physicsHelper;
  52111. private _scene;
  52112. private _origin;
  52113. private _radius;
  52114. private _strength;
  52115. private _falloff;
  52116. private _tickCallback;
  52117. private _sphere;
  52118. private _dataFetched;
  52119. /**
  52120. * Initializes the physics gravitational field event
  52121. * @param physicsHelper A physics helper
  52122. * @param scene BabylonJS scene
  52123. * @param origin The origin position of the gravitational field event
  52124. * @param radius The radius of the gravitational field event
  52125. * @param strength The strength of the gravitational field event
  52126. * @param falloff The falloff for the gravitational field event
  52127. */
  52128. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52129. /**
  52130. * Returns the data related to the gravitational field event (sphere).
  52131. * @returns A gravitational field event
  52132. */
  52133. getData(): PhysicsGravitationalFieldEventData;
  52134. /**
  52135. * Enables the gravitational field.
  52136. */
  52137. enable(): void;
  52138. /**
  52139. * Disables the gravitational field.
  52140. */
  52141. disable(): void;
  52142. /**
  52143. * Disposes the sphere.
  52144. * @param force The force to dispose from the gravitational field event
  52145. */
  52146. dispose(force?: boolean): void;
  52147. private _tick;
  52148. }
  52149. /**
  52150. * Represents a physics updraft event
  52151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52152. */
  52153. export class PhysicsUpdraftEvent {
  52154. private _scene;
  52155. private _origin;
  52156. private _radius;
  52157. private _strength;
  52158. private _height;
  52159. private _updraftMode;
  52160. private _physicsEngine;
  52161. private _originTop;
  52162. private _originDirection;
  52163. private _tickCallback;
  52164. private _cylinder;
  52165. private _cylinderPosition;
  52166. private _dataFetched;
  52167. /**
  52168. * Initializes the physics updraft event
  52169. * @param _scene BabylonJS scene
  52170. * @param _origin The origin position of the updraft
  52171. * @param _radius The radius of the updraft
  52172. * @param _strength The strength of the updraft
  52173. * @param _height The height of the updraft
  52174. * @param _updraftMode The mode of the updraft
  52175. */
  52176. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52177. /**
  52178. * Returns the data related to the updraft event (cylinder).
  52179. * @returns A physics updraft event
  52180. */
  52181. getData(): PhysicsUpdraftEventData;
  52182. /**
  52183. * Enables the updraft.
  52184. */
  52185. enable(): void;
  52186. /**
  52187. * Disables the cortex.
  52188. */
  52189. disable(): void;
  52190. /**
  52191. * Disposes the sphere.
  52192. * @param force Specifies if the updraft should be disposed by force
  52193. */
  52194. dispose(force?: boolean): void;
  52195. private getImpostorForceAndContactPoint;
  52196. private _tick;
  52197. /*** Helpers ***/
  52198. private _prepareCylinder;
  52199. private _intersectsWithCylinder;
  52200. }
  52201. /**
  52202. * Represents a physics vortex event
  52203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52204. */
  52205. export class PhysicsVortexEvent {
  52206. private _scene;
  52207. private _origin;
  52208. private _radius;
  52209. private _strength;
  52210. private _height;
  52211. private _physicsEngine;
  52212. private _originTop;
  52213. private _centripetalForceThreshold;
  52214. private _updraftMultiplier;
  52215. private _tickCallback;
  52216. private _cylinder;
  52217. private _cylinderPosition;
  52218. private _dataFetched;
  52219. /**
  52220. * Initializes the physics vortex event
  52221. * @param _scene The BabylonJS scene
  52222. * @param _origin The origin position of the vortex
  52223. * @param _radius The radius of the vortex
  52224. * @param _strength The strength of the vortex
  52225. * @param _height The height of the vortex
  52226. */
  52227. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52228. /**
  52229. * Returns the data related to the vortex event (cylinder).
  52230. * @returns The physics vortex event data
  52231. */
  52232. getData(): PhysicsVortexEventData;
  52233. /**
  52234. * Enables the vortex.
  52235. */
  52236. enable(): void;
  52237. /**
  52238. * Disables the cortex.
  52239. */
  52240. disable(): void;
  52241. /**
  52242. * Disposes the sphere.
  52243. * @param force
  52244. */
  52245. dispose(force?: boolean): void;
  52246. private getImpostorForceAndContactPoint;
  52247. private _tick;
  52248. /*** Helpers ***/
  52249. private _prepareCylinder;
  52250. private _intersectsWithCylinder;
  52251. }
  52252. /**
  52253. * The strenght of the force in correspondence to the distance of the affected object
  52254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52255. */
  52256. export enum PhysicsRadialImpulseFalloff {
  52257. /** Defines that impulse is constant in strength across it's whole radius */
  52258. Constant = 0,
  52259. /** DEfines that impulse gets weaker if it's further from the origin */
  52260. Linear = 1
  52261. }
  52262. /**
  52263. * The strength of the force in correspondence to the distance of the affected object
  52264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52265. */
  52266. export enum PhysicsUpdraftMode {
  52267. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52268. Center = 0,
  52269. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52270. Perpendicular = 1
  52271. }
  52272. /**
  52273. * Interface for a physics force and contact point
  52274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52275. */
  52276. export interface PhysicsForceAndContactPoint {
  52277. /**
  52278. * The force applied at the contact point
  52279. */
  52280. force: Vector3;
  52281. /**
  52282. * The contact point
  52283. */
  52284. contactPoint: Vector3;
  52285. }
  52286. /**
  52287. * Interface for radial explosion event data
  52288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52289. */
  52290. export interface PhysicsRadialExplosionEventData {
  52291. /**
  52292. * A sphere used for the radial explosion event
  52293. */
  52294. sphere: Mesh;
  52295. /**
  52296. * An array of rays for the radial explosion event
  52297. */
  52298. rays: Array<Ray>;
  52299. }
  52300. /**
  52301. * Interface for gravitational field event data
  52302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52303. */
  52304. export interface PhysicsGravitationalFieldEventData {
  52305. /**
  52306. * A sphere mesh used for the gravitational field event
  52307. */
  52308. sphere: Mesh;
  52309. }
  52310. /**
  52311. * Interface for updraft event data
  52312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52313. */
  52314. export interface PhysicsUpdraftEventData {
  52315. /**
  52316. * A cylinder used for the updraft event
  52317. */
  52318. cylinder: Mesh;
  52319. }
  52320. /**
  52321. * Interface for vortex event data
  52322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52323. */
  52324. export interface PhysicsVortexEventData {
  52325. /**
  52326. * A cylinder used for the vortex event
  52327. */
  52328. cylinder: Mesh;
  52329. }
  52330. }
  52331. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52332. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52333. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52334. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52335. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52336. import { Nullable } from "babylonjs/types";
  52337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52338. /**
  52339. * AmmoJS Physics plugin
  52340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52341. * @see https://github.com/kripken/ammo.js/
  52342. */
  52343. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52344. private _useDeltaForWorldStep;
  52345. /**
  52346. * Reference to the Ammo library
  52347. */
  52348. bjsAMMO: any;
  52349. /**
  52350. * Created ammoJS world which physics bodies are added to
  52351. */
  52352. world: any;
  52353. /**
  52354. * Name of the plugin
  52355. */
  52356. name: string;
  52357. private _timeStep;
  52358. private _fixedTimeStep;
  52359. private _maxSteps;
  52360. private _tmpQuaternion;
  52361. private _tmpAmmoTransform;
  52362. private _tmpAmmoQuaternion;
  52363. private _tmpAmmoConcreteContactResultCallback;
  52364. private _collisionConfiguration;
  52365. private _dispatcher;
  52366. private _overlappingPairCache;
  52367. private _solver;
  52368. private _tmpAmmoVectorA;
  52369. private _tmpAmmoVectorB;
  52370. private _tmpAmmoVectorC;
  52371. private _tmpContactCallbackResult;
  52372. private static readonly DISABLE_COLLISION_FLAG;
  52373. private static readonly KINEMATIC_FLAG;
  52374. private static readonly DISABLE_DEACTIVATION_FLAG;
  52375. /**
  52376. * Initializes the ammoJS plugin
  52377. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52378. * @param ammoInjection can be used to inject your own ammo reference
  52379. */
  52380. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52381. /**
  52382. * Sets the gravity of the physics world (m/(s^2))
  52383. * @param gravity Gravity to set
  52384. */
  52385. setGravity(gravity: Vector3): void;
  52386. /**
  52387. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52388. * @param timeStep timestep to use in seconds
  52389. */
  52390. setTimeStep(timeStep: number): void;
  52391. /**
  52392. * 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)
  52393. * @param fixedTimeStep fixedTimeStep to use in seconds
  52394. */
  52395. setFixedTimeStep(fixedTimeStep: number): void;
  52396. /**
  52397. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52398. * @param maxSteps the maximum number of steps by the physics engine per frame
  52399. */
  52400. setMaxSteps(maxSteps: number): void;
  52401. /**
  52402. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52403. * @returns the current timestep in seconds
  52404. */
  52405. getTimeStep(): number;
  52406. private _isImpostorInContact;
  52407. private _isImpostorPairInContact;
  52408. private _stepSimulation;
  52409. /**
  52410. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52411. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52412. * After the step the babylon meshes are set to the position of the physics imposters
  52413. * @param delta amount of time to step forward
  52414. * @param impostors array of imposters to update before/after the step
  52415. */
  52416. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52417. private _tmpVector;
  52418. private _tmpMatrix;
  52419. /**
  52420. * Applies an implulse on the imposter
  52421. * @param impostor imposter to apply impulse
  52422. * @param force amount of force to be applied to the imposter
  52423. * @param contactPoint the location to apply the impulse on the imposter
  52424. */
  52425. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52426. /**
  52427. * Applies a force on the imposter
  52428. * @param impostor imposter to apply force
  52429. * @param force amount of force to be applied to the imposter
  52430. * @param contactPoint the location to apply the force on the imposter
  52431. */
  52432. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52433. /**
  52434. * Creates a physics body using the plugin
  52435. * @param impostor the imposter to create the physics body on
  52436. */
  52437. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52438. /**
  52439. * Removes the physics body from the imposter and disposes of the body's memory
  52440. * @param impostor imposter to remove the physics body from
  52441. */
  52442. removePhysicsBody(impostor: PhysicsImpostor): void;
  52443. /**
  52444. * Generates a joint
  52445. * @param impostorJoint the imposter joint to create the joint with
  52446. */
  52447. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52448. /**
  52449. * Removes a joint
  52450. * @param impostorJoint the imposter joint to remove the joint from
  52451. */
  52452. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52453. private _addMeshVerts;
  52454. private _createShape;
  52455. /**
  52456. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52457. * @param impostor imposter containing the physics body and babylon object
  52458. */
  52459. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52460. /**
  52461. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52462. * @param impostor imposter containing the physics body and babylon object
  52463. * @param newPosition new position
  52464. * @param newRotation new rotation
  52465. */
  52466. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52467. /**
  52468. * If this plugin is supported
  52469. * @returns true if its supported
  52470. */
  52471. isSupported(): boolean;
  52472. /**
  52473. * Sets the linear velocity of the physics body
  52474. * @param impostor imposter to set the velocity on
  52475. * @param velocity velocity to set
  52476. */
  52477. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52478. /**
  52479. * Sets the angular velocity of the physics body
  52480. * @param impostor imposter to set the velocity on
  52481. * @param velocity velocity to set
  52482. */
  52483. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52484. /**
  52485. * gets the linear velocity
  52486. * @param impostor imposter to get linear velocity from
  52487. * @returns linear velocity
  52488. */
  52489. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52490. /**
  52491. * gets the angular velocity
  52492. * @param impostor imposter to get angular velocity from
  52493. * @returns angular velocity
  52494. */
  52495. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52496. /**
  52497. * Sets the mass of physics body
  52498. * @param impostor imposter to set the mass on
  52499. * @param mass mass to set
  52500. */
  52501. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52502. /**
  52503. * Gets the mass of the physics body
  52504. * @param impostor imposter to get the mass from
  52505. * @returns mass
  52506. */
  52507. getBodyMass(impostor: PhysicsImpostor): number;
  52508. /**
  52509. * Gets friction of the impostor
  52510. * @param impostor impostor to get friction from
  52511. * @returns friction value
  52512. */
  52513. getBodyFriction(impostor: PhysicsImpostor): number;
  52514. /**
  52515. * Sets friction of the impostor
  52516. * @param impostor impostor to set friction on
  52517. * @param friction friction value
  52518. */
  52519. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52520. /**
  52521. * Gets restitution of the impostor
  52522. * @param impostor impostor to get restitution from
  52523. * @returns restitution value
  52524. */
  52525. getBodyRestitution(impostor: PhysicsImpostor): number;
  52526. /**
  52527. * Sets resitution of the impostor
  52528. * @param impostor impostor to set resitution on
  52529. * @param restitution resitution value
  52530. */
  52531. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52532. /**
  52533. * Sleeps the physics body and stops it from being active
  52534. * @param impostor impostor to sleep
  52535. */
  52536. sleepBody(impostor: PhysicsImpostor): void;
  52537. /**
  52538. * Activates the physics body
  52539. * @param impostor impostor to activate
  52540. */
  52541. wakeUpBody(impostor: PhysicsImpostor): void;
  52542. /**
  52543. * Updates the distance parameters of the joint
  52544. * @param joint joint to update
  52545. * @param maxDistance maximum distance of the joint
  52546. * @param minDistance minimum distance of the joint
  52547. */
  52548. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52549. /**
  52550. * Sets a motor on the joint
  52551. * @param joint joint to set motor on
  52552. * @param speed speed of the motor
  52553. * @param maxForce maximum force of the motor
  52554. * @param motorIndex index of the motor
  52555. */
  52556. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52557. /**
  52558. * Sets the motors limit
  52559. * @param joint joint to set limit on
  52560. * @param upperLimit upper limit
  52561. * @param lowerLimit lower limit
  52562. */
  52563. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52564. /**
  52565. * Syncs the position and rotation of a mesh with the impostor
  52566. * @param mesh mesh to sync
  52567. * @param impostor impostor to update the mesh with
  52568. */
  52569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52570. /**
  52571. * Gets the radius of the impostor
  52572. * @param impostor impostor to get radius from
  52573. * @returns the radius
  52574. */
  52575. getRadius(impostor: PhysicsImpostor): number;
  52576. /**
  52577. * Gets the box size of the impostor
  52578. * @param impostor impostor to get box size from
  52579. * @param result the resulting box size
  52580. */
  52581. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52582. /**
  52583. * Disposes of the impostor
  52584. */
  52585. dispose(): void;
  52586. }
  52587. }
  52588. declare module "babylonjs/Physics/Plugins/index" {
  52589. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52590. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52591. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52592. }
  52593. declare module "babylonjs/Physics/index" {
  52594. export * from "babylonjs/Physics/IPhysicsEngine";
  52595. export * from "babylonjs/Physics/physicsEngine";
  52596. export * from "babylonjs/Physics/physicsEngineComponent";
  52597. export * from "babylonjs/Physics/physicsHelper";
  52598. export * from "babylonjs/Physics/physicsImpostor";
  52599. export * from "babylonjs/Physics/physicsJoint";
  52600. export * from "babylonjs/Physics/Plugins/index";
  52601. }
  52602. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52603. /** @hidden */
  52604. export var blackAndWhitePixelShader: {
  52605. name: string;
  52606. shader: string;
  52607. };
  52608. }
  52609. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52611. import { Camera } from "babylonjs/Cameras/camera";
  52612. import { Engine } from "babylonjs/Engines/engine";
  52613. import "babylonjs/Shaders/blackAndWhite.fragment";
  52614. /**
  52615. * Post process used to render in black and white
  52616. */
  52617. export class BlackAndWhitePostProcess extends PostProcess {
  52618. /**
  52619. * Linear about to convert he result to black and white (default: 1)
  52620. */
  52621. degree: number;
  52622. /**
  52623. * Creates a black and white post process
  52624. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52625. * @param name The name of the effect.
  52626. * @param options The required width/height ratio to downsize to before computing the render pass.
  52627. * @param camera The camera to apply the render pass to.
  52628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52629. * @param engine The engine which the post process will be applied. (default: current engine)
  52630. * @param reusable If the post process can be reused on the same frame. (default: false)
  52631. */
  52632. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52633. }
  52634. }
  52635. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52636. import { Nullable } from "babylonjs/types";
  52637. import { Camera } from "babylonjs/Cameras/camera";
  52638. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52639. import { Engine } from "babylonjs/Engines/engine";
  52640. /**
  52641. * This represents a set of one or more post processes in Babylon.
  52642. * A post process can be used to apply a shader to a texture after it is rendered.
  52643. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52644. */
  52645. export class PostProcessRenderEffect {
  52646. private _postProcesses;
  52647. private _getPostProcesses;
  52648. private _singleInstance;
  52649. private _cameras;
  52650. private _indicesForCamera;
  52651. /**
  52652. * Name of the effect
  52653. * @hidden
  52654. */
  52655. _name: string;
  52656. /**
  52657. * Instantiates a post process render effect.
  52658. * A post process can be used to apply a shader to a texture after it is rendered.
  52659. * @param engine The engine the effect is tied to
  52660. * @param name The name of the effect
  52661. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52662. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52663. */
  52664. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52665. /**
  52666. * Checks if all the post processes in the effect are supported.
  52667. */
  52668. readonly isSupported: boolean;
  52669. /**
  52670. * Updates the current state of the effect
  52671. * @hidden
  52672. */
  52673. _update(): void;
  52674. /**
  52675. * Attaches the effect on cameras
  52676. * @param cameras The camera to attach to.
  52677. * @hidden
  52678. */
  52679. _attachCameras(cameras: Camera): void;
  52680. /**
  52681. * Attaches the effect on cameras
  52682. * @param cameras The camera to attach to.
  52683. * @hidden
  52684. */
  52685. _attachCameras(cameras: Camera[]): void;
  52686. /**
  52687. * Detatches the effect on cameras
  52688. * @param cameras The camera to detatch from.
  52689. * @hidden
  52690. */
  52691. _detachCameras(cameras: Camera): void;
  52692. /**
  52693. * Detatches the effect on cameras
  52694. * @param cameras The camera to detatch from.
  52695. * @hidden
  52696. */
  52697. _detachCameras(cameras: Camera[]): void;
  52698. /**
  52699. * Enables the effect on given cameras
  52700. * @param cameras The camera to enable.
  52701. * @hidden
  52702. */
  52703. _enable(cameras: Camera): void;
  52704. /**
  52705. * Enables the effect on given cameras
  52706. * @param cameras The camera to enable.
  52707. * @hidden
  52708. */
  52709. _enable(cameras: Nullable<Camera[]>): void;
  52710. /**
  52711. * Disables the effect on the given cameras
  52712. * @param cameras The camera to disable.
  52713. * @hidden
  52714. */
  52715. _disable(cameras: Camera): void;
  52716. /**
  52717. * Disables the effect on the given cameras
  52718. * @param cameras The camera to disable.
  52719. * @hidden
  52720. */
  52721. _disable(cameras: Nullable<Camera[]>): void;
  52722. /**
  52723. * Gets a list of the post processes contained in the effect.
  52724. * @param camera The camera to get the post processes on.
  52725. * @returns The list of the post processes in the effect.
  52726. */
  52727. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52728. }
  52729. }
  52730. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52731. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52732. /** @hidden */
  52733. export var extractHighlightsPixelShader: {
  52734. name: string;
  52735. shader: string;
  52736. };
  52737. }
  52738. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52739. import { Nullable } from "babylonjs/types";
  52740. import { Camera } from "babylonjs/Cameras/camera";
  52741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52742. import { Engine } from "babylonjs/Engines/engine";
  52743. import "babylonjs/Shaders/extractHighlights.fragment";
  52744. /**
  52745. * 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.
  52746. */
  52747. export class ExtractHighlightsPostProcess extends PostProcess {
  52748. /**
  52749. * The luminance threshold, pixels below this value will be set to black.
  52750. */
  52751. threshold: number;
  52752. /** @hidden */
  52753. _exposure: number;
  52754. /**
  52755. * Post process which has the input texture to be used when performing highlight extraction
  52756. * @hidden
  52757. */
  52758. _inputPostProcess: Nullable<PostProcess>;
  52759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52760. }
  52761. }
  52762. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52763. /** @hidden */
  52764. export var bloomMergePixelShader: {
  52765. name: string;
  52766. shader: string;
  52767. };
  52768. }
  52769. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52770. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52771. import { Nullable } from "babylonjs/types";
  52772. import { Engine } from "babylonjs/Engines/engine";
  52773. import { Camera } from "babylonjs/Cameras/camera";
  52774. import "babylonjs/Shaders/bloomMerge.fragment";
  52775. /**
  52776. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52777. */
  52778. export class BloomMergePostProcess extends PostProcess {
  52779. /** Weight of the bloom to be added to the original input. */
  52780. weight: number;
  52781. /**
  52782. * Creates a new instance of @see BloomMergePostProcess
  52783. * @param name The name of the effect.
  52784. * @param originalFromInput Post process which's input will be used for the merge.
  52785. * @param blurred Blurred highlights post process which's output will be used.
  52786. * @param weight Weight of the bloom to be added to the original input.
  52787. * @param options The required width/height ratio to downsize to before computing the render pass.
  52788. * @param camera The camera to apply the render pass to.
  52789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52790. * @param engine The engine which the post process will be applied. (default: current engine)
  52791. * @param reusable If the post process can be reused on the same frame. (default: false)
  52792. * @param textureType Type of textures used when performing the post process. (default: 0)
  52793. * @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)
  52794. */
  52795. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52796. /** Weight of the bloom to be added to the original input. */
  52797. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52798. }
  52799. }
  52800. declare module "babylonjs/PostProcesses/bloomEffect" {
  52801. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52802. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52803. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52804. import { Camera } from "babylonjs/Cameras/camera";
  52805. import { Scene } from "babylonjs/scene";
  52806. /**
  52807. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52808. */
  52809. export class BloomEffect extends PostProcessRenderEffect {
  52810. private bloomScale;
  52811. /**
  52812. * @hidden Internal
  52813. */
  52814. _effects: Array<PostProcess>;
  52815. /**
  52816. * @hidden Internal
  52817. */
  52818. _downscale: ExtractHighlightsPostProcess;
  52819. private _blurX;
  52820. private _blurY;
  52821. private _merge;
  52822. /**
  52823. * The luminance threshold to find bright areas of the image to bloom.
  52824. */
  52825. threshold: number;
  52826. /**
  52827. * The strength of the bloom.
  52828. */
  52829. weight: number;
  52830. /**
  52831. * Specifies the size of the bloom blur kernel, relative to the final output size
  52832. */
  52833. kernel: number;
  52834. /**
  52835. * Creates a new instance of @see BloomEffect
  52836. * @param scene The scene the effect belongs to.
  52837. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52838. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52839. * @param bloomWeight The the strength of bloom.
  52840. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52841. * @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)
  52842. */
  52843. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52844. /**
  52845. * Disposes each of the internal effects for a given camera.
  52846. * @param camera The camera to dispose the effect on.
  52847. */
  52848. disposeEffects(camera: Camera): void;
  52849. /**
  52850. * @hidden Internal
  52851. */
  52852. _updateEffects(): void;
  52853. /**
  52854. * Internal
  52855. * @returns if all the contained post processes are ready.
  52856. * @hidden
  52857. */
  52858. _isReady(): boolean;
  52859. }
  52860. }
  52861. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52862. /** @hidden */
  52863. export var chromaticAberrationPixelShader: {
  52864. name: string;
  52865. shader: string;
  52866. };
  52867. }
  52868. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52869. import { Vector2 } from "babylonjs/Maths/math";
  52870. import { Nullable } from "babylonjs/types";
  52871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52872. import { Camera } from "babylonjs/Cameras/camera";
  52873. import { Engine } from "babylonjs/Engines/engine";
  52874. import "babylonjs/Shaders/chromaticAberration.fragment";
  52875. /**
  52876. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52877. */
  52878. export class ChromaticAberrationPostProcess extends PostProcess {
  52879. /**
  52880. * The amount of seperation of rgb channels (default: 30)
  52881. */
  52882. aberrationAmount: number;
  52883. /**
  52884. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52885. */
  52886. radialIntensity: number;
  52887. /**
  52888. * 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))
  52889. */
  52890. direction: Vector2;
  52891. /**
  52892. * 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))
  52893. */
  52894. centerPosition: Vector2;
  52895. /**
  52896. * Creates a new instance ChromaticAberrationPostProcess
  52897. * @param name The name of the effect.
  52898. * @param screenWidth The width of the screen to apply the effect on.
  52899. * @param screenHeight The height of the screen to apply the effect on.
  52900. * @param options The required width/height ratio to downsize to before computing the render pass.
  52901. * @param camera The camera to apply the render pass to.
  52902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52903. * @param engine The engine which the post process will be applied. (default: current engine)
  52904. * @param reusable If the post process can be reused on the same frame. (default: false)
  52905. * @param textureType Type of textures used when performing the post process. (default: 0)
  52906. * @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)
  52907. */
  52908. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52909. }
  52910. }
  52911. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52912. /** @hidden */
  52913. export var circleOfConfusionPixelShader: {
  52914. name: string;
  52915. shader: string;
  52916. };
  52917. }
  52918. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52919. import { Nullable } from "babylonjs/types";
  52920. import { Engine } from "babylonjs/Engines/engine";
  52921. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52923. import { Camera } from "babylonjs/Cameras/camera";
  52924. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52925. /**
  52926. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52927. */
  52928. export class CircleOfConfusionPostProcess extends PostProcess {
  52929. /**
  52930. * 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.
  52931. */
  52932. lensSize: number;
  52933. /**
  52934. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52935. */
  52936. fStop: number;
  52937. /**
  52938. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52939. */
  52940. focusDistance: number;
  52941. /**
  52942. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52943. */
  52944. focalLength: number;
  52945. private _depthTexture;
  52946. /**
  52947. * Creates a new instance CircleOfConfusionPostProcess
  52948. * @param name The name of the effect.
  52949. * @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.
  52950. * @param options The required width/height ratio to downsize to before computing the render pass.
  52951. * @param camera The camera to apply the render pass to.
  52952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52953. * @param engine The engine which the post process will be applied. (default: current engine)
  52954. * @param reusable If the post process can be reused on the same frame. (default: false)
  52955. * @param textureType Type of textures used when performing the post process. (default: 0)
  52956. * @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)
  52957. */
  52958. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52959. /**
  52960. * 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.
  52961. */
  52962. depthTexture: RenderTargetTexture;
  52963. }
  52964. }
  52965. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52966. /** @hidden */
  52967. export var colorCorrectionPixelShader: {
  52968. name: string;
  52969. shader: string;
  52970. };
  52971. }
  52972. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52974. import { Engine } from "babylonjs/Engines/engine";
  52975. import { Camera } from "babylonjs/Cameras/camera";
  52976. import "babylonjs/Shaders/colorCorrection.fragment";
  52977. /**
  52978. *
  52979. * This post-process allows the modification of rendered colors by using
  52980. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52981. *
  52982. * The object needs to be provided an url to a texture containing the color
  52983. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52984. * Use an image editing software to tweak the LUT to match your needs.
  52985. *
  52986. * For an example of a color LUT, see here:
  52987. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52988. * For explanations on color grading, see here:
  52989. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52990. *
  52991. */
  52992. export class ColorCorrectionPostProcess extends PostProcess {
  52993. private _colorTableTexture;
  52994. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52995. }
  52996. }
  52997. declare module "babylonjs/Shaders/convolution.fragment" {
  52998. /** @hidden */
  52999. export var convolutionPixelShader: {
  53000. name: string;
  53001. shader: string;
  53002. };
  53003. }
  53004. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53005. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53006. import { Nullable } from "babylonjs/types";
  53007. import { Camera } from "babylonjs/Cameras/camera";
  53008. import { Engine } from "babylonjs/Engines/engine";
  53009. import "babylonjs/Shaders/convolution.fragment";
  53010. /**
  53011. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53012. * input texture to perform effects such as edge detection or sharpening
  53013. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53014. */
  53015. export class ConvolutionPostProcess extends PostProcess {
  53016. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53017. kernel: number[];
  53018. /**
  53019. * Creates a new instance ConvolutionPostProcess
  53020. * @param name The name of the effect.
  53021. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53022. * @param options The required width/height ratio to downsize to before computing the render pass.
  53023. * @param camera The camera to apply the render pass to.
  53024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53025. * @param engine The engine which the post process will be applied. (default: current engine)
  53026. * @param reusable If the post process can be reused on the same frame. (default: false)
  53027. * @param textureType Type of textures used when performing the post process. (default: 0)
  53028. */
  53029. constructor(name: string,
  53030. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53031. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53032. /**
  53033. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53034. */
  53035. static EdgeDetect0Kernel: number[];
  53036. /**
  53037. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53038. */
  53039. static EdgeDetect1Kernel: number[];
  53040. /**
  53041. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53042. */
  53043. static EdgeDetect2Kernel: number[];
  53044. /**
  53045. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53046. */
  53047. static SharpenKernel: number[];
  53048. /**
  53049. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53050. */
  53051. static EmbossKernel: number[];
  53052. /**
  53053. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53054. */
  53055. static GaussianKernel: number[];
  53056. }
  53057. }
  53058. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53059. import { Nullable } from "babylonjs/types";
  53060. import { Vector2 } from "babylonjs/Maths/math";
  53061. import { Camera } from "babylonjs/Cameras/camera";
  53062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53063. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53064. import { Engine } from "babylonjs/Engines/engine";
  53065. import { Scene } from "babylonjs/scene";
  53066. /**
  53067. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53068. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53069. * based on samples that have a large difference in distance than the center pixel.
  53070. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53071. */
  53072. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53073. direction: Vector2;
  53074. /**
  53075. * Creates a new instance CircleOfConfusionPostProcess
  53076. * @param name The name of the effect.
  53077. * @param scene The scene the effect belongs to.
  53078. * @param direction The direction the blur should be applied.
  53079. * @param kernel The size of the kernel used to blur.
  53080. * @param options The required width/height ratio to downsize to before computing the render pass.
  53081. * @param camera The camera to apply the render pass to.
  53082. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53083. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53085. * @param engine The engine which the post process will be applied. (default: current engine)
  53086. * @param reusable If the post process can be reused on the same frame. (default: false)
  53087. * @param textureType Type of textures used when performing the post process. (default: 0)
  53088. * @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)
  53089. */
  53090. 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);
  53091. }
  53092. }
  53093. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53094. /** @hidden */
  53095. export var depthOfFieldMergePixelShader: {
  53096. name: string;
  53097. shader: string;
  53098. };
  53099. }
  53100. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53101. import { Nullable } from "babylonjs/types";
  53102. import { Camera } from "babylonjs/Cameras/camera";
  53103. import { Effect } from "babylonjs/Materials/effect";
  53104. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53105. import { Engine } from "babylonjs/Engines/engine";
  53106. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53107. /**
  53108. * Options to be set when merging outputs from the default pipeline.
  53109. */
  53110. export class DepthOfFieldMergePostProcessOptions {
  53111. /**
  53112. * The original image to merge on top of
  53113. */
  53114. originalFromInput: PostProcess;
  53115. /**
  53116. * Parameters to perform the merge of the depth of field effect
  53117. */
  53118. depthOfField?: {
  53119. circleOfConfusion: PostProcess;
  53120. blurSteps: Array<PostProcess>;
  53121. };
  53122. /**
  53123. * Parameters to perform the merge of bloom effect
  53124. */
  53125. bloom?: {
  53126. blurred: PostProcess;
  53127. weight: number;
  53128. };
  53129. }
  53130. /**
  53131. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53132. */
  53133. export class DepthOfFieldMergePostProcess extends PostProcess {
  53134. private blurSteps;
  53135. /**
  53136. * Creates a new instance of DepthOfFieldMergePostProcess
  53137. * @param name The name of the effect.
  53138. * @param originalFromInput Post process which's input will be used for the merge.
  53139. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53140. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53141. * @param options The required width/height ratio to downsize to before computing the render pass.
  53142. * @param camera The camera to apply the render pass to.
  53143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53144. * @param engine The engine which the post process will be applied. (default: current engine)
  53145. * @param reusable If the post process can be reused on the same frame. (default: false)
  53146. * @param textureType Type of textures used when performing the post process. (default: 0)
  53147. * @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)
  53148. */
  53149. 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);
  53150. /**
  53151. * Updates the effect with the current post process compile time values and recompiles the shader.
  53152. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53153. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53154. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53155. * @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
  53156. * @param onCompiled Called when the shader has been compiled.
  53157. * @param onError Called if there is an error when compiling a shader.
  53158. */
  53159. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53160. }
  53161. }
  53162. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53163. import { Nullable } from "babylonjs/types";
  53164. import { Camera } from "babylonjs/Cameras/camera";
  53165. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53166. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53167. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53168. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53169. import { Scene } from "babylonjs/scene";
  53170. /**
  53171. * Specifies the level of max blur that should be applied when using the depth of field effect
  53172. */
  53173. export enum DepthOfFieldEffectBlurLevel {
  53174. /**
  53175. * Subtle blur
  53176. */
  53177. Low = 0,
  53178. /**
  53179. * Medium blur
  53180. */
  53181. Medium = 1,
  53182. /**
  53183. * Large blur
  53184. */
  53185. High = 2
  53186. }
  53187. /**
  53188. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53189. */
  53190. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53191. private _circleOfConfusion;
  53192. /**
  53193. * @hidden Internal, blurs from high to low
  53194. */
  53195. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53196. private _depthOfFieldBlurY;
  53197. private _dofMerge;
  53198. /**
  53199. * @hidden Internal post processes in depth of field effect
  53200. */
  53201. _effects: Array<PostProcess>;
  53202. /**
  53203. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53204. */
  53205. focalLength: number;
  53206. /**
  53207. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53208. */
  53209. fStop: number;
  53210. /**
  53211. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53212. */
  53213. focusDistance: number;
  53214. /**
  53215. * 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.
  53216. */
  53217. lensSize: number;
  53218. /**
  53219. * Creates a new instance DepthOfFieldEffect
  53220. * @param scene The scene the effect belongs to.
  53221. * @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.
  53222. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53223. * @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)
  53224. */
  53225. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53226. /**
  53227. * 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.
  53228. */
  53229. depthTexture: RenderTargetTexture;
  53230. /**
  53231. * Disposes each of the internal effects for a given camera.
  53232. * @param camera The camera to dispose the effect on.
  53233. */
  53234. disposeEffects(camera: Camera): void;
  53235. /**
  53236. * @hidden Internal
  53237. */
  53238. _updateEffects(): void;
  53239. /**
  53240. * Internal
  53241. * @returns if all the contained post processes are ready.
  53242. * @hidden
  53243. */
  53244. _isReady(): boolean;
  53245. }
  53246. }
  53247. declare module "babylonjs/Shaders/displayPass.fragment" {
  53248. /** @hidden */
  53249. export var displayPassPixelShader: {
  53250. name: string;
  53251. shader: string;
  53252. };
  53253. }
  53254. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53255. import { Nullable } from "babylonjs/types";
  53256. import { Camera } from "babylonjs/Cameras/camera";
  53257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53258. import { Engine } from "babylonjs/Engines/engine";
  53259. import "babylonjs/Shaders/displayPass.fragment";
  53260. /**
  53261. * DisplayPassPostProcess which produces an output the same as it's input
  53262. */
  53263. export class DisplayPassPostProcess extends PostProcess {
  53264. /**
  53265. * Creates the DisplayPassPostProcess
  53266. * @param name The name of the effect.
  53267. * @param options The required width/height ratio to downsize to before computing the render pass.
  53268. * @param camera The camera to apply the render pass to.
  53269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53270. * @param engine The engine which the post process will be applied. (default: current engine)
  53271. * @param reusable If the post process can be reused on the same frame. (default: false)
  53272. */
  53273. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53274. }
  53275. }
  53276. declare module "babylonjs/Shaders/filter.fragment" {
  53277. /** @hidden */
  53278. export var filterPixelShader: {
  53279. name: string;
  53280. shader: string;
  53281. };
  53282. }
  53283. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53284. import { Nullable } from "babylonjs/types";
  53285. import { Matrix } from "babylonjs/Maths/math";
  53286. import { Camera } from "babylonjs/Cameras/camera";
  53287. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53288. import { Engine } from "babylonjs/Engines/engine";
  53289. import "babylonjs/Shaders/filter.fragment";
  53290. /**
  53291. * Applies a kernel filter to the image
  53292. */
  53293. export class FilterPostProcess extends PostProcess {
  53294. /** The matrix to be applied to the image */
  53295. kernelMatrix: Matrix;
  53296. /**
  53297. *
  53298. * @param name The name of the effect.
  53299. * @param kernelMatrix The matrix to be applied to the image
  53300. * @param options The required width/height ratio to downsize to before computing the render pass.
  53301. * @param camera The camera to apply the render pass to.
  53302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53303. * @param engine The engine which the post process will be applied. (default: current engine)
  53304. * @param reusable If the post process can be reused on the same frame. (default: false)
  53305. */
  53306. constructor(name: string,
  53307. /** The matrix to be applied to the image */
  53308. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53309. }
  53310. }
  53311. declare module "babylonjs/Shaders/fxaa.fragment" {
  53312. /** @hidden */
  53313. export var fxaaPixelShader: {
  53314. name: string;
  53315. shader: string;
  53316. };
  53317. }
  53318. declare module "babylonjs/Shaders/fxaa.vertex" {
  53319. /** @hidden */
  53320. export var fxaaVertexShader: {
  53321. name: string;
  53322. shader: string;
  53323. };
  53324. }
  53325. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53326. import { Nullable } from "babylonjs/types";
  53327. import { Camera } from "babylonjs/Cameras/camera";
  53328. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53329. import { Engine } from "babylonjs/Engines/engine";
  53330. import "babylonjs/Shaders/fxaa.fragment";
  53331. import "babylonjs/Shaders/fxaa.vertex";
  53332. /**
  53333. * Fxaa post process
  53334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53335. */
  53336. export class FxaaPostProcess extends PostProcess {
  53337. /** @hidden */
  53338. texelWidth: number;
  53339. /** @hidden */
  53340. texelHeight: number;
  53341. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53342. private _getDefines;
  53343. }
  53344. }
  53345. declare module "babylonjs/Shaders/grain.fragment" {
  53346. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53347. /** @hidden */
  53348. export var grainPixelShader: {
  53349. name: string;
  53350. shader: string;
  53351. };
  53352. }
  53353. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53354. import { Nullable } from "babylonjs/types";
  53355. import { Camera } from "babylonjs/Cameras/camera";
  53356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53357. import { Engine } from "babylonjs/Engines/engine";
  53358. import "babylonjs/Shaders/grain.fragment";
  53359. /**
  53360. * The GrainPostProcess adds noise to the image at mid luminance levels
  53361. */
  53362. export class GrainPostProcess extends PostProcess {
  53363. /**
  53364. * The intensity of the grain added (default: 30)
  53365. */
  53366. intensity: number;
  53367. /**
  53368. * If the grain should be randomized on every frame
  53369. */
  53370. animated: boolean;
  53371. /**
  53372. * Creates a new instance of @see GrainPostProcess
  53373. * @param name The name of the effect.
  53374. * @param options The required width/height ratio to downsize to before computing the render pass.
  53375. * @param camera The camera to apply the render pass to.
  53376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53377. * @param engine The engine which the post process will be applied. (default: current engine)
  53378. * @param reusable If the post process can be reused on the same frame. (default: false)
  53379. * @param textureType Type of textures used when performing the post process. (default: 0)
  53380. * @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)
  53381. */
  53382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53383. }
  53384. }
  53385. declare module "babylonjs/Shaders/highlights.fragment" {
  53386. /** @hidden */
  53387. export var highlightsPixelShader: {
  53388. name: string;
  53389. shader: string;
  53390. };
  53391. }
  53392. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53393. import { Nullable } from "babylonjs/types";
  53394. import { Camera } from "babylonjs/Cameras/camera";
  53395. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53396. import { Engine } from "babylonjs/Engines/engine";
  53397. import "babylonjs/Shaders/highlights.fragment";
  53398. /**
  53399. * Extracts highlights from the image
  53400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53401. */
  53402. export class HighlightsPostProcess extends PostProcess {
  53403. /**
  53404. * Extracts highlights from the image
  53405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53406. * @param name The name of the effect.
  53407. * @param options The required width/height ratio to downsize to before computing the render pass.
  53408. * @param camera The camera to apply the render pass to.
  53409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53410. * @param engine The engine which the post process will be applied. (default: current engine)
  53411. * @param reusable If the post process can be reused on the same frame. (default: false)
  53412. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53413. */
  53414. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53415. }
  53416. }
  53417. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53418. /** @hidden */
  53419. export var mrtFragmentDeclaration: {
  53420. name: string;
  53421. shader: string;
  53422. };
  53423. }
  53424. declare module "babylonjs/Shaders/geometry.fragment" {
  53425. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53426. /** @hidden */
  53427. export var geometryPixelShader: {
  53428. name: string;
  53429. shader: string;
  53430. };
  53431. }
  53432. declare module "babylonjs/Shaders/geometry.vertex" {
  53433. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53434. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53435. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53436. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53437. /** @hidden */
  53438. export var geometryVertexShader: {
  53439. name: string;
  53440. shader: string;
  53441. };
  53442. }
  53443. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53444. import { Matrix } from "babylonjs/Maths/math";
  53445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53446. import { Mesh } from "babylonjs/Meshes/mesh";
  53447. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53448. import { Effect } from "babylonjs/Materials/effect";
  53449. import { Scene } from "babylonjs/scene";
  53450. import "babylonjs/Shaders/geometry.fragment";
  53451. import "babylonjs/Shaders/geometry.vertex";
  53452. /**
  53453. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53454. */
  53455. export class GeometryBufferRenderer {
  53456. /**
  53457. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53458. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53459. */
  53460. static readonly POSITION_TEXTURE_TYPE: number;
  53461. /**
  53462. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53463. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53464. */
  53465. static readonly VELOCITY_TEXTURE_TYPE: number;
  53466. /**
  53467. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53468. * in order to compute objects velocities when enableVelocity is set to "true"
  53469. * @hidden
  53470. */
  53471. _previousTransformationMatrices: {
  53472. [index: number]: Matrix;
  53473. };
  53474. private _scene;
  53475. private _multiRenderTarget;
  53476. private _ratio;
  53477. private _enablePosition;
  53478. private _enableVelocity;
  53479. private _positionIndex;
  53480. private _velocityIndex;
  53481. protected _effect: Effect;
  53482. protected _cachedDefines: string;
  53483. /**
  53484. * Set the render list (meshes to be rendered) used in the G buffer.
  53485. */
  53486. renderList: Mesh[];
  53487. /**
  53488. * Gets wether or not G buffer are supported by the running hardware.
  53489. * This requires draw buffer supports
  53490. */
  53491. readonly isSupported: boolean;
  53492. /**
  53493. * Returns the index of the given texture type in the G-Buffer textures array
  53494. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53495. * @returns the index of the given texture type in the G-Buffer textures array
  53496. */
  53497. getTextureIndex(textureType: number): number;
  53498. /**
  53499. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53500. */
  53501. /**
  53502. * Sets whether or not objects positions are enabled for the G buffer.
  53503. */
  53504. enablePosition: boolean;
  53505. /**
  53506. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53507. */
  53508. /**
  53509. * Sets wether or not objects velocities are enabled for the G buffer.
  53510. */
  53511. enableVelocity: boolean;
  53512. /**
  53513. * Gets the scene associated with the buffer.
  53514. */
  53515. readonly scene: Scene;
  53516. /**
  53517. * Gets the ratio used by the buffer during its creation.
  53518. * How big is the buffer related to the main canvas.
  53519. */
  53520. readonly ratio: number;
  53521. /** @hidden */
  53522. static _SceneComponentInitialization: (scene: Scene) => void;
  53523. /**
  53524. * Creates a new G Buffer for the scene
  53525. * @param scene The scene the buffer belongs to
  53526. * @param ratio How big is the buffer related to the main canvas.
  53527. */
  53528. constructor(scene: Scene, ratio?: number);
  53529. /**
  53530. * Checks wether everything is ready to render a submesh to the G buffer.
  53531. * @param subMesh the submesh to check readiness for
  53532. * @param useInstances is the mesh drawn using instance or not
  53533. * @returns true if ready otherwise false
  53534. */
  53535. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53536. /**
  53537. * Gets the current underlying G Buffer.
  53538. * @returns the buffer
  53539. */
  53540. getGBuffer(): MultiRenderTarget;
  53541. /**
  53542. * Gets the number of samples used to render the buffer (anti aliasing).
  53543. */
  53544. /**
  53545. * Sets the number of samples used to render the buffer (anti aliasing).
  53546. */
  53547. samples: number;
  53548. /**
  53549. * Disposes the renderer and frees up associated resources.
  53550. */
  53551. dispose(): void;
  53552. protected _createRenderTargets(): void;
  53553. }
  53554. }
  53555. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53556. import { Nullable } from "babylonjs/types";
  53557. import { Scene } from "babylonjs/scene";
  53558. import { ISceneComponent } from "babylonjs/sceneComponent";
  53559. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53560. module "babylonjs/scene" {
  53561. interface Scene {
  53562. /** @hidden (Backing field) */
  53563. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53564. /**
  53565. * Gets or Sets the current geometry buffer associated to the scene.
  53566. */
  53567. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53568. /**
  53569. * Enables a GeometryBufferRender and associates it with the scene
  53570. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53571. * @returns the GeometryBufferRenderer
  53572. */
  53573. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53574. /**
  53575. * Disables the GeometryBufferRender associated with the scene
  53576. */
  53577. disableGeometryBufferRenderer(): void;
  53578. }
  53579. }
  53580. /**
  53581. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53582. * in several rendering techniques.
  53583. */
  53584. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53585. /**
  53586. * The component name helpful to identify the component in the list of scene components.
  53587. */
  53588. readonly name: string;
  53589. /**
  53590. * The scene the component belongs to.
  53591. */
  53592. scene: Scene;
  53593. /**
  53594. * Creates a new instance of the component for the given scene
  53595. * @param scene Defines the scene to register the component in
  53596. */
  53597. constructor(scene: Scene);
  53598. /**
  53599. * Registers the component in a given scene
  53600. */
  53601. register(): void;
  53602. /**
  53603. * Rebuilds the elements related to this component in case of
  53604. * context lost for instance.
  53605. */
  53606. rebuild(): void;
  53607. /**
  53608. * Disposes the component and the associated ressources
  53609. */
  53610. dispose(): void;
  53611. private _gatherRenderTargets;
  53612. }
  53613. }
  53614. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53615. /** @hidden */
  53616. export var motionBlurPixelShader: {
  53617. name: string;
  53618. shader: string;
  53619. };
  53620. }
  53621. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53622. import { Nullable } from "babylonjs/types";
  53623. import { Camera } from "babylonjs/Cameras/camera";
  53624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53625. import { Scene } from "babylonjs/scene";
  53626. import "babylonjs/Animations/animatable";
  53627. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53628. import "babylonjs/Shaders/motionBlur.fragment";
  53629. import { Engine } from "babylonjs/Engines/engine";
  53630. /**
  53631. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53632. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53633. * As an example, all you have to do is to create the post-process:
  53634. * var mb = new BABYLON.MotionBlurPostProcess(
  53635. * 'mb', // The name of the effect.
  53636. * scene, // The scene containing the objects to blur according to their velocity.
  53637. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53638. * camera // The camera to apply the render pass to.
  53639. * );
  53640. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53641. */
  53642. export class MotionBlurPostProcess extends PostProcess {
  53643. /**
  53644. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53645. */
  53646. motionStrength: number;
  53647. /**
  53648. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53649. */
  53650. /**
  53651. * Sets the number of iterations to be used for motion blur quality
  53652. */
  53653. motionBlurSamples: number;
  53654. private _motionBlurSamples;
  53655. private _geometryBufferRenderer;
  53656. /**
  53657. * Creates a new instance MotionBlurPostProcess
  53658. * @param name The name of the effect.
  53659. * @param scene The scene containing the objects to blur according to their velocity.
  53660. * @param options The required width/height ratio to downsize to before computing the render pass.
  53661. * @param camera The camera to apply the render pass to.
  53662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53663. * @param engine The engine which the post process will be applied. (default: current engine)
  53664. * @param reusable If the post process can be reused on the same frame. (default: false)
  53665. * @param textureType Type of textures used when performing the post process. (default: 0)
  53666. * @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)
  53667. */
  53668. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53669. /**
  53670. * Disposes the post process.
  53671. * @param camera The camera to dispose the post process on.
  53672. */
  53673. dispose(camera?: Camera): void;
  53674. }
  53675. }
  53676. declare module "babylonjs/Shaders/refraction.fragment" {
  53677. /** @hidden */
  53678. export var refractionPixelShader: {
  53679. name: string;
  53680. shader: string;
  53681. };
  53682. }
  53683. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53684. import { Color3 } from "babylonjs/Maths/math";
  53685. import { Camera } from "babylonjs/Cameras/camera";
  53686. import { Texture } from "babylonjs/Materials/Textures/texture";
  53687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53688. import { Engine } from "babylonjs/Engines/engine";
  53689. import "babylonjs/Shaders/refraction.fragment";
  53690. /**
  53691. * Post process which applies a refractin texture
  53692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53693. */
  53694. export class RefractionPostProcess extends PostProcess {
  53695. /** the base color of the refraction (used to taint the rendering) */
  53696. color: Color3;
  53697. /** simulated refraction depth */
  53698. depth: number;
  53699. /** the coefficient of the base color (0 to remove base color tainting) */
  53700. colorLevel: number;
  53701. private _refTexture;
  53702. private _ownRefractionTexture;
  53703. /**
  53704. * Gets or sets the refraction texture
  53705. * Please note that you are responsible for disposing the texture if you set it manually
  53706. */
  53707. refractionTexture: Texture;
  53708. /**
  53709. * Initializes the RefractionPostProcess
  53710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53711. * @param name The name of the effect.
  53712. * @param refractionTextureUrl Url of the refraction texture to use
  53713. * @param color the base color of the refraction (used to taint the rendering)
  53714. * @param depth simulated refraction depth
  53715. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53716. * @param camera The camera to apply the render pass to.
  53717. * @param options The required width/height ratio to downsize to before computing the render pass.
  53718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53719. * @param engine The engine which the post process will be applied. (default: current engine)
  53720. * @param reusable If the post process can be reused on the same frame. (default: false)
  53721. */
  53722. constructor(name: string, refractionTextureUrl: string,
  53723. /** the base color of the refraction (used to taint the rendering) */
  53724. color: Color3,
  53725. /** simulated refraction depth */
  53726. depth: number,
  53727. /** the coefficient of the base color (0 to remove base color tainting) */
  53728. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53729. /**
  53730. * Disposes of the post process
  53731. * @param camera Camera to dispose post process on
  53732. */
  53733. dispose(camera: Camera): void;
  53734. }
  53735. }
  53736. declare module "babylonjs/Shaders/sharpen.fragment" {
  53737. /** @hidden */
  53738. export var sharpenPixelShader: {
  53739. name: string;
  53740. shader: string;
  53741. };
  53742. }
  53743. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53744. import { Nullable } from "babylonjs/types";
  53745. import { Camera } from "babylonjs/Cameras/camera";
  53746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53747. import "babylonjs/Shaders/sharpen.fragment";
  53748. import { Engine } from "babylonjs/Engines/engine";
  53749. /**
  53750. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53751. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53752. */
  53753. export class SharpenPostProcess extends PostProcess {
  53754. /**
  53755. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53756. */
  53757. colorAmount: number;
  53758. /**
  53759. * How much sharpness should be applied (default: 0.3)
  53760. */
  53761. edgeAmount: number;
  53762. /**
  53763. * Creates a new instance ConvolutionPostProcess
  53764. * @param name The name of the effect.
  53765. * @param options The required width/height ratio to downsize to before computing the render pass.
  53766. * @param camera The camera to apply the render pass to.
  53767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53768. * @param engine The engine which the post process will be applied. (default: current engine)
  53769. * @param reusable If the post process can be reused on the same frame. (default: false)
  53770. * @param textureType Type of textures used when performing the post process. (default: 0)
  53771. * @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)
  53772. */
  53773. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53774. }
  53775. }
  53776. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53777. import { Nullable } from "babylonjs/types";
  53778. import { Camera } from "babylonjs/Cameras/camera";
  53779. import { Engine } from "babylonjs/Engines/engine";
  53780. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53781. /**
  53782. * PostProcessRenderPipeline
  53783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53784. */
  53785. export class PostProcessRenderPipeline {
  53786. private engine;
  53787. private _renderEffects;
  53788. private _renderEffectsForIsolatedPass;
  53789. /**
  53790. * @hidden
  53791. */
  53792. protected _cameras: Camera[];
  53793. /** @hidden */
  53794. _name: string;
  53795. /**
  53796. * Gets pipeline name
  53797. */
  53798. readonly name: string;
  53799. /**
  53800. * Initializes a PostProcessRenderPipeline
  53801. * @param engine engine to add the pipeline to
  53802. * @param name name of the pipeline
  53803. */
  53804. constructor(engine: Engine, name: string);
  53805. /**
  53806. * Gets the class name
  53807. * @returns "PostProcessRenderPipeline"
  53808. */
  53809. getClassName(): string;
  53810. /**
  53811. * If all the render effects in the pipeline are supported
  53812. */
  53813. readonly isSupported: boolean;
  53814. /**
  53815. * Adds an effect to the pipeline
  53816. * @param renderEffect the effect to add
  53817. */
  53818. addEffect(renderEffect: PostProcessRenderEffect): void;
  53819. /** @hidden */
  53820. _rebuild(): void;
  53821. /** @hidden */
  53822. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53823. /** @hidden */
  53824. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53825. /** @hidden */
  53826. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53827. /** @hidden */
  53828. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53829. /** @hidden */
  53830. _attachCameras(cameras: Camera, unique: boolean): void;
  53831. /** @hidden */
  53832. _attachCameras(cameras: Camera[], unique: boolean): void;
  53833. /** @hidden */
  53834. _detachCameras(cameras: Camera): void;
  53835. /** @hidden */
  53836. _detachCameras(cameras: Nullable<Camera[]>): void;
  53837. /** @hidden */
  53838. _update(): void;
  53839. /** @hidden */
  53840. _reset(): void;
  53841. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53842. /**
  53843. * Disposes of the pipeline
  53844. */
  53845. dispose(): void;
  53846. }
  53847. }
  53848. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53849. import { Camera } from "babylonjs/Cameras/camera";
  53850. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53851. /**
  53852. * PostProcessRenderPipelineManager class
  53853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53854. */
  53855. export class PostProcessRenderPipelineManager {
  53856. private _renderPipelines;
  53857. /**
  53858. * Initializes a PostProcessRenderPipelineManager
  53859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53860. */
  53861. constructor();
  53862. /**
  53863. * Gets the list of supported render pipelines
  53864. */
  53865. readonly supportedPipelines: PostProcessRenderPipeline[];
  53866. /**
  53867. * Adds a pipeline to the manager
  53868. * @param renderPipeline The pipeline to add
  53869. */
  53870. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53871. /**
  53872. * Attaches a camera to the pipeline
  53873. * @param renderPipelineName The name of the pipeline to attach to
  53874. * @param cameras the camera to attach
  53875. * @param unique if the camera can be attached multiple times to the pipeline
  53876. */
  53877. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53878. /**
  53879. * Detaches a camera from the pipeline
  53880. * @param renderPipelineName The name of the pipeline to detach from
  53881. * @param cameras the camera to detach
  53882. */
  53883. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53884. /**
  53885. * Enables an effect by name on a pipeline
  53886. * @param renderPipelineName the name of the pipeline to enable the effect in
  53887. * @param renderEffectName the name of the effect to enable
  53888. * @param cameras the cameras that the effect should be enabled on
  53889. */
  53890. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53891. /**
  53892. * Disables an effect by name on a pipeline
  53893. * @param renderPipelineName the name of the pipeline to disable the effect in
  53894. * @param renderEffectName the name of the effect to disable
  53895. * @param cameras the cameras that the effect should be disabled on
  53896. */
  53897. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53898. /**
  53899. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53900. */
  53901. update(): void;
  53902. /** @hidden */
  53903. _rebuild(): void;
  53904. /**
  53905. * Disposes of the manager and pipelines
  53906. */
  53907. dispose(): void;
  53908. }
  53909. }
  53910. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53911. import { ISceneComponent } from "babylonjs/sceneComponent";
  53912. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53913. import { Scene } from "babylonjs/scene";
  53914. module "babylonjs/scene" {
  53915. interface Scene {
  53916. /** @hidden (Backing field) */
  53917. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53918. /**
  53919. * Gets the postprocess render pipeline manager
  53920. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53921. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53922. */
  53923. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53924. }
  53925. }
  53926. /**
  53927. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53928. */
  53929. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53930. /**
  53931. * The component name helpfull to identify the component in the list of scene components.
  53932. */
  53933. readonly name: string;
  53934. /**
  53935. * The scene the component belongs to.
  53936. */
  53937. scene: Scene;
  53938. /**
  53939. * Creates a new instance of the component for the given scene
  53940. * @param scene Defines the scene to register the component in
  53941. */
  53942. constructor(scene: Scene);
  53943. /**
  53944. * Registers the component in a given scene
  53945. */
  53946. register(): void;
  53947. /**
  53948. * Rebuilds the elements related to this component in case of
  53949. * context lost for instance.
  53950. */
  53951. rebuild(): void;
  53952. /**
  53953. * Disposes the component and the associated ressources
  53954. */
  53955. dispose(): void;
  53956. private _gatherRenderTargets;
  53957. }
  53958. }
  53959. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53960. import { IAnimatable } from "babylonjs/Misc/tools";
  53961. import { Camera } from "babylonjs/Cameras/camera";
  53962. import { IDisposable } from "babylonjs/scene";
  53963. import { Scene } from "babylonjs/scene";
  53964. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53965. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53966. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53967. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53968. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53969. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53970. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53971. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53972. import { Animation } from "babylonjs/Animations/animation";
  53973. /**
  53974. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53975. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53976. */
  53977. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53978. private _scene;
  53979. private _camerasToBeAttached;
  53980. /**
  53981. * ID of the sharpen post process,
  53982. */
  53983. private readonly SharpenPostProcessId;
  53984. /**
  53985. * @ignore
  53986. * ID of the image processing post process;
  53987. */
  53988. readonly ImageProcessingPostProcessId: string;
  53989. /**
  53990. * @ignore
  53991. * ID of the Fast Approximate Anti-Aliasing post process;
  53992. */
  53993. readonly FxaaPostProcessId: string;
  53994. /**
  53995. * ID of the chromatic aberration post process,
  53996. */
  53997. private readonly ChromaticAberrationPostProcessId;
  53998. /**
  53999. * ID of the grain post process
  54000. */
  54001. private readonly GrainPostProcessId;
  54002. /**
  54003. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54004. */
  54005. sharpen: SharpenPostProcess;
  54006. private _sharpenEffect;
  54007. private bloom;
  54008. /**
  54009. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54010. */
  54011. depthOfField: DepthOfFieldEffect;
  54012. /**
  54013. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54014. */
  54015. fxaa: FxaaPostProcess;
  54016. /**
  54017. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54018. */
  54019. imageProcessing: ImageProcessingPostProcess;
  54020. /**
  54021. * Chromatic aberration post process which will shift rgb colors in the image
  54022. */
  54023. chromaticAberration: ChromaticAberrationPostProcess;
  54024. private _chromaticAberrationEffect;
  54025. /**
  54026. * Grain post process which add noise to the image
  54027. */
  54028. grain: GrainPostProcess;
  54029. private _grainEffect;
  54030. /**
  54031. * Glow post process which adds a glow to emissive areas of the image
  54032. */
  54033. private _glowLayer;
  54034. /**
  54035. * Animations which can be used to tweak settings over a period of time
  54036. */
  54037. animations: Animation[];
  54038. private _imageProcessingConfigurationObserver;
  54039. private _sharpenEnabled;
  54040. private _bloomEnabled;
  54041. private _depthOfFieldEnabled;
  54042. private _depthOfFieldBlurLevel;
  54043. private _fxaaEnabled;
  54044. private _imageProcessingEnabled;
  54045. private _defaultPipelineTextureType;
  54046. private _bloomScale;
  54047. private _chromaticAberrationEnabled;
  54048. private _grainEnabled;
  54049. private _buildAllowed;
  54050. /**
  54051. * Gets active scene
  54052. */
  54053. readonly scene: Scene;
  54054. /**
  54055. * Enable or disable the sharpen process from the pipeline
  54056. */
  54057. sharpenEnabled: boolean;
  54058. private _resizeObserver;
  54059. private _hardwareScaleLevel;
  54060. private _bloomKernel;
  54061. /**
  54062. * Specifies the size of the bloom blur kernel, relative to the final output size
  54063. */
  54064. bloomKernel: number;
  54065. /**
  54066. * Specifies the weight of the bloom in the final rendering
  54067. */
  54068. private _bloomWeight;
  54069. /**
  54070. * Specifies the luma threshold for the area that will be blurred by the bloom
  54071. */
  54072. private _bloomThreshold;
  54073. private _hdr;
  54074. /**
  54075. * The strength of the bloom.
  54076. */
  54077. bloomWeight: number;
  54078. /**
  54079. * The strength of the bloom.
  54080. */
  54081. bloomThreshold: number;
  54082. /**
  54083. * The scale of the bloom, lower value will provide better performance.
  54084. */
  54085. bloomScale: number;
  54086. /**
  54087. * Enable or disable the bloom from the pipeline
  54088. */
  54089. bloomEnabled: boolean;
  54090. private _rebuildBloom;
  54091. /**
  54092. * If the depth of field is enabled.
  54093. */
  54094. depthOfFieldEnabled: boolean;
  54095. /**
  54096. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54097. */
  54098. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54099. /**
  54100. * If the anti aliasing is enabled.
  54101. */
  54102. fxaaEnabled: boolean;
  54103. private _samples;
  54104. /**
  54105. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54106. */
  54107. samples: number;
  54108. /**
  54109. * If image processing is enabled.
  54110. */
  54111. imageProcessingEnabled: boolean;
  54112. /**
  54113. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54114. */
  54115. glowLayerEnabled: boolean;
  54116. /**
  54117. * Enable or disable the chromaticAberration process from the pipeline
  54118. */
  54119. chromaticAberrationEnabled: boolean;
  54120. /**
  54121. * Enable or disable the grain process from the pipeline
  54122. */
  54123. grainEnabled: boolean;
  54124. /**
  54125. * @constructor
  54126. * @param name - The rendering pipeline name (default: "")
  54127. * @param hdr - If high dynamic range textures should be used (default: true)
  54128. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54129. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54130. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54131. */
  54132. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54133. /**
  54134. * Get the class name
  54135. * @returns "DefaultRenderingPipeline"
  54136. */
  54137. getClassName(): string;
  54138. /**
  54139. * Force the compilation of the entire pipeline.
  54140. */
  54141. prepare(): void;
  54142. private _hasCleared;
  54143. private _prevPostProcess;
  54144. private _prevPrevPostProcess;
  54145. private _setAutoClearAndTextureSharing;
  54146. private _depthOfFieldSceneObserver;
  54147. private _buildPipeline;
  54148. private _disposePostProcesses;
  54149. /**
  54150. * Adds a camera to the pipeline
  54151. * @param camera the camera to be added
  54152. */
  54153. addCamera(camera: Camera): void;
  54154. /**
  54155. * Removes a camera from the pipeline
  54156. * @param camera the camera to remove
  54157. */
  54158. removeCamera(camera: Camera): void;
  54159. /**
  54160. * Dispose of the pipeline and stop all post processes
  54161. */
  54162. dispose(): void;
  54163. /**
  54164. * Serialize the rendering pipeline (Used when exporting)
  54165. * @returns the serialized object
  54166. */
  54167. serialize(): any;
  54168. /**
  54169. * Parse the serialized pipeline
  54170. * @param source Source pipeline.
  54171. * @param scene The scene to load the pipeline to.
  54172. * @param rootUrl The URL of the serialized pipeline.
  54173. * @returns An instantiated pipeline from the serialized object.
  54174. */
  54175. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54176. }
  54177. }
  54178. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54179. /** @hidden */
  54180. export var lensHighlightsPixelShader: {
  54181. name: string;
  54182. shader: string;
  54183. };
  54184. }
  54185. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54186. /** @hidden */
  54187. export var depthOfFieldPixelShader: {
  54188. name: string;
  54189. shader: string;
  54190. };
  54191. }
  54192. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54193. import { Camera } from "babylonjs/Cameras/camera";
  54194. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54195. import { Scene } from "babylonjs/scene";
  54196. import "babylonjs/Shaders/chromaticAberration.fragment";
  54197. import "babylonjs/Shaders/lensHighlights.fragment";
  54198. import "babylonjs/Shaders/depthOfField.fragment";
  54199. /**
  54200. * BABYLON.JS Chromatic Aberration GLSL Shader
  54201. * Author: Olivier Guyot
  54202. * Separates very slightly R, G and B colors on the edges of the screen
  54203. * Inspired by Francois Tarlier & Martins Upitis
  54204. */
  54205. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54206. /**
  54207. * @ignore
  54208. * The chromatic aberration PostProcess id in the pipeline
  54209. */
  54210. LensChromaticAberrationEffect: string;
  54211. /**
  54212. * @ignore
  54213. * The highlights enhancing PostProcess id in the pipeline
  54214. */
  54215. HighlightsEnhancingEffect: string;
  54216. /**
  54217. * @ignore
  54218. * The depth-of-field PostProcess id in the pipeline
  54219. */
  54220. LensDepthOfFieldEffect: string;
  54221. private _scene;
  54222. private _depthTexture;
  54223. private _grainTexture;
  54224. private _chromaticAberrationPostProcess;
  54225. private _highlightsPostProcess;
  54226. private _depthOfFieldPostProcess;
  54227. private _edgeBlur;
  54228. private _grainAmount;
  54229. private _chromaticAberration;
  54230. private _distortion;
  54231. private _highlightsGain;
  54232. private _highlightsThreshold;
  54233. private _dofDistance;
  54234. private _dofAperture;
  54235. private _dofDarken;
  54236. private _dofPentagon;
  54237. private _blurNoise;
  54238. /**
  54239. * @constructor
  54240. *
  54241. * Effect parameters are as follow:
  54242. * {
  54243. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54244. * edge_blur: number; // from 0 to x (1 for realism)
  54245. * distortion: number; // from 0 to x (1 for realism)
  54246. * grain_amount: number; // from 0 to 1
  54247. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54248. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54249. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54250. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54251. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54252. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54253. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54254. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54255. * }
  54256. * Note: if an effect parameter is unset, effect is disabled
  54257. *
  54258. * @param name The rendering pipeline name
  54259. * @param parameters - An object containing all parameters (see above)
  54260. * @param scene The scene linked to this pipeline
  54261. * @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)
  54262. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54263. */
  54264. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54265. /**
  54266. * Sets the amount of blur at the edges
  54267. * @param amount blur amount
  54268. */
  54269. setEdgeBlur(amount: number): void;
  54270. /**
  54271. * Sets edge blur to 0
  54272. */
  54273. disableEdgeBlur(): void;
  54274. /**
  54275. * Sets the amout of grain
  54276. * @param amount Amount of grain
  54277. */
  54278. setGrainAmount(amount: number): void;
  54279. /**
  54280. * Set grain amount to 0
  54281. */
  54282. disableGrain(): void;
  54283. /**
  54284. * Sets the chromatic aberration amount
  54285. * @param amount amount of chromatic aberration
  54286. */
  54287. setChromaticAberration(amount: number): void;
  54288. /**
  54289. * Sets chromatic aberration amount to 0
  54290. */
  54291. disableChromaticAberration(): void;
  54292. /**
  54293. * Sets the EdgeDistortion amount
  54294. * @param amount amount of EdgeDistortion
  54295. */
  54296. setEdgeDistortion(amount: number): void;
  54297. /**
  54298. * Sets edge distortion to 0
  54299. */
  54300. disableEdgeDistortion(): void;
  54301. /**
  54302. * Sets the FocusDistance amount
  54303. * @param amount amount of FocusDistance
  54304. */
  54305. setFocusDistance(amount: number): void;
  54306. /**
  54307. * Disables depth of field
  54308. */
  54309. disableDepthOfField(): void;
  54310. /**
  54311. * Sets the Aperture amount
  54312. * @param amount amount of Aperture
  54313. */
  54314. setAperture(amount: number): void;
  54315. /**
  54316. * Sets the DarkenOutOfFocus amount
  54317. * @param amount amount of DarkenOutOfFocus
  54318. */
  54319. setDarkenOutOfFocus(amount: number): void;
  54320. /**
  54321. * Creates a pentagon bokeh effect
  54322. */
  54323. enablePentagonBokeh(): void;
  54324. /**
  54325. * Disables the pentagon bokeh effect
  54326. */
  54327. disablePentagonBokeh(): void;
  54328. /**
  54329. * Enables noise blur
  54330. */
  54331. enableNoiseBlur(): void;
  54332. /**
  54333. * Disables noise blur
  54334. */
  54335. disableNoiseBlur(): void;
  54336. /**
  54337. * Sets the HighlightsGain amount
  54338. * @param amount amount of HighlightsGain
  54339. */
  54340. setHighlightsGain(amount: number): void;
  54341. /**
  54342. * Sets the HighlightsThreshold amount
  54343. * @param amount amount of HighlightsThreshold
  54344. */
  54345. setHighlightsThreshold(amount: number): void;
  54346. /**
  54347. * Disables highlights
  54348. */
  54349. disableHighlights(): void;
  54350. /**
  54351. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54352. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54353. */
  54354. dispose(disableDepthRender?: boolean): void;
  54355. private _createChromaticAberrationPostProcess;
  54356. private _createHighlightsPostProcess;
  54357. private _createDepthOfFieldPostProcess;
  54358. private _createGrainTexture;
  54359. }
  54360. }
  54361. declare module "babylonjs/Shaders/ssao2.fragment" {
  54362. /** @hidden */
  54363. export var ssao2PixelShader: {
  54364. name: string;
  54365. shader: string;
  54366. };
  54367. }
  54368. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54369. /** @hidden */
  54370. export var ssaoCombinePixelShader: {
  54371. name: string;
  54372. shader: string;
  54373. };
  54374. }
  54375. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54376. import { Camera } from "babylonjs/Cameras/camera";
  54377. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54378. import { Scene } from "babylonjs/scene";
  54379. import "babylonjs/Shaders/ssao2.fragment";
  54380. import "babylonjs/Shaders/ssaoCombine.fragment";
  54381. /**
  54382. * Render pipeline to produce ssao effect
  54383. */
  54384. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54385. /**
  54386. * @ignore
  54387. * The PassPostProcess id in the pipeline that contains the original scene color
  54388. */
  54389. SSAOOriginalSceneColorEffect: string;
  54390. /**
  54391. * @ignore
  54392. * The SSAO PostProcess id in the pipeline
  54393. */
  54394. SSAORenderEffect: string;
  54395. /**
  54396. * @ignore
  54397. * The horizontal blur PostProcess id in the pipeline
  54398. */
  54399. SSAOBlurHRenderEffect: string;
  54400. /**
  54401. * @ignore
  54402. * The vertical blur PostProcess id in the pipeline
  54403. */
  54404. SSAOBlurVRenderEffect: string;
  54405. /**
  54406. * @ignore
  54407. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54408. */
  54409. SSAOCombineRenderEffect: string;
  54410. /**
  54411. * The output strength of the SSAO post-process. Default value is 1.0.
  54412. */
  54413. totalStrength: number;
  54414. /**
  54415. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54416. */
  54417. maxZ: number;
  54418. /**
  54419. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54420. */
  54421. minZAspect: number;
  54422. private _samples;
  54423. /**
  54424. * Number of samples used for the SSAO calculations. Default value is 8
  54425. */
  54426. samples: number;
  54427. private _textureSamples;
  54428. /**
  54429. * Number of samples to use for antialiasing
  54430. */
  54431. textureSamples: number;
  54432. /**
  54433. * Ratio object used for SSAO ratio and blur ratio
  54434. */
  54435. private _ratio;
  54436. /**
  54437. * Dynamically generated sphere sampler.
  54438. */
  54439. private _sampleSphere;
  54440. /**
  54441. * Blur filter offsets
  54442. */
  54443. private _samplerOffsets;
  54444. private _expensiveBlur;
  54445. /**
  54446. * If bilateral blur should be used
  54447. */
  54448. expensiveBlur: boolean;
  54449. /**
  54450. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54451. */
  54452. radius: number;
  54453. /**
  54454. * The base color of the SSAO post-process
  54455. * The final result is "base + ssao" between [0, 1]
  54456. */
  54457. base: number;
  54458. /**
  54459. * Support test.
  54460. */
  54461. static readonly IsSupported: boolean;
  54462. private _scene;
  54463. private _depthTexture;
  54464. private _normalTexture;
  54465. private _randomTexture;
  54466. private _originalColorPostProcess;
  54467. private _ssaoPostProcess;
  54468. private _blurHPostProcess;
  54469. private _blurVPostProcess;
  54470. private _ssaoCombinePostProcess;
  54471. private _firstUpdate;
  54472. /**
  54473. * Gets active scene
  54474. */
  54475. readonly scene: Scene;
  54476. /**
  54477. * @constructor
  54478. * @param name The rendering pipeline name
  54479. * @param scene The scene linked to this pipeline
  54480. * @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 }
  54481. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54482. */
  54483. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54484. /**
  54485. * Get the class name
  54486. * @returns "SSAO2RenderingPipeline"
  54487. */
  54488. getClassName(): string;
  54489. /**
  54490. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54491. */
  54492. dispose(disableGeometryBufferRenderer?: boolean): void;
  54493. private _createBlurPostProcess;
  54494. /** @hidden */
  54495. _rebuild(): void;
  54496. private _bits;
  54497. private _radicalInverse_VdC;
  54498. private _hammersley;
  54499. private _hemisphereSample_uniform;
  54500. private _generateHemisphere;
  54501. private _createSSAOPostProcess;
  54502. private _createSSAOCombinePostProcess;
  54503. private _createRandomTexture;
  54504. /**
  54505. * Serialize the rendering pipeline (Used when exporting)
  54506. * @returns the serialized object
  54507. */
  54508. serialize(): any;
  54509. /**
  54510. * Parse the serialized pipeline
  54511. * @param source Source pipeline.
  54512. * @param scene The scene to load the pipeline to.
  54513. * @param rootUrl The URL of the serialized pipeline.
  54514. * @returns An instantiated pipeline from the serialized object.
  54515. */
  54516. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54517. }
  54518. }
  54519. declare module "babylonjs/Shaders/ssao.fragment" {
  54520. /** @hidden */
  54521. export var ssaoPixelShader: {
  54522. name: string;
  54523. shader: string;
  54524. };
  54525. }
  54526. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54527. import { Camera } from "babylonjs/Cameras/camera";
  54528. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54529. import { Scene } from "babylonjs/scene";
  54530. import "babylonjs/Shaders/ssao.fragment";
  54531. import "babylonjs/Shaders/ssaoCombine.fragment";
  54532. /**
  54533. * Render pipeline to produce ssao effect
  54534. */
  54535. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54536. /**
  54537. * @ignore
  54538. * The PassPostProcess id in the pipeline that contains the original scene color
  54539. */
  54540. SSAOOriginalSceneColorEffect: string;
  54541. /**
  54542. * @ignore
  54543. * The SSAO PostProcess id in the pipeline
  54544. */
  54545. SSAORenderEffect: string;
  54546. /**
  54547. * @ignore
  54548. * The horizontal blur PostProcess id in the pipeline
  54549. */
  54550. SSAOBlurHRenderEffect: string;
  54551. /**
  54552. * @ignore
  54553. * The vertical blur PostProcess id in the pipeline
  54554. */
  54555. SSAOBlurVRenderEffect: string;
  54556. /**
  54557. * @ignore
  54558. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54559. */
  54560. SSAOCombineRenderEffect: string;
  54561. /**
  54562. * The output strength of the SSAO post-process. Default value is 1.0.
  54563. */
  54564. totalStrength: number;
  54565. /**
  54566. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54567. */
  54568. radius: number;
  54569. /**
  54570. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54571. * Must not be equal to fallOff and superior to fallOff.
  54572. * Default value is 0.0075
  54573. */
  54574. area: number;
  54575. /**
  54576. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54577. * Must not be equal to area and inferior to area.
  54578. * Default value is 0.000001
  54579. */
  54580. fallOff: number;
  54581. /**
  54582. * The base color of the SSAO post-process
  54583. * The final result is "base + ssao" between [0, 1]
  54584. */
  54585. base: number;
  54586. private _scene;
  54587. private _depthTexture;
  54588. private _randomTexture;
  54589. private _originalColorPostProcess;
  54590. private _ssaoPostProcess;
  54591. private _blurHPostProcess;
  54592. private _blurVPostProcess;
  54593. private _ssaoCombinePostProcess;
  54594. private _firstUpdate;
  54595. /**
  54596. * Gets active scene
  54597. */
  54598. readonly scene: Scene;
  54599. /**
  54600. * @constructor
  54601. * @param name - The rendering pipeline name
  54602. * @param scene - The scene linked to this pipeline
  54603. * @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 }
  54604. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54605. */
  54606. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54607. /**
  54608. * Get the class name
  54609. * @returns "SSAORenderingPipeline"
  54610. */
  54611. getClassName(): string;
  54612. /**
  54613. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54614. */
  54615. dispose(disableDepthRender?: boolean): void;
  54616. private _createBlurPostProcess;
  54617. /** @hidden */
  54618. _rebuild(): void;
  54619. private _createSSAOPostProcess;
  54620. private _createSSAOCombinePostProcess;
  54621. private _createRandomTexture;
  54622. }
  54623. }
  54624. declare module "babylonjs/Shaders/standard.fragment" {
  54625. /** @hidden */
  54626. export var standardPixelShader: {
  54627. name: string;
  54628. shader: string;
  54629. };
  54630. }
  54631. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54632. import { Nullable } from "babylonjs/types";
  54633. import { IAnimatable } from "babylonjs/Misc/tools";
  54634. import { Camera } from "babylonjs/Cameras/camera";
  54635. import { Texture } from "babylonjs/Materials/Textures/texture";
  54636. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54637. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54638. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54639. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54640. import { IDisposable } from "babylonjs/scene";
  54641. import { SpotLight } from "babylonjs/Lights/spotLight";
  54642. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54643. import { Scene } from "babylonjs/scene";
  54644. import { Animation } from "babylonjs/Animations/animation";
  54645. import "babylonjs/Shaders/standard.fragment";
  54646. /**
  54647. * Standard rendering pipeline
  54648. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54649. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54650. */
  54651. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54652. /**
  54653. * Public members
  54654. */
  54655. /**
  54656. * Post-process which contains the original scene color before the pipeline applies all the effects
  54657. */
  54658. originalPostProcess: Nullable<PostProcess>;
  54659. /**
  54660. * Post-process used to down scale an image x4
  54661. */
  54662. downSampleX4PostProcess: Nullable<PostProcess>;
  54663. /**
  54664. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54665. */
  54666. brightPassPostProcess: Nullable<PostProcess>;
  54667. /**
  54668. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54669. */
  54670. blurHPostProcesses: PostProcess[];
  54671. /**
  54672. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54673. */
  54674. blurVPostProcesses: PostProcess[];
  54675. /**
  54676. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54677. */
  54678. textureAdderPostProcess: Nullable<PostProcess>;
  54679. /**
  54680. * Post-process used to create volumetric lighting effect
  54681. */
  54682. volumetricLightPostProcess: Nullable<PostProcess>;
  54683. /**
  54684. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54685. */
  54686. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54687. /**
  54688. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54689. */
  54690. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54691. /**
  54692. * Post-process used to merge the volumetric light effect and the real scene color
  54693. */
  54694. volumetricLightMergePostProces: Nullable<PostProcess>;
  54695. /**
  54696. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54697. */
  54698. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54699. /**
  54700. * Base post-process used to calculate the average luminance of the final image for HDR
  54701. */
  54702. luminancePostProcess: Nullable<PostProcess>;
  54703. /**
  54704. * Post-processes used to create down sample post-processes in order to get
  54705. * the average luminance of the final image for HDR
  54706. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54707. */
  54708. luminanceDownSamplePostProcesses: PostProcess[];
  54709. /**
  54710. * Post-process used to create a HDR effect (light adaptation)
  54711. */
  54712. hdrPostProcess: Nullable<PostProcess>;
  54713. /**
  54714. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54715. */
  54716. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54717. /**
  54718. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54719. */
  54720. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54721. /**
  54722. * Post-process used to merge the final HDR post-process and the real scene color
  54723. */
  54724. hdrFinalPostProcess: Nullable<PostProcess>;
  54725. /**
  54726. * Post-process used to create a lens flare effect
  54727. */
  54728. lensFlarePostProcess: Nullable<PostProcess>;
  54729. /**
  54730. * Post-process that merges the result of the lens flare post-process and the real scene color
  54731. */
  54732. lensFlareComposePostProcess: Nullable<PostProcess>;
  54733. /**
  54734. * Post-process used to create a motion blur effect
  54735. */
  54736. motionBlurPostProcess: Nullable<PostProcess>;
  54737. /**
  54738. * Post-process used to create a depth of field effect
  54739. */
  54740. depthOfFieldPostProcess: Nullable<PostProcess>;
  54741. /**
  54742. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54743. */
  54744. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54745. /**
  54746. * Represents the brightness threshold in order to configure the illuminated surfaces
  54747. */
  54748. brightThreshold: number;
  54749. /**
  54750. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54751. */
  54752. blurWidth: number;
  54753. /**
  54754. * Sets if the blur for highlighted surfaces must be only horizontal
  54755. */
  54756. horizontalBlur: boolean;
  54757. /**
  54758. * Sets the overall exposure used by the pipeline
  54759. */
  54760. exposure: number;
  54761. /**
  54762. * Texture used typically to simulate "dirty" on camera lens
  54763. */
  54764. lensTexture: Nullable<Texture>;
  54765. /**
  54766. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54767. */
  54768. volumetricLightCoefficient: number;
  54769. /**
  54770. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54771. */
  54772. volumetricLightPower: number;
  54773. /**
  54774. * Used the set the blur intensity to smooth the volumetric lights
  54775. */
  54776. volumetricLightBlurScale: number;
  54777. /**
  54778. * Light (spot or directional) used to generate the volumetric lights rays
  54779. * The source light must have a shadow generate so the pipeline can get its
  54780. * depth map
  54781. */
  54782. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54783. /**
  54784. * For eye adaptation, represents the minimum luminance the eye can see
  54785. */
  54786. hdrMinimumLuminance: number;
  54787. /**
  54788. * For eye adaptation, represents the decrease luminance speed
  54789. */
  54790. hdrDecreaseRate: number;
  54791. /**
  54792. * For eye adaptation, represents the increase luminance speed
  54793. */
  54794. hdrIncreaseRate: number;
  54795. /**
  54796. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54797. */
  54798. lensColorTexture: Nullable<Texture>;
  54799. /**
  54800. * The overall strengh for the lens flare effect
  54801. */
  54802. lensFlareStrength: number;
  54803. /**
  54804. * Dispersion coefficient for lens flare ghosts
  54805. */
  54806. lensFlareGhostDispersal: number;
  54807. /**
  54808. * Main lens flare halo width
  54809. */
  54810. lensFlareHaloWidth: number;
  54811. /**
  54812. * Based on the lens distortion effect, defines how much the lens flare result
  54813. * is distorted
  54814. */
  54815. lensFlareDistortionStrength: number;
  54816. /**
  54817. * Lens star texture must be used to simulate rays on the flares and is available
  54818. * in the documentation
  54819. */
  54820. lensStarTexture: Nullable<Texture>;
  54821. /**
  54822. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54823. * flare effect by taking account of the dirt texture
  54824. */
  54825. lensFlareDirtTexture: Nullable<Texture>;
  54826. /**
  54827. * Represents the focal length for the depth of field effect
  54828. */
  54829. depthOfFieldDistance: number;
  54830. /**
  54831. * Represents the blur intensity for the blurred part of the depth of field effect
  54832. */
  54833. depthOfFieldBlurWidth: number;
  54834. /**
  54835. * For motion blur, defines how much the image is blurred by the movement
  54836. */
  54837. motionStrength: number;
  54838. /**
  54839. * List of animations for the pipeline (IAnimatable implementation)
  54840. */
  54841. animations: Animation[];
  54842. /**
  54843. * Private members
  54844. */
  54845. private _scene;
  54846. private _currentDepthOfFieldSource;
  54847. private _basePostProcess;
  54848. private _hdrCurrentLuminance;
  54849. private _floatTextureType;
  54850. private _ratio;
  54851. private _bloomEnabled;
  54852. private _depthOfFieldEnabled;
  54853. private _vlsEnabled;
  54854. private _lensFlareEnabled;
  54855. private _hdrEnabled;
  54856. private _motionBlurEnabled;
  54857. private _fxaaEnabled;
  54858. private _motionBlurSamples;
  54859. private _volumetricLightStepsCount;
  54860. private _samples;
  54861. /**
  54862. * @ignore
  54863. * Specifies if the bloom pipeline is enabled
  54864. */
  54865. BloomEnabled: boolean;
  54866. /**
  54867. * @ignore
  54868. * Specifies if the depth of field pipeline is enabed
  54869. */
  54870. DepthOfFieldEnabled: boolean;
  54871. /**
  54872. * @ignore
  54873. * Specifies if the lens flare pipeline is enabed
  54874. */
  54875. LensFlareEnabled: boolean;
  54876. /**
  54877. * @ignore
  54878. * Specifies if the HDR pipeline is enabled
  54879. */
  54880. HDREnabled: boolean;
  54881. /**
  54882. * @ignore
  54883. * Specifies if the volumetric lights scattering effect is enabled
  54884. */
  54885. VLSEnabled: boolean;
  54886. /**
  54887. * @ignore
  54888. * Specifies if the motion blur effect is enabled
  54889. */
  54890. MotionBlurEnabled: boolean;
  54891. /**
  54892. * Specifies if anti-aliasing is enabled
  54893. */
  54894. fxaaEnabled: boolean;
  54895. /**
  54896. * Specifies the number of steps used to calculate the volumetric lights
  54897. * Typically in interval [50, 200]
  54898. */
  54899. volumetricLightStepsCount: number;
  54900. /**
  54901. * Specifies the number of samples used for the motion blur effect
  54902. * Typically in interval [16, 64]
  54903. */
  54904. motionBlurSamples: number;
  54905. /**
  54906. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54907. */
  54908. samples: number;
  54909. /**
  54910. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54911. * @constructor
  54912. * @param name The rendering pipeline name
  54913. * @param scene The scene linked to this pipeline
  54914. * @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)
  54915. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54916. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54917. */
  54918. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54919. private _buildPipeline;
  54920. private _createDownSampleX4PostProcess;
  54921. private _createBrightPassPostProcess;
  54922. private _createBlurPostProcesses;
  54923. private _createTextureAdderPostProcess;
  54924. private _createVolumetricLightPostProcess;
  54925. private _createLuminancePostProcesses;
  54926. private _createHdrPostProcess;
  54927. private _createLensFlarePostProcess;
  54928. private _createDepthOfFieldPostProcess;
  54929. private _createMotionBlurPostProcess;
  54930. private _getDepthTexture;
  54931. private _disposePostProcesses;
  54932. /**
  54933. * Dispose of the pipeline and stop all post processes
  54934. */
  54935. dispose(): void;
  54936. /**
  54937. * Serialize the rendering pipeline (Used when exporting)
  54938. * @returns the serialized object
  54939. */
  54940. serialize(): any;
  54941. /**
  54942. * Parse the serialized pipeline
  54943. * @param source Source pipeline.
  54944. * @param scene The scene to load the pipeline to.
  54945. * @param rootUrl The URL of the serialized pipeline.
  54946. * @returns An instantiated pipeline from the serialized object.
  54947. */
  54948. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54949. /**
  54950. * Luminance steps
  54951. */
  54952. static LuminanceSteps: number;
  54953. }
  54954. }
  54955. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54956. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54957. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54958. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54959. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54960. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54961. }
  54962. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54963. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54964. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54965. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54966. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54967. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54968. }
  54969. declare module "babylonjs/Shaders/tonemap.fragment" {
  54970. /** @hidden */
  54971. export var tonemapPixelShader: {
  54972. name: string;
  54973. shader: string;
  54974. };
  54975. }
  54976. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54977. import { Camera } from "babylonjs/Cameras/camera";
  54978. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54979. import "babylonjs/Shaders/tonemap.fragment";
  54980. import { Engine } from "babylonjs/Engines/engine";
  54981. /** Defines operator used for tonemapping */
  54982. export enum TonemappingOperator {
  54983. /** Hable */
  54984. Hable = 0,
  54985. /** Reinhard */
  54986. Reinhard = 1,
  54987. /** HejiDawson */
  54988. HejiDawson = 2,
  54989. /** Photographic */
  54990. Photographic = 3
  54991. }
  54992. /**
  54993. * Defines a post process to apply tone mapping
  54994. */
  54995. export class TonemapPostProcess extends PostProcess {
  54996. private _operator;
  54997. /** Defines the required exposure adjustement */
  54998. exposureAdjustment: number;
  54999. /**
  55000. * Creates a new TonemapPostProcess
  55001. * @param name defines the name of the postprocess
  55002. * @param _operator defines the operator to use
  55003. * @param exposureAdjustment defines the required exposure adjustement
  55004. * @param camera defines the camera to use (can be null)
  55005. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55006. * @param engine defines the hosting engine (can be ignore if camera is set)
  55007. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55008. */
  55009. constructor(name: string, _operator: TonemappingOperator,
  55010. /** Defines the required exposure adjustement */
  55011. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55012. }
  55013. }
  55014. declare module "babylonjs/Shaders/depth.vertex" {
  55015. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55016. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55017. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55018. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55019. /** @hidden */
  55020. export var depthVertexShader: {
  55021. name: string;
  55022. shader: string;
  55023. };
  55024. }
  55025. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55026. /** @hidden */
  55027. export var volumetricLightScatteringPixelShader: {
  55028. name: string;
  55029. shader: string;
  55030. };
  55031. }
  55032. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55033. /** @hidden */
  55034. export var volumetricLightScatteringPassPixelShader: {
  55035. name: string;
  55036. shader: string;
  55037. };
  55038. }
  55039. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55040. import { Vector3 } from "babylonjs/Maths/math";
  55041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55042. import { Mesh } from "babylonjs/Meshes/mesh";
  55043. import { Camera } from "babylonjs/Cameras/camera";
  55044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55045. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55046. import { Scene } from "babylonjs/scene";
  55047. import "babylonjs/Meshes/Builders/planeBuilder";
  55048. import "babylonjs/Shaders/depth.vertex";
  55049. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55050. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55051. import { Engine } from "babylonjs/Engines/engine";
  55052. /**
  55053. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55054. */
  55055. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55056. private _volumetricLightScatteringPass;
  55057. private _volumetricLightScatteringRTT;
  55058. private _viewPort;
  55059. private _screenCoordinates;
  55060. private _cachedDefines;
  55061. /**
  55062. * If not undefined, the mesh position is computed from the attached node position
  55063. */
  55064. attachedNode: {
  55065. position: Vector3;
  55066. };
  55067. /**
  55068. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55069. */
  55070. customMeshPosition: Vector3;
  55071. /**
  55072. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55073. */
  55074. useCustomMeshPosition: boolean;
  55075. /**
  55076. * If the post-process should inverse the light scattering direction
  55077. */
  55078. invert: boolean;
  55079. /**
  55080. * The internal mesh used by the post-process
  55081. */
  55082. mesh: Mesh;
  55083. /**
  55084. * @hidden
  55085. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55086. */
  55087. useDiffuseColor: boolean;
  55088. /**
  55089. * Array containing the excluded meshes not rendered in the internal pass
  55090. */
  55091. excludedMeshes: AbstractMesh[];
  55092. /**
  55093. * Controls the overall intensity of the post-process
  55094. */
  55095. exposure: number;
  55096. /**
  55097. * Dissipates each sample's contribution in range [0, 1]
  55098. */
  55099. decay: number;
  55100. /**
  55101. * Controls the overall intensity of each sample
  55102. */
  55103. weight: number;
  55104. /**
  55105. * Controls the density of each sample
  55106. */
  55107. density: number;
  55108. /**
  55109. * @constructor
  55110. * @param name The post-process name
  55111. * @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)
  55112. * @param camera The camera that the post-process will be attached to
  55113. * @param mesh The mesh used to create the light scattering
  55114. * @param samples The post-process quality, default 100
  55115. * @param samplingModeThe post-process filtering mode
  55116. * @param engine The babylon engine
  55117. * @param reusable If the post-process is reusable
  55118. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55119. */
  55120. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55121. /**
  55122. * Returns the string "VolumetricLightScatteringPostProcess"
  55123. * @returns "VolumetricLightScatteringPostProcess"
  55124. */
  55125. getClassName(): string;
  55126. private _isReady;
  55127. /**
  55128. * Sets the new light position for light scattering effect
  55129. * @param position The new custom light position
  55130. */
  55131. setCustomMeshPosition(position: Vector3): void;
  55132. /**
  55133. * Returns the light position for light scattering effect
  55134. * @return Vector3 The custom light position
  55135. */
  55136. getCustomMeshPosition(): Vector3;
  55137. /**
  55138. * Disposes the internal assets and detaches the post-process from the camera
  55139. */
  55140. dispose(camera: Camera): void;
  55141. /**
  55142. * Returns the render target texture used by the post-process
  55143. * @return the render target texture used by the post-process
  55144. */
  55145. getPass(): RenderTargetTexture;
  55146. private _meshExcluded;
  55147. private _createPass;
  55148. private _updateMeshScreenCoordinates;
  55149. /**
  55150. * Creates a default mesh for the Volumeric Light Scattering post-process
  55151. * @param name The mesh name
  55152. * @param scene The scene where to create the mesh
  55153. * @return the default mesh
  55154. */
  55155. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55156. }
  55157. }
  55158. declare module "babylonjs/PostProcesses/index" {
  55159. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55160. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55161. export * from "babylonjs/PostProcesses/bloomEffect";
  55162. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55163. export * from "babylonjs/PostProcesses/blurPostProcess";
  55164. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55165. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55166. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55167. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55168. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55169. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55170. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55171. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55172. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55173. export * from "babylonjs/PostProcesses/filterPostProcess";
  55174. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55175. export * from "babylonjs/PostProcesses/grainPostProcess";
  55176. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55177. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55178. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55179. export * from "babylonjs/PostProcesses/passPostProcess";
  55180. export * from "babylonjs/PostProcesses/postProcess";
  55181. export * from "babylonjs/PostProcesses/postProcessManager";
  55182. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55183. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55184. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55185. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55186. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55187. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55188. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55189. }
  55190. declare module "babylonjs/Probes/index" {
  55191. export * from "babylonjs/Probes/reflectionProbe";
  55192. }
  55193. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55194. import { Scene } from "babylonjs/scene";
  55195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55196. import { Color3 } from "babylonjs/Maths/math";
  55197. import { SmartArray } from "babylonjs/Misc/smartArray";
  55198. import { ISceneComponent } from "babylonjs/sceneComponent";
  55199. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55200. import "babylonjs/Meshes/Builders/boxBuilder";
  55201. import "babylonjs/Shaders/color.fragment";
  55202. import "babylonjs/Shaders/color.vertex";
  55203. module "babylonjs/scene" {
  55204. interface Scene {
  55205. /** @hidden (Backing field) */
  55206. _boundingBoxRenderer: BoundingBoxRenderer;
  55207. /** @hidden (Backing field) */
  55208. _forceShowBoundingBoxes: boolean;
  55209. /**
  55210. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55211. */
  55212. forceShowBoundingBoxes: boolean;
  55213. /**
  55214. * Gets the bounding box renderer associated with the scene
  55215. * @returns a BoundingBoxRenderer
  55216. */
  55217. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55218. }
  55219. }
  55220. module "babylonjs/Meshes/abstractMesh" {
  55221. interface AbstractMesh {
  55222. /** @hidden (Backing field) */
  55223. _showBoundingBox: boolean;
  55224. /**
  55225. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55226. */
  55227. showBoundingBox: boolean;
  55228. }
  55229. }
  55230. /**
  55231. * Component responsible of rendering the bounding box of the meshes in a scene.
  55232. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55233. */
  55234. export class BoundingBoxRenderer implements ISceneComponent {
  55235. /**
  55236. * The component name helpfull to identify the component in the list of scene components.
  55237. */
  55238. readonly name: string;
  55239. /**
  55240. * The scene the component belongs to.
  55241. */
  55242. scene: Scene;
  55243. /**
  55244. * Color of the bounding box lines placed in front of an object
  55245. */
  55246. frontColor: Color3;
  55247. /**
  55248. * Color of the bounding box lines placed behind an object
  55249. */
  55250. backColor: Color3;
  55251. /**
  55252. * Defines if the renderer should show the back lines or not
  55253. */
  55254. showBackLines: boolean;
  55255. /**
  55256. * @hidden
  55257. */
  55258. renderList: SmartArray<BoundingBox>;
  55259. private _colorShader;
  55260. private _vertexBuffers;
  55261. private _indexBuffer;
  55262. /**
  55263. * Instantiates a new bounding box renderer in a scene.
  55264. * @param scene the scene the renderer renders in
  55265. */
  55266. constructor(scene: Scene);
  55267. /**
  55268. * Registers the component in a given scene
  55269. */
  55270. register(): void;
  55271. private _evaluateSubMesh;
  55272. private _activeMesh;
  55273. private _prepareRessources;
  55274. private _createIndexBuffer;
  55275. /**
  55276. * Rebuilds the elements related to this component in case of
  55277. * context lost for instance.
  55278. */
  55279. rebuild(): void;
  55280. /**
  55281. * @hidden
  55282. */
  55283. reset(): void;
  55284. /**
  55285. * Render the bounding boxes of a specific rendering group
  55286. * @param renderingGroupId defines the rendering group to render
  55287. */
  55288. render(renderingGroupId: number): void;
  55289. /**
  55290. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55291. * @param mesh Define the mesh to render the occlusion bounding box for
  55292. */
  55293. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55294. /**
  55295. * Dispose and release the resources attached to this renderer.
  55296. */
  55297. dispose(): void;
  55298. }
  55299. }
  55300. declare module "babylonjs/Shaders/depth.fragment" {
  55301. /** @hidden */
  55302. export var depthPixelShader: {
  55303. name: string;
  55304. shader: string;
  55305. };
  55306. }
  55307. declare module "babylonjs/Rendering/depthRenderer" {
  55308. import { Nullable } from "babylonjs/types";
  55309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55310. import { Scene } from "babylonjs/scene";
  55311. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55312. import { Camera } from "babylonjs/Cameras/camera";
  55313. import "babylonjs/Shaders/depth.fragment";
  55314. import "babylonjs/Shaders/depth.vertex";
  55315. /**
  55316. * This represents a depth renderer in Babylon.
  55317. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55318. */
  55319. export class DepthRenderer {
  55320. private _scene;
  55321. private _depthMap;
  55322. private _effect;
  55323. private _cachedDefines;
  55324. private _camera;
  55325. /**
  55326. * Specifiess that the depth renderer will only be used within
  55327. * the camera it is created for.
  55328. * This can help forcing its rendering during the camera processing.
  55329. */
  55330. useOnlyInActiveCamera: boolean;
  55331. /** @hidden */
  55332. static _SceneComponentInitialization: (scene: Scene) => void;
  55333. /**
  55334. * Instantiates a depth renderer
  55335. * @param scene The scene the renderer belongs to
  55336. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55337. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55338. */
  55339. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55340. /**
  55341. * Creates the depth rendering effect and checks if the effect is ready.
  55342. * @param subMesh The submesh to be used to render the depth map of
  55343. * @param useInstances If multiple world instances should be used
  55344. * @returns if the depth renderer is ready to render the depth map
  55345. */
  55346. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55347. /**
  55348. * Gets the texture which the depth map will be written to.
  55349. * @returns The depth map texture
  55350. */
  55351. getDepthMap(): RenderTargetTexture;
  55352. /**
  55353. * Disposes of the depth renderer.
  55354. */
  55355. dispose(): void;
  55356. }
  55357. }
  55358. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55359. import { Nullable } from "babylonjs/types";
  55360. import { Scene } from "babylonjs/scene";
  55361. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55362. import { Camera } from "babylonjs/Cameras/camera";
  55363. import { ISceneComponent } from "babylonjs/sceneComponent";
  55364. module "babylonjs/scene" {
  55365. interface Scene {
  55366. /** @hidden (Backing field) */
  55367. _depthRenderer: {
  55368. [id: string]: DepthRenderer;
  55369. };
  55370. /**
  55371. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55372. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55373. * @returns the created depth renderer
  55374. */
  55375. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55376. /**
  55377. * Disables a depth renderer for a given camera
  55378. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55379. */
  55380. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55381. }
  55382. }
  55383. /**
  55384. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55385. * in several rendering techniques.
  55386. */
  55387. export class DepthRendererSceneComponent implements ISceneComponent {
  55388. /**
  55389. * The component name helpfull to identify the component in the list of scene components.
  55390. */
  55391. readonly name: string;
  55392. /**
  55393. * The scene the component belongs to.
  55394. */
  55395. scene: Scene;
  55396. /**
  55397. * Creates a new instance of the component for the given scene
  55398. * @param scene Defines the scene to register the component in
  55399. */
  55400. constructor(scene: Scene);
  55401. /**
  55402. * Registers the component in a given scene
  55403. */
  55404. register(): void;
  55405. /**
  55406. * Rebuilds the elements related to this component in case of
  55407. * context lost for instance.
  55408. */
  55409. rebuild(): void;
  55410. /**
  55411. * Disposes the component and the associated ressources
  55412. */
  55413. dispose(): void;
  55414. private _gatherRenderTargets;
  55415. private _gatherActiveCameraRenderTargets;
  55416. }
  55417. }
  55418. declare module "babylonjs/Shaders/outline.fragment" {
  55419. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55420. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55421. /** @hidden */
  55422. export var outlinePixelShader: {
  55423. name: string;
  55424. shader: string;
  55425. };
  55426. }
  55427. declare module "babylonjs/Shaders/outline.vertex" {
  55428. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55429. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55430. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55431. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55432. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55433. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55434. /** @hidden */
  55435. export var outlineVertexShader: {
  55436. name: string;
  55437. shader: string;
  55438. };
  55439. }
  55440. declare module "babylonjs/Rendering/outlineRenderer" {
  55441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55442. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55443. import { Scene } from "babylonjs/scene";
  55444. import { ISceneComponent } from "babylonjs/sceneComponent";
  55445. import "babylonjs/Shaders/outline.fragment";
  55446. import "babylonjs/Shaders/outline.vertex";
  55447. module "babylonjs/scene" {
  55448. interface Scene {
  55449. /** @hidden */
  55450. _outlineRenderer: OutlineRenderer;
  55451. /**
  55452. * Gets the outline renderer associated with the scene
  55453. * @returns a OutlineRenderer
  55454. */
  55455. getOutlineRenderer(): OutlineRenderer;
  55456. }
  55457. }
  55458. module "babylonjs/Meshes/abstractMesh" {
  55459. interface AbstractMesh {
  55460. /** @hidden (Backing field) */
  55461. _renderOutline: boolean;
  55462. /**
  55463. * Gets or sets a boolean indicating if the outline must be rendered as well
  55464. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55465. */
  55466. renderOutline: boolean;
  55467. /** @hidden (Backing field) */
  55468. _renderOverlay: boolean;
  55469. /**
  55470. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55471. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55472. */
  55473. renderOverlay: boolean;
  55474. }
  55475. }
  55476. /**
  55477. * This class is responsible to draw bothe outline/overlay of meshes.
  55478. * It should not be used directly but through the available method on mesh.
  55479. */
  55480. export class OutlineRenderer implements ISceneComponent {
  55481. /**
  55482. * The name of the component. Each component must have a unique name.
  55483. */
  55484. name: string;
  55485. /**
  55486. * The scene the component belongs to.
  55487. */
  55488. scene: Scene;
  55489. /**
  55490. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55491. */
  55492. zOffset: number;
  55493. private _engine;
  55494. private _effect;
  55495. private _cachedDefines;
  55496. private _savedDepthWrite;
  55497. /**
  55498. * Instantiates a new outline renderer. (There could be only one per scene).
  55499. * @param scene Defines the scene it belongs to
  55500. */
  55501. constructor(scene: Scene);
  55502. /**
  55503. * Register the component to one instance of a scene.
  55504. */
  55505. register(): void;
  55506. /**
  55507. * Rebuilds the elements related to this component in case of
  55508. * context lost for instance.
  55509. */
  55510. rebuild(): void;
  55511. /**
  55512. * Disposes the component and the associated ressources.
  55513. */
  55514. dispose(): void;
  55515. /**
  55516. * Renders the outline in the canvas.
  55517. * @param subMesh Defines the sumesh to render
  55518. * @param batch Defines the batch of meshes in case of instances
  55519. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55520. */
  55521. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55522. /**
  55523. * Returns whether or not the outline renderer is ready for a given submesh.
  55524. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55525. * @param subMesh Defines the submesh to check readyness for
  55526. * @param useInstances Defines wheter wee are trying to render instances or not
  55527. * @returns true if ready otherwise false
  55528. */
  55529. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55530. private _beforeRenderingMesh;
  55531. private _afterRenderingMesh;
  55532. }
  55533. }
  55534. declare module "babylonjs/Rendering/index" {
  55535. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55536. export * from "babylonjs/Rendering/depthRenderer";
  55537. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55538. export * from "babylonjs/Rendering/edgesRenderer";
  55539. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55540. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55541. export * from "babylonjs/Rendering/outlineRenderer";
  55542. export * from "babylonjs/Rendering/renderingGroup";
  55543. export * from "babylonjs/Rendering/renderingManager";
  55544. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55545. }
  55546. declare module "babylonjs/Sprites/index" {
  55547. export * from "babylonjs/Sprites/sprite";
  55548. export * from "babylonjs/Sprites/spriteManager";
  55549. export * from "babylonjs/Sprites/spriteSceneComponent";
  55550. }
  55551. declare module "babylonjs/Misc/assetsManager" {
  55552. import { Scene } from "babylonjs/scene";
  55553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55554. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55555. import { Skeleton } from "babylonjs/Bones/skeleton";
  55556. import { Observable } from "babylonjs/Misc/observable";
  55557. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55558. import { Texture } from "babylonjs/Materials/Textures/texture";
  55559. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55560. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55561. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55562. /**
  55563. * Defines the list of states available for a task inside a AssetsManager
  55564. */
  55565. export enum AssetTaskState {
  55566. /**
  55567. * Initialization
  55568. */
  55569. INIT = 0,
  55570. /**
  55571. * Running
  55572. */
  55573. RUNNING = 1,
  55574. /**
  55575. * Done
  55576. */
  55577. DONE = 2,
  55578. /**
  55579. * Error
  55580. */
  55581. ERROR = 3
  55582. }
  55583. /**
  55584. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55585. */
  55586. export abstract class AbstractAssetTask {
  55587. /**
  55588. * Task name
  55589. */ name: string;
  55590. /**
  55591. * Callback called when the task is successful
  55592. */
  55593. onSuccess: (task: any) => void;
  55594. /**
  55595. * Callback called when the task is not successful
  55596. */
  55597. onError: (task: any, message?: string, exception?: any) => void;
  55598. /**
  55599. * Creates a new AssetsManager
  55600. * @param name defines the name of the task
  55601. */
  55602. constructor(
  55603. /**
  55604. * Task name
  55605. */ name: string);
  55606. private _isCompleted;
  55607. private _taskState;
  55608. private _errorObject;
  55609. /**
  55610. * Get if the task is completed
  55611. */
  55612. readonly isCompleted: boolean;
  55613. /**
  55614. * Gets the current state of the task
  55615. */
  55616. readonly taskState: AssetTaskState;
  55617. /**
  55618. * Gets the current error object (if task is in error)
  55619. */
  55620. readonly errorObject: {
  55621. message?: string;
  55622. exception?: any;
  55623. };
  55624. /**
  55625. * Internal only
  55626. * @hidden
  55627. */
  55628. _setErrorObject(message?: string, exception?: any): void;
  55629. /**
  55630. * Execute the current task
  55631. * @param scene defines the scene where you want your assets to be loaded
  55632. * @param onSuccess is a callback called when the task is successfully executed
  55633. * @param onError is a callback called if an error occurs
  55634. */
  55635. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55636. /**
  55637. * Execute the current task
  55638. * @param scene defines the scene where you want your assets to be loaded
  55639. * @param onSuccess is a callback called when the task is successfully executed
  55640. * @param onError is a callback called if an error occurs
  55641. */
  55642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55643. /**
  55644. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55645. * This can be used with failed tasks that have the reason for failure fixed.
  55646. */
  55647. reset(): void;
  55648. private onErrorCallback;
  55649. private onDoneCallback;
  55650. }
  55651. /**
  55652. * Define the interface used by progress events raised during assets loading
  55653. */
  55654. export interface IAssetsProgressEvent {
  55655. /**
  55656. * Defines the number of remaining tasks to process
  55657. */
  55658. remainingCount: number;
  55659. /**
  55660. * Defines the total number of tasks
  55661. */
  55662. totalCount: number;
  55663. /**
  55664. * Defines the task that was just processed
  55665. */
  55666. task: AbstractAssetTask;
  55667. }
  55668. /**
  55669. * Class used to share progress information about assets loading
  55670. */
  55671. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55672. /**
  55673. * Defines the number of remaining tasks to process
  55674. */
  55675. remainingCount: number;
  55676. /**
  55677. * Defines the total number of tasks
  55678. */
  55679. totalCount: number;
  55680. /**
  55681. * Defines the task that was just processed
  55682. */
  55683. task: AbstractAssetTask;
  55684. /**
  55685. * Creates a AssetsProgressEvent
  55686. * @param remainingCount defines the number of remaining tasks to process
  55687. * @param totalCount defines the total number of tasks
  55688. * @param task defines the task that was just processed
  55689. */
  55690. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55691. }
  55692. /**
  55693. * Define a task used by AssetsManager to load meshes
  55694. */
  55695. export class MeshAssetTask extends AbstractAssetTask {
  55696. /**
  55697. * Defines the name of the task
  55698. */
  55699. name: string;
  55700. /**
  55701. * Defines the list of mesh's names you want to load
  55702. */
  55703. meshesNames: any;
  55704. /**
  55705. * Defines the root url to use as a base to load your meshes and associated resources
  55706. */
  55707. rootUrl: string;
  55708. /**
  55709. * Defines the filename of the scene to load from
  55710. */
  55711. sceneFilename: string;
  55712. /**
  55713. * Gets the list of loaded meshes
  55714. */
  55715. loadedMeshes: Array<AbstractMesh>;
  55716. /**
  55717. * Gets the list of loaded particle systems
  55718. */
  55719. loadedParticleSystems: Array<IParticleSystem>;
  55720. /**
  55721. * Gets the list of loaded skeletons
  55722. */
  55723. loadedSkeletons: Array<Skeleton>;
  55724. /**
  55725. * Gets the list of loaded animation groups
  55726. */
  55727. loadedAnimationGroups: Array<AnimationGroup>;
  55728. /**
  55729. * Callback called when the task is successful
  55730. */
  55731. onSuccess: (task: MeshAssetTask) => void;
  55732. /**
  55733. * Callback called when the task is successful
  55734. */
  55735. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55736. /**
  55737. * Creates a new MeshAssetTask
  55738. * @param name defines the name of the task
  55739. * @param meshesNames defines the list of mesh's names you want to load
  55740. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55741. * @param sceneFilename defines the filename of the scene to load from
  55742. */
  55743. constructor(
  55744. /**
  55745. * Defines the name of the task
  55746. */
  55747. name: string,
  55748. /**
  55749. * Defines the list of mesh's names you want to load
  55750. */
  55751. meshesNames: any,
  55752. /**
  55753. * Defines the root url to use as a base to load your meshes and associated resources
  55754. */
  55755. rootUrl: string,
  55756. /**
  55757. * Defines the filename of the scene to load from
  55758. */
  55759. sceneFilename: string);
  55760. /**
  55761. * Execute the current task
  55762. * @param scene defines the scene where you want your assets to be loaded
  55763. * @param onSuccess is a callback called when the task is successfully executed
  55764. * @param onError is a callback called if an error occurs
  55765. */
  55766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55767. }
  55768. /**
  55769. * Define a task used by AssetsManager to load text content
  55770. */
  55771. export class TextFileAssetTask extends AbstractAssetTask {
  55772. /**
  55773. * Defines the name of the task
  55774. */
  55775. name: string;
  55776. /**
  55777. * Defines the location of the file to load
  55778. */
  55779. url: string;
  55780. /**
  55781. * Gets the loaded text string
  55782. */
  55783. text: string;
  55784. /**
  55785. * Callback called when the task is successful
  55786. */
  55787. onSuccess: (task: TextFileAssetTask) => void;
  55788. /**
  55789. * Callback called when the task is successful
  55790. */
  55791. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55792. /**
  55793. * Creates a new TextFileAssetTask object
  55794. * @param name defines the name of the task
  55795. * @param url defines the location of the file to load
  55796. */
  55797. constructor(
  55798. /**
  55799. * Defines the name of the task
  55800. */
  55801. name: string,
  55802. /**
  55803. * Defines the location of the file to load
  55804. */
  55805. url: string);
  55806. /**
  55807. * Execute the current task
  55808. * @param scene defines the scene where you want your assets to be loaded
  55809. * @param onSuccess is a callback called when the task is successfully executed
  55810. * @param onError is a callback called if an error occurs
  55811. */
  55812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55813. }
  55814. /**
  55815. * Define a task used by AssetsManager to load binary data
  55816. */
  55817. export class BinaryFileAssetTask extends AbstractAssetTask {
  55818. /**
  55819. * Defines the name of the task
  55820. */
  55821. name: string;
  55822. /**
  55823. * Defines the location of the file to load
  55824. */
  55825. url: string;
  55826. /**
  55827. * Gets the lodaded data (as an array buffer)
  55828. */
  55829. data: ArrayBuffer;
  55830. /**
  55831. * Callback called when the task is successful
  55832. */
  55833. onSuccess: (task: BinaryFileAssetTask) => void;
  55834. /**
  55835. * Callback called when the task is successful
  55836. */
  55837. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55838. /**
  55839. * Creates a new BinaryFileAssetTask object
  55840. * @param name defines the name of the new task
  55841. * @param url defines the location of the file to load
  55842. */
  55843. constructor(
  55844. /**
  55845. * Defines the name of the task
  55846. */
  55847. name: string,
  55848. /**
  55849. * Defines the location of the file to load
  55850. */
  55851. url: string);
  55852. /**
  55853. * Execute the current task
  55854. * @param scene defines the scene where you want your assets to be loaded
  55855. * @param onSuccess is a callback called when the task is successfully executed
  55856. * @param onError is a callback called if an error occurs
  55857. */
  55858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55859. }
  55860. /**
  55861. * Define a task used by AssetsManager to load images
  55862. */
  55863. export class ImageAssetTask extends AbstractAssetTask {
  55864. /**
  55865. * Defines the name of the task
  55866. */
  55867. name: string;
  55868. /**
  55869. * Defines the location of the image to load
  55870. */
  55871. url: string;
  55872. /**
  55873. * Gets the loaded images
  55874. */
  55875. image: HTMLImageElement;
  55876. /**
  55877. * Callback called when the task is successful
  55878. */
  55879. onSuccess: (task: ImageAssetTask) => void;
  55880. /**
  55881. * Callback called when the task is successful
  55882. */
  55883. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55884. /**
  55885. * Creates a new ImageAssetTask
  55886. * @param name defines the name of the task
  55887. * @param url defines the location of the image to load
  55888. */
  55889. constructor(
  55890. /**
  55891. * Defines the name of the task
  55892. */
  55893. name: string,
  55894. /**
  55895. * Defines the location of the image to load
  55896. */
  55897. url: string);
  55898. /**
  55899. * Execute the current task
  55900. * @param scene defines the scene where you want your assets to be loaded
  55901. * @param onSuccess is a callback called when the task is successfully executed
  55902. * @param onError is a callback called if an error occurs
  55903. */
  55904. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55905. }
  55906. /**
  55907. * Defines the interface used by texture loading tasks
  55908. */
  55909. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55910. /**
  55911. * Gets the loaded texture
  55912. */
  55913. texture: TEX;
  55914. }
  55915. /**
  55916. * Define a task used by AssetsManager to load 2D textures
  55917. */
  55918. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55919. /**
  55920. * Defines the name of the task
  55921. */
  55922. name: string;
  55923. /**
  55924. * Defines the location of the file to load
  55925. */
  55926. url: string;
  55927. /**
  55928. * Defines if mipmap should not be generated (default is false)
  55929. */
  55930. noMipmap?: boolean | undefined;
  55931. /**
  55932. * Defines if texture must be inverted on Y axis (default is false)
  55933. */
  55934. invertY?: boolean | undefined;
  55935. /**
  55936. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55937. */
  55938. samplingMode: number;
  55939. /**
  55940. * Gets the loaded texture
  55941. */
  55942. texture: Texture;
  55943. /**
  55944. * Callback called when the task is successful
  55945. */
  55946. onSuccess: (task: TextureAssetTask) => void;
  55947. /**
  55948. * Callback called when the task is successful
  55949. */
  55950. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55951. /**
  55952. * Creates a new TextureAssetTask object
  55953. * @param name defines the name of the task
  55954. * @param url defines the location of the file to load
  55955. * @param noMipmap defines if mipmap should not be generated (default is false)
  55956. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55957. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55958. */
  55959. constructor(
  55960. /**
  55961. * Defines the name of the task
  55962. */
  55963. name: string,
  55964. /**
  55965. * Defines the location of the file to load
  55966. */
  55967. url: string,
  55968. /**
  55969. * Defines if mipmap should not be generated (default is false)
  55970. */
  55971. noMipmap?: boolean | undefined,
  55972. /**
  55973. * Defines if texture must be inverted on Y axis (default is false)
  55974. */
  55975. invertY?: boolean | undefined,
  55976. /**
  55977. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55978. */
  55979. samplingMode?: number);
  55980. /**
  55981. * Execute the current task
  55982. * @param scene defines the scene where you want your assets to be loaded
  55983. * @param onSuccess is a callback called when the task is successfully executed
  55984. * @param onError is a callback called if an error occurs
  55985. */
  55986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55987. }
  55988. /**
  55989. * Define a task used by AssetsManager to load cube textures
  55990. */
  55991. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55992. /**
  55993. * Defines the name of the task
  55994. */
  55995. name: string;
  55996. /**
  55997. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55998. */
  55999. url: string;
  56000. /**
  56001. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56002. */
  56003. extensions?: string[] | undefined;
  56004. /**
  56005. * Defines if mipmaps should not be generated (default is false)
  56006. */
  56007. noMipmap?: boolean | undefined;
  56008. /**
  56009. * Defines the explicit list of files (undefined by default)
  56010. */
  56011. files?: string[] | undefined;
  56012. /**
  56013. * Gets the loaded texture
  56014. */
  56015. texture: CubeTexture;
  56016. /**
  56017. * Callback called when the task is successful
  56018. */
  56019. onSuccess: (task: CubeTextureAssetTask) => void;
  56020. /**
  56021. * Callback called when the task is successful
  56022. */
  56023. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56024. /**
  56025. * Creates a new CubeTextureAssetTask
  56026. * @param name defines the name of the task
  56027. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56028. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56029. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56030. * @param files defines the explicit list of files (undefined by default)
  56031. */
  56032. constructor(
  56033. /**
  56034. * Defines the name of the task
  56035. */
  56036. name: string,
  56037. /**
  56038. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56039. */
  56040. url: string,
  56041. /**
  56042. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56043. */
  56044. extensions?: string[] | undefined,
  56045. /**
  56046. * Defines if mipmaps should not be generated (default is false)
  56047. */
  56048. noMipmap?: boolean | undefined,
  56049. /**
  56050. * Defines the explicit list of files (undefined by default)
  56051. */
  56052. files?: string[] | undefined);
  56053. /**
  56054. * Execute the current task
  56055. * @param scene defines the scene where you want your assets to be loaded
  56056. * @param onSuccess is a callback called when the task is successfully executed
  56057. * @param onError is a callback called if an error occurs
  56058. */
  56059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56060. }
  56061. /**
  56062. * Define a task used by AssetsManager to load HDR cube textures
  56063. */
  56064. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56065. /**
  56066. * Defines the name of the task
  56067. */
  56068. name: string;
  56069. /**
  56070. * Defines the location of the file to load
  56071. */
  56072. url: string;
  56073. /**
  56074. * Defines the desired size (the more it increases the longer the generation will be)
  56075. */
  56076. size: number;
  56077. /**
  56078. * Defines if mipmaps should not be generated (default is false)
  56079. */
  56080. noMipmap: boolean;
  56081. /**
  56082. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56083. */
  56084. generateHarmonics: boolean;
  56085. /**
  56086. * 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)
  56087. */
  56088. gammaSpace: boolean;
  56089. /**
  56090. * Internal Use Only
  56091. */
  56092. reserved: boolean;
  56093. /**
  56094. * Gets the loaded texture
  56095. */
  56096. texture: HDRCubeTexture;
  56097. /**
  56098. * Callback called when the task is successful
  56099. */
  56100. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56101. /**
  56102. * Callback called when the task is successful
  56103. */
  56104. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56105. /**
  56106. * Creates a new HDRCubeTextureAssetTask object
  56107. * @param name defines the name of the task
  56108. * @param url defines the location of the file to load
  56109. * @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.
  56110. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56111. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56112. * @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)
  56113. * @param reserved Internal use only
  56114. */
  56115. constructor(
  56116. /**
  56117. * Defines the name of the task
  56118. */
  56119. name: string,
  56120. /**
  56121. * Defines the location of the file to load
  56122. */
  56123. url: string,
  56124. /**
  56125. * Defines the desired size (the more it increases the longer the generation will be)
  56126. */
  56127. size: number,
  56128. /**
  56129. * Defines if mipmaps should not be generated (default is false)
  56130. */
  56131. noMipmap?: boolean,
  56132. /**
  56133. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56134. */
  56135. generateHarmonics?: boolean,
  56136. /**
  56137. * 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)
  56138. */
  56139. gammaSpace?: boolean,
  56140. /**
  56141. * Internal Use Only
  56142. */
  56143. reserved?: boolean);
  56144. /**
  56145. * Execute the current task
  56146. * @param scene defines the scene where you want your assets to be loaded
  56147. * @param onSuccess is a callback called when the task is successfully executed
  56148. * @param onError is a callback called if an error occurs
  56149. */
  56150. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56151. }
  56152. /**
  56153. * This class can be used to easily import assets into a scene
  56154. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56155. */
  56156. export class AssetsManager {
  56157. private _scene;
  56158. private _isLoading;
  56159. protected _tasks: AbstractAssetTask[];
  56160. protected _waitingTasksCount: number;
  56161. protected _totalTasksCount: number;
  56162. /**
  56163. * Callback called when all tasks are processed
  56164. */
  56165. onFinish: (tasks: AbstractAssetTask[]) => void;
  56166. /**
  56167. * Callback called when a task is successful
  56168. */
  56169. onTaskSuccess: (task: AbstractAssetTask) => void;
  56170. /**
  56171. * Callback called when a task had an error
  56172. */
  56173. onTaskError: (task: AbstractAssetTask) => void;
  56174. /**
  56175. * Callback called when a task is done (whatever the result is)
  56176. */
  56177. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56178. /**
  56179. * Observable called when all tasks are processed
  56180. */
  56181. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56182. /**
  56183. * Observable called when a task had an error
  56184. */
  56185. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56186. /**
  56187. * Observable called when a task is successful
  56188. */
  56189. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56190. /**
  56191. * Observable called when a task is done (whatever the result is)
  56192. */
  56193. onProgressObservable: Observable<IAssetsProgressEvent>;
  56194. /**
  56195. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56197. */
  56198. useDefaultLoadingScreen: boolean;
  56199. /**
  56200. * Creates a new AssetsManager
  56201. * @param scene defines the scene to work on
  56202. */
  56203. constructor(scene: Scene);
  56204. /**
  56205. * Add a MeshAssetTask to the list of active tasks
  56206. * @param taskName defines the name of the new task
  56207. * @param meshesNames defines the name of meshes to load
  56208. * @param rootUrl defines the root url to use to locate files
  56209. * @param sceneFilename defines the filename of the scene file
  56210. * @returns a new MeshAssetTask object
  56211. */
  56212. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56213. /**
  56214. * Add a TextFileAssetTask to the list of active tasks
  56215. * @param taskName defines the name of the new task
  56216. * @param url defines the url of the file to load
  56217. * @returns a new TextFileAssetTask object
  56218. */
  56219. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56220. /**
  56221. * Add a BinaryFileAssetTask to the list of active tasks
  56222. * @param taskName defines the name of the new task
  56223. * @param url defines the url of the file to load
  56224. * @returns a new BinaryFileAssetTask object
  56225. */
  56226. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56227. /**
  56228. * Add a ImageAssetTask to the list of active tasks
  56229. * @param taskName defines the name of the new task
  56230. * @param url defines the url of the file to load
  56231. * @returns a new ImageAssetTask object
  56232. */
  56233. addImageTask(taskName: string, url: string): ImageAssetTask;
  56234. /**
  56235. * Add a TextureAssetTask to the list of active tasks
  56236. * @param taskName defines the name of the new task
  56237. * @param url defines the url of the file to load
  56238. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56239. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56240. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56241. * @returns a new TextureAssetTask object
  56242. */
  56243. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56244. /**
  56245. * Add a CubeTextureAssetTask to the list of active tasks
  56246. * @param taskName defines the name of the new task
  56247. * @param url defines the url of the file to load
  56248. * @param extensions defines the extension to use to load the cube map (can be null)
  56249. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56250. * @param files defines the list of files to load (can be null)
  56251. * @returns a new CubeTextureAssetTask object
  56252. */
  56253. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56254. /**
  56255. *
  56256. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56257. * @param taskName defines the name of the new task
  56258. * @param url defines the url of the file to load
  56259. * @param size defines the size you want for the cubemap (can be null)
  56260. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56261. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56262. * @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)
  56263. * @param reserved Internal use only
  56264. * @returns a new HDRCubeTextureAssetTask object
  56265. */
  56266. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56267. /**
  56268. * Remove a task from the assets manager.
  56269. * @param task the task to remove
  56270. */
  56271. removeTask(task: AbstractAssetTask): void;
  56272. private _decreaseWaitingTasksCount;
  56273. private _runTask;
  56274. /**
  56275. * Reset the AssetsManager and remove all tasks
  56276. * @return the current instance of the AssetsManager
  56277. */
  56278. reset(): AssetsManager;
  56279. /**
  56280. * Start the loading process
  56281. * @return the current instance of the AssetsManager
  56282. */
  56283. load(): AssetsManager;
  56284. }
  56285. }
  56286. declare module "babylonjs/Misc/deferred" {
  56287. /**
  56288. * Wrapper class for promise with external resolve and reject.
  56289. */
  56290. export class Deferred<T> {
  56291. /**
  56292. * The promise associated with this deferred object.
  56293. */
  56294. readonly promise: Promise<T>;
  56295. private _resolve;
  56296. private _reject;
  56297. /**
  56298. * The resolve method of the promise associated with this deferred object.
  56299. */
  56300. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56301. /**
  56302. * The reject method of the promise associated with this deferred object.
  56303. */
  56304. readonly reject: (reason?: any) => void;
  56305. /**
  56306. * Constructor for this deferred object.
  56307. */
  56308. constructor();
  56309. }
  56310. }
  56311. declare module "babylonjs/Misc/filesInput" {
  56312. import { Engine } from "babylonjs/Engines/engine";
  56313. import { Scene } from "babylonjs/scene";
  56314. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56315. /**
  56316. * Class used to help managing file picking and drag'n'drop
  56317. */
  56318. export class FilesInput {
  56319. /**
  56320. * List of files ready to be loaded
  56321. */
  56322. static readonly FilesToLoad: {
  56323. [key: string]: File;
  56324. };
  56325. /**
  56326. * Callback called when a file is processed
  56327. */
  56328. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56329. private _engine;
  56330. private _currentScene;
  56331. private _sceneLoadedCallback;
  56332. private _progressCallback;
  56333. private _additionalRenderLoopLogicCallback;
  56334. private _textureLoadingCallback;
  56335. private _startingProcessingFilesCallback;
  56336. private _onReloadCallback;
  56337. private _errorCallback;
  56338. private _elementToMonitor;
  56339. private _sceneFileToLoad;
  56340. private _filesToLoad;
  56341. /**
  56342. * Creates a new FilesInput
  56343. * @param engine defines the rendering engine
  56344. * @param scene defines the hosting scene
  56345. * @param sceneLoadedCallback callback called when scene is loaded
  56346. * @param progressCallback callback called to track progress
  56347. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56348. * @param textureLoadingCallback callback called when a texture is loading
  56349. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56350. * @param onReloadCallback callback called when a reload is requested
  56351. * @param errorCallback callback call if an error occurs
  56352. */
  56353. 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);
  56354. private _dragEnterHandler;
  56355. private _dragOverHandler;
  56356. private _dropHandler;
  56357. /**
  56358. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56359. * @param elementToMonitor defines the DOM element to track
  56360. */
  56361. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56362. /**
  56363. * Release all associated resources
  56364. */
  56365. dispose(): void;
  56366. private renderFunction;
  56367. private drag;
  56368. private drop;
  56369. private _traverseFolder;
  56370. private _processFiles;
  56371. /**
  56372. * Load files from a drop event
  56373. * @param event defines the drop event to use as source
  56374. */
  56375. loadFiles(event: any): void;
  56376. private _processReload;
  56377. /**
  56378. * Reload the current scene from the loaded files
  56379. */
  56380. reload(): void;
  56381. }
  56382. }
  56383. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56384. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56385. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56386. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56387. }
  56388. declare module "babylonjs/Misc/sceneOptimizer" {
  56389. import { Scene, IDisposable } from "babylonjs/scene";
  56390. import { Observable } from "babylonjs/Misc/observable";
  56391. /**
  56392. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56394. */
  56395. export class SceneOptimization {
  56396. /**
  56397. * Defines the priority of this optimization (0 by default which means first in the list)
  56398. */
  56399. priority: number;
  56400. /**
  56401. * Gets a string describing the action executed by the current optimization
  56402. * @returns description string
  56403. */
  56404. getDescription(): string;
  56405. /**
  56406. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56407. * @param scene defines the current scene where to apply this optimization
  56408. * @param optimizer defines the current optimizer
  56409. * @returns true if everything that can be done was applied
  56410. */
  56411. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56412. /**
  56413. * Creates the SceneOptimization object
  56414. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56415. * @param desc defines the description associated with the optimization
  56416. */
  56417. constructor(
  56418. /**
  56419. * Defines the priority of this optimization (0 by default which means first in the list)
  56420. */
  56421. priority?: number);
  56422. }
  56423. /**
  56424. * Defines an optimization used to reduce the size of render target textures
  56425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56426. */
  56427. export class TextureOptimization extends SceneOptimization {
  56428. /**
  56429. * Defines the priority of this optimization (0 by default which means first in the list)
  56430. */
  56431. priority: number;
  56432. /**
  56433. * 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
  56434. */
  56435. maximumSize: number;
  56436. /**
  56437. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56438. */
  56439. step: number;
  56440. /**
  56441. * Gets a string describing the action executed by the current optimization
  56442. * @returns description string
  56443. */
  56444. getDescription(): string;
  56445. /**
  56446. * Creates the TextureOptimization object
  56447. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56448. * @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
  56449. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56450. */
  56451. constructor(
  56452. /**
  56453. * Defines the priority of this optimization (0 by default which means first in the list)
  56454. */
  56455. priority?: number,
  56456. /**
  56457. * 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
  56458. */
  56459. maximumSize?: number,
  56460. /**
  56461. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56462. */
  56463. step?: number);
  56464. /**
  56465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56466. * @param scene defines the current scene where to apply this optimization
  56467. * @param optimizer defines the current optimizer
  56468. * @returns true if everything that can be done was applied
  56469. */
  56470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56471. }
  56472. /**
  56473. * Defines an optimization used to increase or decrease the rendering resolution
  56474. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56475. */
  56476. export class HardwareScalingOptimization extends SceneOptimization {
  56477. /**
  56478. * Defines the priority of this optimization (0 by default which means first in the list)
  56479. */
  56480. priority: number;
  56481. /**
  56482. * Defines the maximum scale to use (2 by default)
  56483. */
  56484. maximumScale: number;
  56485. /**
  56486. * Defines the step to use between two passes (0.5 by default)
  56487. */
  56488. step: number;
  56489. private _currentScale;
  56490. private _directionOffset;
  56491. /**
  56492. * Gets a string describing the action executed by the current optimization
  56493. * @return description string
  56494. */
  56495. getDescription(): string;
  56496. /**
  56497. * Creates the HardwareScalingOptimization object
  56498. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56499. * @param maximumScale defines the maximum scale to use (2 by default)
  56500. * @param step defines the step to use between two passes (0.5 by default)
  56501. */
  56502. constructor(
  56503. /**
  56504. * Defines the priority of this optimization (0 by default which means first in the list)
  56505. */
  56506. priority?: number,
  56507. /**
  56508. * Defines the maximum scale to use (2 by default)
  56509. */
  56510. maximumScale?: number,
  56511. /**
  56512. * Defines the step to use between two passes (0.5 by default)
  56513. */
  56514. step?: number);
  56515. /**
  56516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56517. * @param scene defines the current scene where to apply this optimization
  56518. * @param optimizer defines the current optimizer
  56519. * @returns true if everything that can be done was applied
  56520. */
  56521. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56522. }
  56523. /**
  56524. * Defines an optimization used to remove shadows
  56525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56526. */
  56527. export class ShadowsOptimization extends SceneOptimization {
  56528. /**
  56529. * Gets a string describing the action executed by the current optimization
  56530. * @return description string
  56531. */
  56532. getDescription(): string;
  56533. /**
  56534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56535. * @param scene defines the current scene where to apply this optimization
  56536. * @param optimizer defines the current optimizer
  56537. * @returns true if everything that can be done was applied
  56538. */
  56539. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56540. }
  56541. /**
  56542. * Defines an optimization used to turn post-processes off
  56543. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56544. */
  56545. export class PostProcessesOptimization extends SceneOptimization {
  56546. /**
  56547. * Gets a string describing the action executed by the current optimization
  56548. * @return description string
  56549. */
  56550. getDescription(): string;
  56551. /**
  56552. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56553. * @param scene defines the current scene where to apply this optimization
  56554. * @param optimizer defines the current optimizer
  56555. * @returns true if everything that can be done was applied
  56556. */
  56557. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56558. }
  56559. /**
  56560. * Defines an optimization used to turn lens flares off
  56561. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56562. */
  56563. export class LensFlaresOptimization extends SceneOptimization {
  56564. /**
  56565. * Gets a string describing the action executed by the current optimization
  56566. * @return description string
  56567. */
  56568. getDescription(): string;
  56569. /**
  56570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56571. * @param scene defines the current scene where to apply this optimization
  56572. * @param optimizer defines the current optimizer
  56573. * @returns true if everything that can be done was applied
  56574. */
  56575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56576. }
  56577. /**
  56578. * Defines an optimization based on user defined callback.
  56579. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56580. */
  56581. export class CustomOptimization extends SceneOptimization {
  56582. /**
  56583. * Callback called to apply the custom optimization.
  56584. */
  56585. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56586. /**
  56587. * Callback called to get custom description
  56588. */
  56589. onGetDescription: () => string;
  56590. /**
  56591. * Gets a string describing the action executed by the current optimization
  56592. * @returns description string
  56593. */
  56594. getDescription(): string;
  56595. /**
  56596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56597. * @param scene defines the current scene where to apply this optimization
  56598. * @param optimizer defines the current optimizer
  56599. * @returns true if everything that can be done was applied
  56600. */
  56601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56602. }
  56603. /**
  56604. * Defines an optimization used to turn particles off
  56605. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56606. */
  56607. export class ParticlesOptimization extends SceneOptimization {
  56608. /**
  56609. * Gets a string describing the action executed by the current optimization
  56610. * @return description string
  56611. */
  56612. getDescription(): string;
  56613. /**
  56614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56615. * @param scene defines the current scene where to apply this optimization
  56616. * @param optimizer defines the current optimizer
  56617. * @returns true if everything that can be done was applied
  56618. */
  56619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56620. }
  56621. /**
  56622. * Defines an optimization used to turn render targets off
  56623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56624. */
  56625. export class RenderTargetsOptimization extends SceneOptimization {
  56626. /**
  56627. * Gets a string describing the action executed by the current optimization
  56628. * @return description string
  56629. */
  56630. getDescription(): string;
  56631. /**
  56632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56633. * @param scene defines the current scene where to apply this optimization
  56634. * @param optimizer defines the current optimizer
  56635. * @returns true if everything that can be done was applied
  56636. */
  56637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56638. }
  56639. /**
  56640. * Defines an optimization used to merge meshes with compatible materials
  56641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56642. */
  56643. export class MergeMeshesOptimization extends SceneOptimization {
  56644. private static _UpdateSelectionTree;
  56645. /**
  56646. * Gets or sets a boolean which defines if optimization octree has to be updated
  56647. */
  56648. /**
  56649. * Gets or sets a boolean which defines if optimization octree has to be updated
  56650. */
  56651. static UpdateSelectionTree: boolean;
  56652. /**
  56653. * Gets a string describing the action executed by the current optimization
  56654. * @return description string
  56655. */
  56656. getDescription(): string;
  56657. private _canBeMerged;
  56658. /**
  56659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56660. * @param scene defines the current scene where to apply this optimization
  56661. * @param optimizer defines the current optimizer
  56662. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56663. * @returns true if everything that can be done was applied
  56664. */
  56665. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56666. }
  56667. /**
  56668. * Defines a list of options used by SceneOptimizer
  56669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56670. */
  56671. export class SceneOptimizerOptions {
  56672. /**
  56673. * Defines the target frame rate to reach (60 by default)
  56674. */
  56675. targetFrameRate: number;
  56676. /**
  56677. * Defines the interval between two checkes (2000ms by default)
  56678. */
  56679. trackerDuration: number;
  56680. /**
  56681. * Gets the list of optimizations to apply
  56682. */
  56683. optimizations: SceneOptimization[];
  56684. /**
  56685. * Creates a new list of options used by SceneOptimizer
  56686. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56687. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56688. */
  56689. constructor(
  56690. /**
  56691. * Defines the target frame rate to reach (60 by default)
  56692. */
  56693. targetFrameRate?: number,
  56694. /**
  56695. * Defines the interval between two checkes (2000ms by default)
  56696. */
  56697. trackerDuration?: number);
  56698. /**
  56699. * Add a new optimization
  56700. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56701. * @returns the current SceneOptimizerOptions
  56702. */
  56703. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56704. /**
  56705. * Add a new custom optimization
  56706. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56707. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56709. * @returns the current SceneOptimizerOptions
  56710. */
  56711. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56712. /**
  56713. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56714. * @param targetFrameRate defines the target frame rate (60 by default)
  56715. * @returns a SceneOptimizerOptions object
  56716. */
  56717. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56718. /**
  56719. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56720. * @param targetFrameRate defines the target frame rate (60 by default)
  56721. * @returns a SceneOptimizerOptions object
  56722. */
  56723. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56724. /**
  56725. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56726. * @param targetFrameRate defines the target frame rate (60 by default)
  56727. * @returns a SceneOptimizerOptions object
  56728. */
  56729. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56730. }
  56731. /**
  56732. * Class used to run optimizations in order to reach a target frame rate
  56733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56734. */
  56735. export class SceneOptimizer implements IDisposable {
  56736. private _isRunning;
  56737. private _options;
  56738. private _scene;
  56739. private _currentPriorityLevel;
  56740. private _targetFrameRate;
  56741. private _trackerDuration;
  56742. private _currentFrameRate;
  56743. private _sceneDisposeObserver;
  56744. private _improvementMode;
  56745. /**
  56746. * Defines an observable called when the optimizer reaches the target frame rate
  56747. */
  56748. onSuccessObservable: Observable<SceneOptimizer>;
  56749. /**
  56750. * Defines an observable called when the optimizer enables an optimization
  56751. */
  56752. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56753. /**
  56754. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56755. */
  56756. onFailureObservable: Observable<SceneOptimizer>;
  56757. /**
  56758. * Gets a boolean indicating if the optimizer is in improvement mode
  56759. */
  56760. readonly isInImprovementMode: boolean;
  56761. /**
  56762. * Gets the current priority level (0 at start)
  56763. */
  56764. readonly currentPriorityLevel: number;
  56765. /**
  56766. * Gets the current frame rate checked by the SceneOptimizer
  56767. */
  56768. readonly currentFrameRate: number;
  56769. /**
  56770. * Gets or sets the current target frame rate (60 by default)
  56771. */
  56772. /**
  56773. * Gets or sets the current target frame rate (60 by default)
  56774. */
  56775. targetFrameRate: number;
  56776. /**
  56777. * Gets or sets the current interval between two checks (every 2000ms by default)
  56778. */
  56779. /**
  56780. * Gets or sets the current interval between two checks (every 2000ms by default)
  56781. */
  56782. trackerDuration: number;
  56783. /**
  56784. * Gets the list of active optimizations
  56785. */
  56786. readonly optimizations: SceneOptimization[];
  56787. /**
  56788. * Creates a new SceneOptimizer
  56789. * @param scene defines the scene to work on
  56790. * @param options defines the options to use with the SceneOptimizer
  56791. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56792. * @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)
  56793. */
  56794. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56795. /**
  56796. * Stops the current optimizer
  56797. */
  56798. stop(): void;
  56799. /**
  56800. * Reset the optimizer to initial step (current priority level = 0)
  56801. */
  56802. reset(): void;
  56803. /**
  56804. * Start the optimizer. By default it will try to reach a specific framerate
  56805. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56806. */
  56807. start(): void;
  56808. private _checkCurrentState;
  56809. /**
  56810. * Release all resources
  56811. */
  56812. dispose(): void;
  56813. /**
  56814. * Helper function to create a SceneOptimizer with one single line of code
  56815. * @param scene defines the scene to work on
  56816. * @param options defines the options to use with the SceneOptimizer
  56817. * @param onSuccess defines a callback to call on success
  56818. * @param onFailure defines a callback to call on failure
  56819. * @returns the new SceneOptimizer object
  56820. */
  56821. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56822. }
  56823. }
  56824. declare module "babylonjs/Misc/sceneSerializer" {
  56825. import { Scene } from "babylonjs/scene";
  56826. /**
  56827. * Class used to serialize a scene into a string
  56828. */
  56829. export class SceneSerializer {
  56830. /**
  56831. * Clear cache used by a previous serialization
  56832. */
  56833. static ClearCache(): void;
  56834. /**
  56835. * Serialize a scene into a JSON compatible object
  56836. * @param scene defines the scene to serialize
  56837. * @returns a JSON compatible object
  56838. */
  56839. static Serialize(scene: Scene): any;
  56840. /**
  56841. * Serialize a mesh into a JSON compatible object
  56842. * @param toSerialize defines the mesh to serialize
  56843. * @param withParents defines if parents must be serialized as well
  56844. * @param withChildren defines if children must be serialized as well
  56845. * @returns a JSON compatible object
  56846. */
  56847. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56848. }
  56849. }
  56850. declare module "babylonjs/Misc/videoRecorder" {
  56851. import { Nullable } from "babylonjs/types";
  56852. import { Engine } from "babylonjs/Engines/engine";
  56853. /**
  56854. * This represents the different options avilable for the video capture.
  56855. */
  56856. export interface VideoRecorderOptions {
  56857. /** Defines the mime type of the video */
  56858. mimeType: string;
  56859. /** Defines the video the video should be recorded at */
  56860. fps: number;
  56861. /** Defines the chunk size for the recording data */
  56862. recordChunckSize: number;
  56863. /** The audio tracks to attach to the record */
  56864. audioTracks?: MediaStreamTrack[];
  56865. }
  56866. /**
  56867. * This can helps recording videos from BabylonJS.
  56868. * This is based on the available WebRTC functionalities of the browser.
  56869. *
  56870. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56871. */
  56872. export class VideoRecorder {
  56873. private static readonly _defaultOptions;
  56874. /**
  56875. * Returns wehther or not the VideoRecorder is available in your browser.
  56876. * @param engine Defines the Babylon Engine to check the support for
  56877. * @returns true if supported otherwise false
  56878. */
  56879. static IsSupported(engine: Engine): boolean;
  56880. private readonly _options;
  56881. private _canvas;
  56882. private _mediaRecorder;
  56883. private _recordedChunks;
  56884. private _fileName;
  56885. private _resolve;
  56886. private _reject;
  56887. /**
  56888. * True wether a recording is already in progress.
  56889. */
  56890. readonly isRecording: boolean;
  56891. /**
  56892. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56893. * a video file.
  56894. * @param engine Defines the BabylonJS Engine you wish to record
  56895. * @param options Defines options that can be used to customized the capture
  56896. */
  56897. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56898. /**
  56899. * Stops the current recording before the default capture timeout passed in the startRecording
  56900. * functions.
  56901. */
  56902. stopRecording(): void;
  56903. /**
  56904. * Starts recording the canvas for a max duration specified in parameters.
  56905. * @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.
  56906. * @param maxDuration Defines the maximum recording time in seconds.
  56907. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56908. * @return a promise callback at the end of the recording with the video data in Blob.
  56909. */
  56910. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56911. /**
  56912. * Releases internal resources used during the recording.
  56913. */
  56914. dispose(): void;
  56915. private _handleDataAvailable;
  56916. private _handleError;
  56917. private _handleStop;
  56918. }
  56919. }
  56920. declare module "babylonjs/Misc/workerPool" {
  56921. import { IDisposable } from "babylonjs/scene";
  56922. /**
  56923. * Helper class to push actions to a pool of workers.
  56924. */
  56925. export class WorkerPool implements IDisposable {
  56926. private _workerInfos;
  56927. private _pendingActions;
  56928. /**
  56929. * Constructor
  56930. * @param workers Array of workers to use for actions
  56931. */
  56932. constructor(workers: Array<Worker>);
  56933. /**
  56934. * Terminates all workers and clears any pending actions.
  56935. */
  56936. dispose(): void;
  56937. /**
  56938. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56939. * pended until a worker has completed its action.
  56940. * @param action The action to perform. Call onComplete when the action is complete.
  56941. */
  56942. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56943. private _execute;
  56944. }
  56945. }
  56946. declare module "babylonjs/Misc/screenshotTools" {
  56947. import { Camera } from "babylonjs/Cameras/camera";
  56948. import { Engine } from "babylonjs/Engines/engine";
  56949. /**
  56950. * Class containing a set of static utilities functions for screenshots
  56951. */
  56952. export class ScreenshotTools {
  56953. /**
  56954. * Captures a screenshot of the current rendering
  56955. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56956. * @param engine defines the rendering engine
  56957. * @param camera defines the source camera
  56958. * @param size This parameter can be set to a single number or to an object with the
  56959. * following (optional) properties: precision, width, height. If a single number is passed,
  56960. * it will be used for both width and height. If an object is passed, the screenshot size
  56961. * will be derived from the parameters. The precision property is a multiplier allowing
  56962. * rendering at a higher or lower resolution
  56963. * @param successCallback defines the callback receives a single parameter which contains the
  56964. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56965. * src parameter of an <img> to display it
  56966. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56967. * Check your browser for supported MIME types
  56968. */
  56969. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56970. /**
  56971. * Generates an image screenshot from the specified camera.
  56972. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56973. * @param engine The engine to use for rendering
  56974. * @param camera The camera to use for rendering
  56975. * @param size This parameter can be set to a single number or to an object with the
  56976. * following (optional) properties: precision, width, height. If a single number is passed,
  56977. * it will be used for both width and height. If an object is passed, the screenshot size
  56978. * will be derived from the parameters. The precision property is a multiplier allowing
  56979. * rendering at a higher or lower resolution
  56980. * @param successCallback The callback receives a single parameter which contains the
  56981. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56982. * src parameter of an <img> to display it
  56983. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56984. * Check your browser for supported MIME types
  56985. * @param samples Texture samples (default: 1)
  56986. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56987. * @param fileName A name for for the downloaded file.
  56988. */
  56989. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56990. }
  56991. }
  56992. declare module "babylonjs/Misc/index" {
  56993. export * from "babylonjs/Misc/andOrNotEvaluator";
  56994. export * from "babylonjs/Misc/assetsManager";
  56995. export * from "babylonjs/Misc/dds";
  56996. export * from "babylonjs/Misc/decorators";
  56997. export * from "babylonjs/Misc/deferred";
  56998. export * from "babylonjs/Misc/environmentTextureTools";
  56999. export * from "babylonjs/Misc/filesInput";
  57000. export * from "babylonjs/Misc/HighDynamicRange/index";
  57001. export * from "babylonjs/Misc/khronosTextureContainer";
  57002. export * from "babylonjs/Misc/observable";
  57003. export * from "babylonjs/Misc/performanceMonitor";
  57004. export * from "babylonjs/Misc/promise";
  57005. export * from "babylonjs/Misc/sceneOptimizer";
  57006. export * from "babylonjs/Misc/sceneSerializer";
  57007. export * from "babylonjs/Misc/smartArray";
  57008. export * from "babylonjs/Misc/stringDictionary";
  57009. export * from "babylonjs/Misc/tags";
  57010. export * from "babylonjs/Misc/textureTools";
  57011. export * from "babylonjs/Misc/tga";
  57012. export * from "babylonjs/Misc/tools";
  57013. export * from "babylonjs/Misc/videoRecorder";
  57014. export * from "babylonjs/Misc/virtualJoystick";
  57015. export * from "babylonjs/Misc/workerPool";
  57016. export * from "babylonjs/Misc/logger";
  57017. export * from "babylonjs/Misc/typeStore";
  57018. export * from "babylonjs/Misc/filesInputStore";
  57019. export * from "babylonjs/Misc/deepCopier";
  57020. export * from "babylonjs/Misc/pivotTools";
  57021. export * from "babylonjs/Misc/precisionDate";
  57022. export * from "babylonjs/Misc/screenshotTools";
  57023. export * from "babylonjs/Misc/typeStore";
  57024. }
  57025. declare module "babylonjs/index" {
  57026. export * from "babylonjs/abstractScene";
  57027. export * from "babylonjs/Actions/index";
  57028. export * from "babylonjs/Animations/index";
  57029. export * from "babylonjs/assetContainer";
  57030. export * from "babylonjs/Audio/index";
  57031. export * from "babylonjs/Behaviors/index";
  57032. export * from "babylonjs/Bones/index";
  57033. export * from "babylonjs/Cameras/index";
  57034. export * from "babylonjs/Collisions/index";
  57035. export * from "babylonjs/Culling/index";
  57036. export * from "babylonjs/Debug/index";
  57037. export * from "babylonjs/Engines/index";
  57038. export * from "babylonjs/Events/index";
  57039. export * from "babylonjs/Gamepads/index";
  57040. export * from "babylonjs/Gizmos/index";
  57041. export * from "babylonjs/Helpers/index";
  57042. export * from "babylonjs/Instrumentation/index";
  57043. export * from "babylonjs/Layers/index";
  57044. export * from "babylonjs/LensFlares/index";
  57045. export * from "babylonjs/Lights/index";
  57046. export * from "babylonjs/Loading/index";
  57047. export * from "babylonjs/Materials/index";
  57048. export * from "babylonjs/Maths/index";
  57049. export * from "babylonjs/Meshes/index";
  57050. export * from "babylonjs/Morph/index";
  57051. export * from "babylonjs/node";
  57052. export * from "babylonjs/Offline/index";
  57053. export * from "babylonjs/Particles/index";
  57054. export * from "babylonjs/Physics/index";
  57055. export * from "babylonjs/PostProcesses/index";
  57056. export * from "babylonjs/Probes/index";
  57057. export * from "babylonjs/Rendering/index";
  57058. export * from "babylonjs/scene";
  57059. export * from "babylonjs/sceneComponent";
  57060. export * from "babylonjs/Sprites/index";
  57061. export * from "babylonjs/States/index";
  57062. export * from "babylonjs/Misc/index";
  57063. export * from "babylonjs/types";
  57064. }
  57065. declare module "babylonjs/Animations/pathCursor" {
  57066. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57067. /**
  57068. * A cursor which tracks a point on a path
  57069. */
  57070. export class PathCursor {
  57071. private path;
  57072. /**
  57073. * Stores path cursor callbacks for when an onchange event is triggered
  57074. */
  57075. private _onchange;
  57076. /**
  57077. * The value of the path cursor
  57078. */
  57079. value: number;
  57080. /**
  57081. * The animation array of the path cursor
  57082. */
  57083. animations: Animation[];
  57084. /**
  57085. * Initializes the path cursor
  57086. * @param path The path to track
  57087. */
  57088. constructor(path: Path2);
  57089. /**
  57090. * Gets the cursor point on the path
  57091. * @returns A point on the path cursor at the cursor location
  57092. */
  57093. getPoint(): Vector3;
  57094. /**
  57095. * Moves the cursor ahead by the step amount
  57096. * @param step The amount to move the cursor forward
  57097. * @returns This path cursor
  57098. */
  57099. moveAhead(step?: number): PathCursor;
  57100. /**
  57101. * Moves the cursor behind by the step amount
  57102. * @param step The amount to move the cursor back
  57103. * @returns This path cursor
  57104. */
  57105. moveBack(step?: number): PathCursor;
  57106. /**
  57107. * Moves the cursor by the step amount
  57108. * If the step amount is greater than one, an exception is thrown
  57109. * @param step The amount to move the cursor
  57110. * @returns This path cursor
  57111. */
  57112. move(step: number): PathCursor;
  57113. /**
  57114. * Ensures that the value is limited between zero and one
  57115. * @returns This path cursor
  57116. */
  57117. private ensureLimits;
  57118. /**
  57119. * Runs onchange callbacks on change (used by the animation engine)
  57120. * @returns This path cursor
  57121. */
  57122. private raiseOnChange;
  57123. /**
  57124. * Executes a function on change
  57125. * @param f A path cursor onchange callback
  57126. * @returns This path cursor
  57127. */
  57128. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57129. }
  57130. }
  57131. declare module "babylonjs/Legacy/legacy" {
  57132. import * as Babylon from "babylonjs/index";
  57133. export * from "babylonjs/index";
  57134. }
  57135. declare module "babylonjs/Shaders/blur.fragment" {
  57136. /** @hidden */
  57137. export var blurPixelShader: {
  57138. name: string;
  57139. shader: string;
  57140. };
  57141. }
  57142. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57143. /** @hidden */
  57144. export var bones300Declaration: {
  57145. name: string;
  57146. shader: string;
  57147. };
  57148. }
  57149. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57150. /** @hidden */
  57151. export var instances300Declaration: {
  57152. name: string;
  57153. shader: string;
  57154. };
  57155. }
  57156. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57157. /** @hidden */
  57158. export var pointCloudVertexDeclaration: {
  57159. name: string;
  57160. shader: string;
  57161. };
  57162. }
  57163. // Mixins
  57164. interface Window {
  57165. mozIndexedDB: IDBFactory;
  57166. webkitIndexedDB: IDBFactory;
  57167. msIndexedDB: IDBFactory;
  57168. webkitURL: typeof URL;
  57169. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57170. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57171. WebGLRenderingContext: WebGLRenderingContext;
  57172. MSGesture: MSGesture;
  57173. CANNON: any;
  57174. AudioContext: AudioContext;
  57175. webkitAudioContext: AudioContext;
  57176. PointerEvent: any;
  57177. Math: Math;
  57178. Uint8Array: Uint8ArrayConstructor;
  57179. Float32Array: Float32ArrayConstructor;
  57180. mozURL: typeof URL;
  57181. msURL: typeof URL;
  57182. VRFrameData: any; // WebVR, from specs 1.1
  57183. DracoDecoderModule: any;
  57184. setImmediate(handler: (...args: any[]) => void): number;
  57185. }
  57186. interface HTMLCanvasElement {
  57187. requestPointerLock(): void;
  57188. msRequestPointerLock?(): void;
  57189. mozRequestPointerLock?(): void;
  57190. webkitRequestPointerLock?(): void;
  57191. /** Track wether a record is in progress */
  57192. isRecording: boolean;
  57193. /** Capture Stream method defined by some browsers */
  57194. captureStream(fps?: number): MediaStream;
  57195. }
  57196. interface CanvasRenderingContext2D {
  57197. msImageSmoothingEnabled: boolean;
  57198. }
  57199. interface MouseEvent {
  57200. mozMovementX: number;
  57201. mozMovementY: number;
  57202. webkitMovementX: number;
  57203. webkitMovementY: number;
  57204. msMovementX: number;
  57205. msMovementY: number;
  57206. }
  57207. interface Navigator {
  57208. mozGetVRDevices: (any: any) => any;
  57209. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57210. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57211. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57212. webkitGetGamepads(): Gamepad[];
  57213. msGetGamepads(): Gamepad[];
  57214. webkitGamepads(): Gamepad[];
  57215. }
  57216. interface HTMLVideoElement {
  57217. mozSrcObject: any;
  57218. }
  57219. interface Math {
  57220. fround(x: number): number;
  57221. imul(a: number, b: number): number;
  57222. }
  57223. interface WebGLProgram {
  57224. context?: WebGLRenderingContext;
  57225. vertexShader?: WebGLShader;
  57226. fragmentShader?: WebGLShader;
  57227. isParallelCompiled: boolean;
  57228. onCompiled?: () => void;
  57229. }
  57230. interface WebGLRenderingContext {
  57231. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57232. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57233. vertexAttribDivisor(index: number, divisor: number): void;
  57234. createVertexArray(): any;
  57235. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57236. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57237. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57238. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57239. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57240. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57241. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57242. // Queries
  57243. createQuery(): WebGLQuery;
  57244. deleteQuery(query: WebGLQuery): void;
  57245. beginQuery(target: number, query: WebGLQuery): void;
  57246. endQuery(target: number): void;
  57247. getQueryParameter(query: WebGLQuery, pname: number): any;
  57248. getQuery(target: number, pname: number): any;
  57249. MAX_SAMPLES: number;
  57250. RGBA8: number;
  57251. READ_FRAMEBUFFER: number;
  57252. DRAW_FRAMEBUFFER: number;
  57253. UNIFORM_BUFFER: number;
  57254. HALF_FLOAT_OES: number;
  57255. RGBA16F: number;
  57256. RGBA32F: number;
  57257. R32F: number;
  57258. RG32F: number;
  57259. RGB32F: number;
  57260. R16F: number;
  57261. RG16F: number;
  57262. RGB16F: number;
  57263. RED: number;
  57264. RG: number;
  57265. R8: number;
  57266. RG8: number;
  57267. UNSIGNED_INT_24_8: number;
  57268. DEPTH24_STENCIL8: number;
  57269. /* Multiple Render Targets */
  57270. drawBuffers(buffers: number[]): void;
  57271. readBuffer(src: number): void;
  57272. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57273. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57274. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57275. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57276. // Occlusion Query
  57277. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57278. ANY_SAMPLES_PASSED: number;
  57279. QUERY_RESULT_AVAILABLE: number;
  57280. QUERY_RESULT: number;
  57281. }
  57282. interface WebGLBuffer {
  57283. references: number;
  57284. capacity: number;
  57285. is32Bits: boolean;
  57286. }
  57287. interface WebGLProgram {
  57288. transformFeedback?: WebGLTransformFeedback | null;
  57289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57290. }
  57291. interface EXT_disjoint_timer_query {
  57292. QUERY_COUNTER_BITS_EXT: number;
  57293. TIME_ELAPSED_EXT: number;
  57294. TIMESTAMP_EXT: number;
  57295. GPU_DISJOINT_EXT: number;
  57296. QUERY_RESULT_EXT: number;
  57297. QUERY_RESULT_AVAILABLE_EXT: number;
  57298. queryCounterEXT(query: WebGLQuery, target: number): void;
  57299. createQueryEXT(): WebGLQuery;
  57300. beginQueryEXT(target: number, query: WebGLQuery): void;
  57301. endQueryEXT(target: number): void;
  57302. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57303. deleteQueryEXT(query: WebGLQuery): void;
  57304. }
  57305. interface WebGLUniformLocation {
  57306. _currentState: any;
  57307. }
  57308. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57309. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57310. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57311. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57312. interface WebGLRenderingContext {
  57313. readonly RASTERIZER_DISCARD: number;
  57314. readonly DEPTH_COMPONENT24: number;
  57315. readonly TEXTURE_3D: number;
  57316. readonly TEXTURE_2D_ARRAY: number;
  57317. readonly TEXTURE_COMPARE_FUNC: number;
  57318. readonly TEXTURE_COMPARE_MODE: number;
  57319. readonly COMPARE_REF_TO_TEXTURE: number;
  57320. readonly TEXTURE_WRAP_R: number;
  57321. readonly HALF_FLOAT: number;
  57322. readonly RGB8: number;
  57323. readonly RED_INTEGER: number;
  57324. readonly RG_INTEGER: number;
  57325. readonly RGB_INTEGER: number;
  57326. readonly RGBA_INTEGER: number;
  57327. readonly R8_SNORM: number;
  57328. readonly RG8_SNORM: number;
  57329. readonly RGB8_SNORM: number;
  57330. readonly RGBA8_SNORM: number;
  57331. readonly R8I: number;
  57332. readonly RG8I: number;
  57333. readonly RGB8I: number;
  57334. readonly RGBA8I: number;
  57335. readonly R8UI: number;
  57336. readonly RG8UI: number;
  57337. readonly RGB8UI: number;
  57338. readonly RGBA8UI: number;
  57339. readonly R16I: number;
  57340. readonly RG16I: number;
  57341. readonly RGB16I: number;
  57342. readonly RGBA16I: number;
  57343. readonly R16UI: number;
  57344. readonly RG16UI: number;
  57345. readonly RGB16UI: number;
  57346. readonly RGBA16UI: number;
  57347. readonly R32I: number;
  57348. readonly RG32I: number;
  57349. readonly RGB32I: number;
  57350. readonly RGBA32I: number;
  57351. readonly R32UI: number;
  57352. readonly RG32UI: number;
  57353. readonly RGB32UI: number;
  57354. readonly RGBA32UI: number;
  57355. readonly RGB10_A2UI: number;
  57356. readonly R11F_G11F_B10F: number;
  57357. readonly RGB9_E5: number;
  57358. readonly RGB10_A2: number;
  57359. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57360. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57361. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57362. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57363. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57364. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57365. 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;
  57366. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57367. readonly TRANSFORM_FEEDBACK: number;
  57368. readonly INTERLEAVED_ATTRIBS: number;
  57369. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57370. createTransformFeedback(): WebGLTransformFeedback;
  57371. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57372. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57373. beginTransformFeedback(primitiveMode: number): void;
  57374. endTransformFeedback(): void;
  57375. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57376. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57377. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57378. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57379. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57380. }
  57381. interface ImageBitmap {
  57382. readonly width: number;
  57383. readonly height: number;
  57384. close(): void;
  57385. }
  57386. interface WebGLQuery extends WebGLObject {
  57387. }
  57388. declare var WebGLQuery: {
  57389. prototype: WebGLQuery;
  57390. new(): WebGLQuery;
  57391. };
  57392. interface WebGLSampler extends WebGLObject {
  57393. }
  57394. declare var WebGLSampler: {
  57395. prototype: WebGLSampler;
  57396. new(): WebGLSampler;
  57397. };
  57398. interface WebGLSync extends WebGLObject {
  57399. }
  57400. declare var WebGLSync: {
  57401. prototype: WebGLSync;
  57402. new(): WebGLSync;
  57403. };
  57404. interface WebGLTransformFeedback extends WebGLObject {
  57405. }
  57406. declare var WebGLTransformFeedback: {
  57407. prototype: WebGLTransformFeedback;
  57408. new(): WebGLTransformFeedback;
  57409. };
  57410. interface WebGLVertexArrayObject extends WebGLObject {
  57411. }
  57412. declare var WebGLVertexArrayObject: {
  57413. prototype: WebGLVertexArrayObject;
  57414. new(): WebGLVertexArrayObject;
  57415. };
  57416. // Type definitions for WebVR API
  57417. // Project: https://w3c.github.io/webvr/
  57418. // Definitions by: six a <https://github.com/lostfictions>
  57419. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57420. interface VRDisplay extends EventTarget {
  57421. /**
  57422. * Dictionary of capabilities describing the VRDisplay.
  57423. */
  57424. readonly capabilities: VRDisplayCapabilities;
  57425. /**
  57426. * z-depth defining the far plane of the eye view frustum
  57427. * enables mapping of values in the render target depth
  57428. * attachment to scene coordinates. Initially set to 10000.0.
  57429. */
  57430. depthFar: number;
  57431. /**
  57432. * z-depth defining the near plane of the eye view frustum
  57433. * enables mapping of values in the render target depth
  57434. * attachment to scene coordinates. Initially set to 0.01.
  57435. */
  57436. depthNear: number;
  57437. /**
  57438. * An identifier for this distinct VRDisplay. Used as an
  57439. * association point in the Gamepad API.
  57440. */
  57441. readonly displayId: number;
  57442. /**
  57443. * A display name, a user-readable name identifying it.
  57444. */
  57445. readonly displayName: string;
  57446. readonly isConnected: boolean;
  57447. readonly isPresenting: boolean;
  57448. /**
  57449. * If this VRDisplay supports room-scale experiences, the optional
  57450. * stage attribute contains details on the room-scale parameters.
  57451. */
  57452. readonly stageParameters: VRStageParameters | null;
  57453. /**
  57454. * Passing the value returned by `requestAnimationFrame` to
  57455. * `cancelAnimationFrame` will unregister the callback.
  57456. * @param handle Define the hanle of the request to cancel
  57457. */
  57458. cancelAnimationFrame(handle: number): void;
  57459. /**
  57460. * Stops presenting to the VRDisplay.
  57461. * @returns a promise to know when it stopped
  57462. */
  57463. exitPresent(): Promise<void>;
  57464. /**
  57465. * Return the current VREyeParameters for the given eye.
  57466. * @param whichEye Define the eye we want the parameter for
  57467. * @returns the eye parameters
  57468. */
  57469. getEyeParameters(whichEye: string): VREyeParameters;
  57470. /**
  57471. * Populates the passed VRFrameData with the information required to render
  57472. * the current frame.
  57473. * @param frameData Define the data structure to populate
  57474. * @returns true if ok otherwise false
  57475. */
  57476. getFrameData(frameData: VRFrameData): boolean;
  57477. /**
  57478. * Get the layers currently being presented.
  57479. * @returns the list of VR layers
  57480. */
  57481. getLayers(): VRLayer[];
  57482. /**
  57483. * Return a VRPose containing the future predicted pose of the VRDisplay
  57484. * when the current frame will be presented. The value returned will not
  57485. * change until JavaScript has returned control to the browser.
  57486. *
  57487. * The VRPose will contain the position, orientation, velocity,
  57488. * and acceleration of each of these properties.
  57489. * @returns the pose object
  57490. */
  57491. getPose(): VRPose;
  57492. /**
  57493. * Return the current instantaneous pose of the VRDisplay, with no
  57494. * prediction applied.
  57495. * @returns the current instantaneous pose
  57496. */
  57497. getImmediatePose(): VRPose;
  57498. /**
  57499. * The callback passed to `requestAnimationFrame` will be called
  57500. * any time a new frame should be rendered. When the VRDisplay is
  57501. * presenting the callback will be called at the native refresh
  57502. * rate of the HMD. When not presenting this function acts
  57503. * identically to how window.requestAnimationFrame acts. Content should
  57504. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57505. * asynchronously from other displays and at differing refresh rates.
  57506. * @param callback Define the eaction to run next frame
  57507. * @returns the request handle it
  57508. */
  57509. requestAnimationFrame(callback: FrameRequestCallback): number;
  57510. /**
  57511. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57512. * Repeat calls while already presenting will update the VRLayers being displayed.
  57513. * @param layers Define the list of layer to present
  57514. * @returns a promise to know when the request has been fulfilled
  57515. */
  57516. requestPresent(layers: VRLayer[]): Promise<void>;
  57517. /**
  57518. * Reset the pose for this display, treating its current position and
  57519. * orientation as the "origin/zero" values. VRPose.position,
  57520. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57521. * updated when calling resetPose(). This should be called in only
  57522. * sitting-space experiences.
  57523. */
  57524. resetPose(): void;
  57525. /**
  57526. * The VRLayer provided to the VRDisplay will be captured and presented
  57527. * in the HMD. Calling this function has the same effect on the source
  57528. * canvas as any other operation that uses its source image, and canvases
  57529. * created without preserveDrawingBuffer set to true will be cleared.
  57530. * @param pose Define the pose to submit
  57531. */
  57532. submitFrame(pose?: VRPose): void;
  57533. }
  57534. declare var VRDisplay: {
  57535. prototype: VRDisplay;
  57536. new(): VRDisplay;
  57537. };
  57538. interface VRLayer {
  57539. leftBounds?: number[] | Float32Array | null;
  57540. rightBounds?: number[] | Float32Array | null;
  57541. source?: HTMLCanvasElement | null;
  57542. }
  57543. interface VRDisplayCapabilities {
  57544. readonly canPresent: boolean;
  57545. readonly hasExternalDisplay: boolean;
  57546. readonly hasOrientation: boolean;
  57547. readonly hasPosition: boolean;
  57548. readonly maxLayers: number;
  57549. }
  57550. interface VREyeParameters {
  57551. /** @deprecated */
  57552. readonly fieldOfView: VRFieldOfView;
  57553. readonly offset: Float32Array;
  57554. readonly renderHeight: number;
  57555. readonly renderWidth: number;
  57556. }
  57557. interface VRFieldOfView {
  57558. readonly downDegrees: number;
  57559. readonly leftDegrees: number;
  57560. readonly rightDegrees: number;
  57561. readonly upDegrees: number;
  57562. }
  57563. interface VRFrameData {
  57564. readonly leftProjectionMatrix: Float32Array;
  57565. readonly leftViewMatrix: Float32Array;
  57566. readonly pose: VRPose;
  57567. readonly rightProjectionMatrix: Float32Array;
  57568. readonly rightViewMatrix: Float32Array;
  57569. readonly timestamp: number;
  57570. }
  57571. interface VRPose {
  57572. readonly angularAcceleration: Float32Array | null;
  57573. readonly angularVelocity: Float32Array | null;
  57574. readonly linearAcceleration: Float32Array | null;
  57575. readonly linearVelocity: Float32Array | null;
  57576. readonly orientation: Float32Array | null;
  57577. readonly position: Float32Array | null;
  57578. readonly timestamp: number;
  57579. }
  57580. interface VRStageParameters {
  57581. sittingToStandingTransform?: Float32Array;
  57582. sizeX?: number;
  57583. sizeY?: number;
  57584. }
  57585. interface Navigator {
  57586. getVRDisplays(): Promise<VRDisplay[]>;
  57587. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57588. }
  57589. interface Window {
  57590. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57591. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57592. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57593. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57594. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57595. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57596. }
  57597. interface Gamepad {
  57598. readonly displayId: number;
  57599. }
  57600. interface XRDevice {
  57601. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57602. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57603. }
  57604. interface XRSession {
  57605. getInputSources(): Array<any>;
  57606. baseLayer: XRWebGLLayer;
  57607. requestFrameOfReference(type: string): Promise<void>;
  57608. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57609. end(): Promise<void>;
  57610. requestAnimationFrame: Function;
  57611. addEventListener: Function;
  57612. }
  57613. interface XRSessionCreationOptions {
  57614. outputContext?: WebGLRenderingContext | null;
  57615. immersive?: boolean;
  57616. environmentIntegration?: boolean;
  57617. }
  57618. interface XRLayer {
  57619. getViewport: Function;
  57620. framebufferWidth: number;
  57621. framebufferHeight: number;
  57622. }
  57623. interface XRView {
  57624. projectionMatrix: Float32Array;
  57625. }
  57626. interface XRFrame {
  57627. getDevicePose: Function;
  57628. getInputPose: Function;
  57629. views: Array<XRView>;
  57630. baseLayer: XRLayer;
  57631. }
  57632. interface XRFrameOfReference {
  57633. }
  57634. interface XRWebGLLayer extends XRLayer {
  57635. framebuffer: WebGLFramebuffer;
  57636. }
  57637. declare var XRWebGLLayer: {
  57638. prototype: XRWebGLLayer;
  57639. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57640. };
  57641. declare module "babylonjs" {
  57642. export * from "babylonjs/Legacy/legacy";
  57643. }
  57644. declare module BABYLON {
  57645. /** Alias type for value that can be null */
  57646. export type Nullable<T> = T | null;
  57647. /**
  57648. * Alias type for number that are floats
  57649. * @ignorenaming
  57650. */
  57651. export type float = number;
  57652. /**
  57653. * Alias type for number that are doubles.
  57654. * @ignorenaming
  57655. */
  57656. export type double = number;
  57657. /**
  57658. * Alias type for number that are integer
  57659. * @ignorenaming
  57660. */
  57661. export type int = number;
  57662. /** Alias type for number array or Float32Array */
  57663. export type FloatArray = number[] | Float32Array;
  57664. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57665. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57666. /**
  57667. * Alias for types that can be used by a Buffer or VertexBuffer.
  57668. */
  57669. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57670. /**
  57671. * Alias type for primitive types
  57672. * @ignorenaming
  57673. */
  57674. type Primitive = undefined | null | boolean | string | number | Function;
  57675. /**
  57676. * Type modifier to make all the properties of an object Readonly
  57677. */
  57678. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57679. /**
  57680. * Type modifier to make all the properties of an object Readonly recursively
  57681. */
  57682. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57683. /** @hidden */
  57684. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57685. }
  57686. /** @hidden */
  57687. /** @hidden */
  57688. type DeepImmutableObject<T> = {
  57689. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57690. };
  57691. }
  57692. declare module BABYLON {
  57693. /**
  57694. * Class containing a set of static utilities functions for arrays.
  57695. */
  57696. export class ArrayTools {
  57697. /**
  57698. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57699. * @param size the number of element to construct and put in the array
  57700. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57701. * @returns a new array filled with new objects
  57702. */
  57703. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * Scalar computation library
  57709. */
  57710. export class Scalar {
  57711. /**
  57712. * Two pi constants convenient for computation.
  57713. */
  57714. static TwoPi: number;
  57715. /**
  57716. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57717. * @param a number
  57718. * @param b number
  57719. * @param epsilon (default = 1.401298E-45)
  57720. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57721. */
  57722. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57723. /**
  57724. * Returns a string : the upper case translation of the number i to hexadecimal.
  57725. * @param i number
  57726. * @returns the upper case translation of the number i to hexadecimal.
  57727. */
  57728. static ToHex(i: number): string;
  57729. /**
  57730. * Returns -1 if value is negative and +1 is value is positive.
  57731. * @param value the value
  57732. * @returns the value itself if it's equal to zero.
  57733. */
  57734. static Sign(value: number): number;
  57735. /**
  57736. * Returns the value itself if it's between min and max.
  57737. * Returns min if the value is lower than min.
  57738. * Returns max if the value is greater than max.
  57739. * @param value the value to clmap
  57740. * @param min the min value to clamp to (default: 0)
  57741. * @param max the max value to clamp to (default: 1)
  57742. * @returns the clamped value
  57743. */
  57744. static Clamp(value: number, min?: number, max?: number): number;
  57745. /**
  57746. * the log2 of value.
  57747. * @param value the value to compute log2 of
  57748. * @returns the log2 of value.
  57749. */
  57750. static Log2(value: number): number;
  57751. /**
  57752. * Loops the value, so that it is never larger than length and never smaller than 0.
  57753. *
  57754. * This is similar to the modulo operator but it works with floating point numbers.
  57755. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57756. * With t = 5 and length = 2.5, the result would be 0.0.
  57757. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57758. * @param value the value
  57759. * @param length the length
  57760. * @returns the looped value
  57761. */
  57762. static Repeat(value: number, length: number): number;
  57763. /**
  57764. * Normalize the value between 0.0 and 1.0 using min and max values
  57765. * @param value value to normalize
  57766. * @param min max to normalize between
  57767. * @param max min to normalize between
  57768. * @returns the normalized value
  57769. */
  57770. static Normalize(value: number, min: number, max: number): number;
  57771. /**
  57772. * Denormalize the value from 0.0 and 1.0 using min and max values
  57773. * @param normalized value to denormalize
  57774. * @param min max to denormalize between
  57775. * @param max min to denormalize between
  57776. * @returns the denormalized value
  57777. */
  57778. static Denormalize(normalized: number, min: number, max: number): number;
  57779. /**
  57780. * Calculates the shortest difference between two given angles given in degrees.
  57781. * @param current current angle in degrees
  57782. * @param target target angle in degrees
  57783. * @returns the delta
  57784. */
  57785. static DeltaAngle(current: number, target: number): number;
  57786. /**
  57787. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57788. * @param tx value
  57789. * @param length length
  57790. * @returns The returned value will move back and forth between 0 and length
  57791. */
  57792. static PingPong(tx: number, length: number): number;
  57793. /**
  57794. * Interpolates between min and max with smoothing at the limits.
  57795. *
  57796. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57797. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57798. * @param from from
  57799. * @param to to
  57800. * @param tx value
  57801. * @returns the smooth stepped value
  57802. */
  57803. static SmoothStep(from: number, to: number, tx: number): number;
  57804. /**
  57805. * Moves a value current towards target.
  57806. *
  57807. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57808. * Negative values of maxDelta pushes the value away from target.
  57809. * @param current current value
  57810. * @param target target value
  57811. * @param maxDelta max distance to move
  57812. * @returns resulting value
  57813. */
  57814. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57815. /**
  57816. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57817. *
  57818. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57819. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57820. * @param current current value
  57821. * @param target target value
  57822. * @param maxDelta max distance to move
  57823. * @returns resulting angle
  57824. */
  57825. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57826. /**
  57827. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57828. * @param start start value
  57829. * @param end target value
  57830. * @param amount amount to lerp between
  57831. * @returns the lerped value
  57832. */
  57833. static Lerp(start: number, end: number, amount: number): number;
  57834. /**
  57835. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57836. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57837. * @param start start value
  57838. * @param end target value
  57839. * @param amount amount to lerp between
  57840. * @returns the lerped value
  57841. */
  57842. static LerpAngle(start: number, end: number, amount: number): number;
  57843. /**
  57844. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57845. * @param a start value
  57846. * @param b target value
  57847. * @param value value between a and b
  57848. * @returns the inverseLerp value
  57849. */
  57850. static InverseLerp(a: number, b: number, value: number): number;
  57851. /**
  57852. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57853. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57854. * @param value1 spline value
  57855. * @param tangent1 spline value
  57856. * @param value2 spline value
  57857. * @param tangent2 spline value
  57858. * @param amount input value
  57859. * @returns hermite result
  57860. */
  57861. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57862. /**
  57863. * Returns a random float number between and min and max values
  57864. * @param min min value of random
  57865. * @param max max value of random
  57866. * @returns random value
  57867. */
  57868. static RandomRange(min: number, max: number): number;
  57869. /**
  57870. * This function returns percentage of a number in a given range.
  57871. *
  57872. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57873. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57874. * @param number to convert to percentage
  57875. * @param min min range
  57876. * @param max max range
  57877. * @returns the percentage
  57878. */
  57879. static RangeToPercent(number: number, min: number, max: number): number;
  57880. /**
  57881. * This function returns number that corresponds to the percentage in a given range.
  57882. *
  57883. * PercentToRange(0.34,0,100) will return 34.
  57884. * @param percent to convert to number
  57885. * @param min min range
  57886. * @param max max range
  57887. * @returns the number
  57888. */
  57889. static PercentToRange(percent: number, min: number, max: number): number;
  57890. /**
  57891. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57892. * @param angle The angle to normalize in radian.
  57893. * @return The converted angle.
  57894. */
  57895. static NormalizeRadians(angle: number): number;
  57896. }
  57897. }
  57898. declare module BABYLON {
  57899. /**
  57900. * Constant used to convert a value to gamma space
  57901. * @ignorenaming
  57902. */
  57903. export const ToGammaSpace: number;
  57904. /**
  57905. * Constant used to convert a value to linear space
  57906. * @ignorenaming
  57907. */
  57908. export const ToLinearSpace = 2.2;
  57909. /**
  57910. * Constant used to define the minimal number value in Babylon.js
  57911. * @ignorenaming
  57912. */
  57913. export const Epsilon = 0.001;
  57914. /**
  57915. * Class used to hold a RBG color
  57916. */
  57917. export class Color3 {
  57918. /**
  57919. * Defines the red component (between 0 and 1, default is 0)
  57920. */
  57921. r: number;
  57922. /**
  57923. * Defines the green component (between 0 and 1, default is 0)
  57924. */
  57925. g: number;
  57926. /**
  57927. * Defines the blue component (between 0 and 1, default is 0)
  57928. */
  57929. b: number;
  57930. /**
  57931. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57932. * @param r defines the red component (between 0 and 1, default is 0)
  57933. * @param g defines the green component (between 0 and 1, default is 0)
  57934. * @param b defines the blue component (between 0 and 1, default is 0)
  57935. */
  57936. constructor(
  57937. /**
  57938. * Defines the red component (between 0 and 1, default is 0)
  57939. */
  57940. r?: number,
  57941. /**
  57942. * Defines the green component (between 0 and 1, default is 0)
  57943. */
  57944. g?: number,
  57945. /**
  57946. * Defines the blue component (between 0 and 1, default is 0)
  57947. */
  57948. b?: number);
  57949. /**
  57950. * Creates a string with the Color3 current values
  57951. * @returns the string representation of the Color3 object
  57952. */
  57953. toString(): string;
  57954. /**
  57955. * Returns the string "Color3"
  57956. * @returns "Color3"
  57957. */
  57958. getClassName(): string;
  57959. /**
  57960. * Compute the Color3 hash code
  57961. * @returns an unique number that can be used to hash Color3 objects
  57962. */
  57963. getHashCode(): number;
  57964. /**
  57965. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57966. * @param array defines the array where to store the r,g,b components
  57967. * @param index defines an optional index in the target array to define where to start storing values
  57968. * @returns the current Color3 object
  57969. */
  57970. toArray(array: FloatArray, index?: number): Color3;
  57971. /**
  57972. * Returns a new Color4 object from the current Color3 and the given alpha
  57973. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57974. * @returns a new Color4 object
  57975. */
  57976. toColor4(alpha?: number): Color4;
  57977. /**
  57978. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57979. * @returns the new array
  57980. */
  57981. asArray(): number[];
  57982. /**
  57983. * Returns the luminance value
  57984. * @returns a float value
  57985. */
  57986. toLuminance(): number;
  57987. /**
  57988. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57989. * @param otherColor defines the second operand
  57990. * @returns the new Color3 object
  57991. */
  57992. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57993. /**
  57994. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57995. * @param otherColor defines the second operand
  57996. * @param result defines the Color3 object where to store the result
  57997. * @returns the current Color3
  57998. */
  57999. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58000. /**
  58001. * Determines equality between Color3 objects
  58002. * @param otherColor defines the second operand
  58003. * @returns true if the rgb values are equal to the given ones
  58004. */
  58005. equals(otherColor: DeepImmutable<Color3>): boolean;
  58006. /**
  58007. * Determines equality between the current Color3 object and a set of r,b,g values
  58008. * @param r defines the red component to check
  58009. * @param g defines the green component to check
  58010. * @param b defines the blue component to check
  58011. * @returns true if the rgb values are equal to the given ones
  58012. */
  58013. equalsFloats(r: number, g: number, b: number): boolean;
  58014. /**
  58015. * Multiplies in place each rgb value by scale
  58016. * @param scale defines the scaling factor
  58017. * @returns the updated Color3
  58018. */
  58019. scale(scale: number): Color3;
  58020. /**
  58021. * Multiplies the rgb values by scale and stores the result into "result"
  58022. * @param scale defines the scaling factor
  58023. * @param result defines the Color3 object where to store the result
  58024. * @returns the unmodified current Color3
  58025. */
  58026. scaleToRef(scale: number, result: Color3): Color3;
  58027. /**
  58028. * Scale the current Color3 values by a factor and add the result to a given Color3
  58029. * @param scale defines the scale factor
  58030. * @param result defines color to store the result into
  58031. * @returns the unmodified current Color3
  58032. */
  58033. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58034. /**
  58035. * Clamps the rgb values by the min and max values and stores the result into "result"
  58036. * @param min defines minimum clamping value (default is 0)
  58037. * @param max defines maximum clamping value (default is 1)
  58038. * @param result defines color to store the result into
  58039. * @returns the original Color3
  58040. */
  58041. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58042. /**
  58043. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58044. * @param otherColor defines the second operand
  58045. * @returns the new Color3
  58046. */
  58047. add(otherColor: DeepImmutable<Color3>): Color3;
  58048. /**
  58049. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58050. * @param otherColor defines the second operand
  58051. * @param result defines Color3 object to store the result into
  58052. * @returns the unmodified current Color3
  58053. */
  58054. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58055. /**
  58056. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58057. * @param otherColor defines the second operand
  58058. * @returns the new Color3
  58059. */
  58060. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58061. /**
  58062. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58063. * @param otherColor defines the second operand
  58064. * @param result defines Color3 object to store the result into
  58065. * @returns the unmodified current Color3
  58066. */
  58067. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58068. /**
  58069. * Copy the current object
  58070. * @returns a new Color3 copied the current one
  58071. */
  58072. clone(): Color3;
  58073. /**
  58074. * Copies the rgb values from the source in the current Color3
  58075. * @param source defines the source Color3 object
  58076. * @returns the updated Color3 object
  58077. */
  58078. copyFrom(source: DeepImmutable<Color3>): Color3;
  58079. /**
  58080. * Updates the Color3 rgb values from the given floats
  58081. * @param r defines the red component to read from
  58082. * @param g defines the green component to read from
  58083. * @param b defines the blue component to read from
  58084. * @returns the current Color3 object
  58085. */
  58086. copyFromFloats(r: number, g: number, b: number): Color3;
  58087. /**
  58088. * Updates the Color3 rgb values from the given floats
  58089. * @param r defines the red component to read from
  58090. * @param g defines the green component to read from
  58091. * @param b defines the blue component to read from
  58092. * @returns the current Color3 object
  58093. */
  58094. set(r: number, g: number, b: number): Color3;
  58095. /**
  58096. * Compute the Color3 hexadecimal code as a string
  58097. * @returns a string containing the hexadecimal representation of the Color3 object
  58098. */
  58099. toHexString(): string;
  58100. /**
  58101. * Computes a new Color3 converted from the current one to linear space
  58102. * @returns a new Color3 object
  58103. */
  58104. toLinearSpace(): Color3;
  58105. /**
  58106. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58107. * @param convertedColor defines the Color3 object where to store the linear space version
  58108. * @returns the unmodified Color3
  58109. */
  58110. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58111. /**
  58112. * Computes a new Color3 converted from the current one to gamma space
  58113. * @returns a new Color3 object
  58114. */
  58115. toGammaSpace(): Color3;
  58116. /**
  58117. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58118. * @param convertedColor defines the Color3 object where to store the gamma space version
  58119. * @returns the unmodified Color3
  58120. */
  58121. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58122. private static _BlackReadOnly;
  58123. /**
  58124. * Creates a new Color3 from the string containing valid hexadecimal values
  58125. * @param hex defines a string containing valid hexadecimal values
  58126. * @returns a new Color3 object
  58127. */
  58128. static FromHexString(hex: string): Color3;
  58129. /**
  58130. * Creates a new Vector3 from the starting index of the given array
  58131. * @param array defines the source array
  58132. * @param offset defines an offset in the source array
  58133. * @returns a new Color3 object
  58134. */
  58135. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58136. /**
  58137. * Creates a new Color3 from integer values (< 256)
  58138. * @param r defines the red component to read from (value between 0 and 255)
  58139. * @param g defines the green component to read from (value between 0 and 255)
  58140. * @param b defines the blue component to read from (value between 0 and 255)
  58141. * @returns a new Color3 object
  58142. */
  58143. static FromInts(r: number, g: number, b: number): Color3;
  58144. /**
  58145. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58146. * @param start defines the start Color3 value
  58147. * @param end defines the end Color3 value
  58148. * @param amount defines the gradient value between start and end
  58149. * @returns a new Color3 object
  58150. */
  58151. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58152. /**
  58153. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58154. * @param left defines the start value
  58155. * @param right defines the end value
  58156. * @param amount defines the gradient factor
  58157. * @param result defines the Color3 object where to store the result
  58158. */
  58159. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58160. /**
  58161. * Returns a Color3 value containing a red color
  58162. * @returns a new Color3 object
  58163. */
  58164. static Red(): Color3;
  58165. /**
  58166. * Returns a Color3 value containing a green color
  58167. * @returns a new Color3 object
  58168. */
  58169. static Green(): Color3;
  58170. /**
  58171. * Returns a Color3 value containing a blue color
  58172. * @returns a new Color3 object
  58173. */
  58174. static Blue(): Color3;
  58175. /**
  58176. * Returns a Color3 value containing a black color
  58177. * @returns a new Color3 object
  58178. */
  58179. static Black(): Color3;
  58180. /**
  58181. * Gets a Color3 value containing a black color that must not be updated
  58182. */
  58183. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58184. /**
  58185. * Returns a Color3 value containing a white color
  58186. * @returns a new Color3 object
  58187. */
  58188. static White(): Color3;
  58189. /**
  58190. * Returns a Color3 value containing a purple color
  58191. * @returns a new Color3 object
  58192. */
  58193. static Purple(): Color3;
  58194. /**
  58195. * Returns a Color3 value containing a magenta color
  58196. * @returns a new Color3 object
  58197. */
  58198. static Magenta(): Color3;
  58199. /**
  58200. * Returns a Color3 value containing a yellow color
  58201. * @returns a new Color3 object
  58202. */
  58203. static Yellow(): Color3;
  58204. /**
  58205. * Returns a Color3 value containing a gray color
  58206. * @returns a new Color3 object
  58207. */
  58208. static Gray(): Color3;
  58209. /**
  58210. * Returns a Color3 value containing a teal color
  58211. * @returns a new Color3 object
  58212. */
  58213. static Teal(): Color3;
  58214. /**
  58215. * Returns a Color3 value containing a random color
  58216. * @returns a new Color3 object
  58217. */
  58218. static Random(): Color3;
  58219. }
  58220. /**
  58221. * Class used to hold a RBGA color
  58222. */
  58223. export class Color4 {
  58224. /**
  58225. * Defines the red component (between 0 and 1, default is 0)
  58226. */
  58227. r: number;
  58228. /**
  58229. * Defines the green component (between 0 and 1, default is 0)
  58230. */
  58231. g: number;
  58232. /**
  58233. * Defines the blue component (between 0 and 1, default is 0)
  58234. */
  58235. b: number;
  58236. /**
  58237. * Defines the alpha component (between 0 and 1, default is 1)
  58238. */
  58239. a: number;
  58240. /**
  58241. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58242. * @param r defines the red component (between 0 and 1, default is 0)
  58243. * @param g defines the green component (between 0 and 1, default is 0)
  58244. * @param b defines the blue component (between 0 and 1, default is 0)
  58245. * @param a defines the alpha component (between 0 and 1, default is 1)
  58246. */
  58247. constructor(
  58248. /**
  58249. * Defines the red component (between 0 and 1, default is 0)
  58250. */
  58251. r?: number,
  58252. /**
  58253. * Defines the green component (between 0 and 1, default is 0)
  58254. */
  58255. g?: number,
  58256. /**
  58257. * Defines the blue component (between 0 and 1, default is 0)
  58258. */
  58259. b?: number,
  58260. /**
  58261. * Defines the alpha component (between 0 and 1, default is 1)
  58262. */
  58263. a?: number);
  58264. /**
  58265. * Adds in place the given Color4 values to the current Color4 object
  58266. * @param right defines the second operand
  58267. * @returns the current updated Color4 object
  58268. */
  58269. addInPlace(right: DeepImmutable<Color4>): Color4;
  58270. /**
  58271. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58272. * @returns the new array
  58273. */
  58274. asArray(): number[];
  58275. /**
  58276. * Stores from the starting index in the given array the Color4 successive values
  58277. * @param array defines the array where to store the r,g,b components
  58278. * @param index defines an optional index in the target array to define where to start storing values
  58279. * @returns the current Color4 object
  58280. */
  58281. toArray(array: number[], index?: number): Color4;
  58282. /**
  58283. * Determines equality between Color4 objects
  58284. * @param otherColor defines the second operand
  58285. * @returns true if the rgba values are equal to the given ones
  58286. */
  58287. equals(otherColor: DeepImmutable<Color4>): boolean;
  58288. /**
  58289. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58290. * @param right defines the second operand
  58291. * @returns a new Color4 object
  58292. */
  58293. add(right: DeepImmutable<Color4>): Color4;
  58294. /**
  58295. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58296. * @param right defines the second operand
  58297. * @returns a new Color4 object
  58298. */
  58299. subtract(right: DeepImmutable<Color4>): Color4;
  58300. /**
  58301. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58302. * @param right defines the second operand
  58303. * @param result defines the Color4 object where to store the result
  58304. * @returns the current Color4 object
  58305. */
  58306. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58307. /**
  58308. * Creates a new Color4 with the current Color4 values multiplied by scale
  58309. * @param scale defines the scaling factor to apply
  58310. * @returns a new Color4 object
  58311. */
  58312. scale(scale: number): Color4;
  58313. /**
  58314. * Multiplies the current Color4 values by scale and stores the result in "result"
  58315. * @param scale defines the scaling factor to apply
  58316. * @param result defines the Color4 object where to store the result
  58317. * @returns the current unmodified Color4
  58318. */
  58319. scaleToRef(scale: number, result: Color4): Color4;
  58320. /**
  58321. * Scale the current Color4 values by a factor and add the result to a given Color4
  58322. * @param scale defines the scale factor
  58323. * @param result defines the Color4 object where to store the result
  58324. * @returns the unmodified current Color4
  58325. */
  58326. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58327. /**
  58328. * Clamps the rgb values by the min and max values and stores the result into "result"
  58329. * @param min defines minimum clamping value (default is 0)
  58330. * @param max defines maximum clamping value (default is 1)
  58331. * @param result defines color to store the result into.
  58332. * @returns the cuurent Color4
  58333. */
  58334. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58335. /**
  58336. * Multipy an Color4 value by another and return a new Color4 object
  58337. * @param color defines the Color4 value to multiply by
  58338. * @returns a new Color4 object
  58339. */
  58340. multiply(color: Color4): Color4;
  58341. /**
  58342. * Multipy a Color4 value by another and push the result in a reference value
  58343. * @param color defines the Color4 value to multiply by
  58344. * @param result defines the Color4 to fill the result in
  58345. * @returns the result Color4
  58346. */
  58347. multiplyToRef(color: Color4, result: Color4): Color4;
  58348. /**
  58349. * Creates a string with the Color4 current values
  58350. * @returns the string representation of the Color4 object
  58351. */
  58352. toString(): string;
  58353. /**
  58354. * Returns the string "Color4"
  58355. * @returns "Color4"
  58356. */
  58357. getClassName(): string;
  58358. /**
  58359. * Compute the Color4 hash code
  58360. * @returns an unique number that can be used to hash Color4 objects
  58361. */
  58362. getHashCode(): number;
  58363. /**
  58364. * Creates a new Color4 copied from the current one
  58365. * @returns a new Color4 object
  58366. */
  58367. clone(): Color4;
  58368. /**
  58369. * Copies the given Color4 values into the current one
  58370. * @param source defines the source Color4 object
  58371. * @returns the current updated Color4 object
  58372. */
  58373. copyFrom(source: Color4): Color4;
  58374. /**
  58375. * Copies the given float values into the current one
  58376. * @param r defines the red component to read from
  58377. * @param g defines the green component to read from
  58378. * @param b defines the blue component to read from
  58379. * @param a defines the alpha component to read from
  58380. * @returns the current updated Color4 object
  58381. */
  58382. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58383. /**
  58384. * Copies the given float values into the current one
  58385. * @param r defines the red component to read from
  58386. * @param g defines the green component to read from
  58387. * @param b defines the blue component to read from
  58388. * @param a defines the alpha component to read from
  58389. * @returns the current updated Color4 object
  58390. */
  58391. set(r: number, g: number, b: number, a: number): Color4;
  58392. /**
  58393. * Compute the Color4 hexadecimal code as a string
  58394. * @returns a string containing the hexadecimal representation of the Color4 object
  58395. */
  58396. toHexString(): string;
  58397. /**
  58398. * Computes a new Color4 converted from the current one to linear space
  58399. * @returns a new Color4 object
  58400. */
  58401. toLinearSpace(): Color4;
  58402. /**
  58403. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58404. * @param convertedColor defines the Color4 object where to store the linear space version
  58405. * @returns the unmodified Color4
  58406. */
  58407. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58408. /**
  58409. * Computes a new Color4 converted from the current one to gamma space
  58410. * @returns a new Color4 object
  58411. */
  58412. toGammaSpace(): Color4;
  58413. /**
  58414. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58415. * @param convertedColor defines the Color4 object where to store the gamma space version
  58416. * @returns the unmodified Color4
  58417. */
  58418. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58419. /**
  58420. * Creates a new Color4 from the string containing valid hexadecimal values
  58421. * @param hex defines a string containing valid hexadecimal values
  58422. * @returns a new Color4 object
  58423. */
  58424. static FromHexString(hex: string): Color4;
  58425. /**
  58426. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58427. * @param left defines the start value
  58428. * @param right defines the end value
  58429. * @param amount defines the gradient factor
  58430. * @returns a new Color4 object
  58431. */
  58432. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58433. /**
  58434. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58435. * @param left defines the start value
  58436. * @param right defines the end value
  58437. * @param amount defines the gradient factor
  58438. * @param result defines the Color4 object where to store data
  58439. */
  58440. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58441. /**
  58442. * Creates a new Color4 from a Color3 and an alpha value
  58443. * @param color3 defines the source Color3 to read from
  58444. * @param alpha defines the alpha component (1.0 by default)
  58445. * @returns a new Color4 object
  58446. */
  58447. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58448. /**
  58449. * Creates a new Color4 from the starting index element of the given array
  58450. * @param array defines the source array to read from
  58451. * @param offset defines the offset in the source array
  58452. * @returns a new Color4 object
  58453. */
  58454. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58455. /**
  58456. * Creates a new Color3 from integer values (< 256)
  58457. * @param r defines the red component to read from (value between 0 and 255)
  58458. * @param g defines the green component to read from (value between 0 and 255)
  58459. * @param b defines the blue component to read from (value between 0 and 255)
  58460. * @param a defines the alpha component to read from (value between 0 and 255)
  58461. * @returns a new Color3 object
  58462. */
  58463. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58464. /**
  58465. * Check the content of a given array and convert it to an array containing RGBA data
  58466. * If the original array was already containing count * 4 values then it is returned directly
  58467. * @param colors defines the array to check
  58468. * @param count defines the number of RGBA data to expect
  58469. * @returns an array containing count * 4 values (RGBA)
  58470. */
  58471. static CheckColors4(colors: number[], count: number): number[];
  58472. }
  58473. /**
  58474. * Class representing a vector containing 2 coordinates
  58475. */
  58476. export class Vector2 {
  58477. /** defines the first coordinate */
  58478. x: number;
  58479. /** defines the second coordinate */
  58480. y: number;
  58481. /**
  58482. * Creates a new Vector2 from the given x and y coordinates
  58483. * @param x defines the first coordinate
  58484. * @param y defines the second coordinate
  58485. */
  58486. constructor(
  58487. /** defines the first coordinate */
  58488. x?: number,
  58489. /** defines the second coordinate */
  58490. y?: number);
  58491. /**
  58492. * Gets a string with the Vector2 coordinates
  58493. * @returns a string with the Vector2 coordinates
  58494. */
  58495. toString(): string;
  58496. /**
  58497. * Gets class name
  58498. * @returns the string "Vector2"
  58499. */
  58500. getClassName(): string;
  58501. /**
  58502. * Gets current vector hash code
  58503. * @returns the Vector2 hash code as a number
  58504. */
  58505. getHashCode(): number;
  58506. /**
  58507. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58508. * @param array defines the source array
  58509. * @param index defines the offset in source array
  58510. * @returns the current Vector2
  58511. */
  58512. toArray(array: FloatArray, index?: number): Vector2;
  58513. /**
  58514. * Copy the current vector to an array
  58515. * @returns a new array with 2 elements: the Vector2 coordinates.
  58516. */
  58517. asArray(): number[];
  58518. /**
  58519. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58520. * @param source defines the source Vector2
  58521. * @returns the current updated Vector2
  58522. */
  58523. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58524. /**
  58525. * Sets the Vector2 coordinates with the given floats
  58526. * @param x defines the first coordinate
  58527. * @param y defines the second coordinate
  58528. * @returns the current updated Vector2
  58529. */
  58530. copyFromFloats(x: number, y: number): Vector2;
  58531. /**
  58532. * Sets the Vector2 coordinates with the given floats
  58533. * @param x defines the first coordinate
  58534. * @param y defines the second coordinate
  58535. * @returns the current updated Vector2
  58536. */
  58537. set(x: number, y: number): Vector2;
  58538. /**
  58539. * Add another vector with the current one
  58540. * @param otherVector defines the other vector
  58541. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58542. */
  58543. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58544. /**
  58545. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58546. * @param otherVector defines the other vector
  58547. * @param result defines the target vector
  58548. * @returns the unmodified current Vector2
  58549. */
  58550. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58551. /**
  58552. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58553. * @param otherVector defines the other vector
  58554. * @returns the current updated Vector2
  58555. */
  58556. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58557. /**
  58558. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58559. * @param otherVector defines the other vector
  58560. * @returns a new Vector2
  58561. */
  58562. addVector3(otherVector: Vector3): Vector2;
  58563. /**
  58564. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58565. * @param otherVector defines the other vector
  58566. * @returns a new Vector2
  58567. */
  58568. subtract(otherVector: Vector2): Vector2;
  58569. /**
  58570. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58571. * @param otherVector defines the other vector
  58572. * @param result defines the target vector
  58573. * @returns the unmodified current Vector2
  58574. */
  58575. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58576. /**
  58577. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58578. * @param otherVector defines the other vector
  58579. * @returns the current updated Vector2
  58580. */
  58581. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58582. /**
  58583. * Multiplies in place the current Vector2 coordinates by the given ones
  58584. * @param otherVector defines the other vector
  58585. * @returns the current updated Vector2
  58586. */
  58587. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58588. /**
  58589. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58590. * @param otherVector defines the other vector
  58591. * @returns a new Vector2
  58592. */
  58593. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58594. /**
  58595. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58596. * @param otherVector defines the other vector
  58597. * @param result defines the target vector
  58598. * @returns the unmodified current Vector2
  58599. */
  58600. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58601. /**
  58602. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58603. * @param x defines the first coordinate
  58604. * @param y defines the second coordinate
  58605. * @returns a new Vector2
  58606. */
  58607. multiplyByFloats(x: number, y: number): Vector2;
  58608. /**
  58609. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58610. * @param otherVector defines the other vector
  58611. * @returns a new Vector2
  58612. */
  58613. divide(otherVector: Vector2): Vector2;
  58614. /**
  58615. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58616. * @param otherVector defines the other vector
  58617. * @param result defines the target vector
  58618. * @returns the unmodified current Vector2
  58619. */
  58620. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58621. /**
  58622. * Divides the current Vector2 coordinates by the given ones
  58623. * @param otherVector defines the other vector
  58624. * @returns the current updated Vector2
  58625. */
  58626. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58627. /**
  58628. * Gets a new Vector2 with current Vector2 negated coordinates
  58629. * @returns a new Vector2
  58630. */
  58631. negate(): Vector2;
  58632. /**
  58633. * Multiply the Vector2 coordinates by scale
  58634. * @param scale defines the scaling factor
  58635. * @returns the current updated Vector2
  58636. */
  58637. scaleInPlace(scale: number): Vector2;
  58638. /**
  58639. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58640. * @param scale defines the scaling factor
  58641. * @returns a new Vector2
  58642. */
  58643. scale(scale: number): Vector2;
  58644. /**
  58645. * Scale the current Vector2 values by a factor to a given Vector2
  58646. * @param scale defines the scale factor
  58647. * @param result defines the Vector2 object where to store the result
  58648. * @returns the unmodified current Vector2
  58649. */
  58650. scaleToRef(scale: number, result: Vector2): Vector2;
  58651. /**
  58652. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58653. * @param scale defines the scale factor
  58654. * @param result defines the Vector2 object where to store the result
  58655. * @returns the unmodified current Vector2
  58656. */
  58657. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58658. /**
  58659. * Gets a boolean if two vectors are equals
  58660. * @param otherVector defines the other vector
  58661. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58662. */
  58663. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58664. /**
  58665. * Gets a boolean if two vectors are equals (using an epsilon value)
  58666. * @param otherVector defines the other vector
  58667. * @param epsilon defines the minimal distance to consider equality
  58668. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58669. */
  58670. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58671. /**
  58672. * Gets a new Vector2 from current Vector2 floored values
  58673. * @returns a new Vector2
  58674. */
  58675. floor(): Vector2;
  58676. /**
  58677. * Gets a new Vector2 from current Vector2 floored values
  58678. * @returns a new Vector2
  58679. */
  58680. fract(): Vector2;
  58681. /**
  58682. * Gets the length of the vector
  58683. * @returns the vector length (float)
  58684. */
  58685. length(): number;
  58686. /**
  58687. * Gets the vector squared length
  58688. * @returns the vector squared length (float)
  58689. */
  58690. lengthSquared(): number;
  58691. /**
  58692. * Normalize the vector
  58693. * @returns the current updated Vector2
  58694. */
  58695. normalize(): Vector2;
  58696. /**
  58697. * Gets a new Vector2 copied from the Vector2
  58698. * @returns a new Vector2
  58699. */
  58700. clone(): Vector2;
  58701. /**
  58702. * Gets a new Vector2(0, 0)
  58703. * @returns a new Vector2
  58704. */
  58705. static Zero(): Vector2;
  58706. /**
  58707. * Gets a new Vector2(1, 1)
  58708. * @returns a new Vector2
  58709. */
  58710. static One(): Vector2;
  58711. /**
  58712. * Gets a new Vector2 set from the given index element of the given array
  58713. * @param array defines the data source
  58714. * @param offset defines the offset in the data source
  58715. * @returns a new Vector2
  58716. */
  58717. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58718. /**
  58719. * Sets "result" from the given index element of the given array
  58720. * @param array defines the data source
  58721. * @param offset defines the offset in the data source
  58722. * @param result defines the target vector
  58723. */
  58724. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58725. /**
  58726. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58727. * @param value1 defines 1st point of control
  58728. * @param value2 defines 2nd point of control
  58729. * @param value3 defines 3rd point of control
  58730. * @param value4 defines 4th point of control
  58731. * @param amount defines the interpolation factor
  58732. * @returns a new Vector2
  58733. */
  58734. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58735. /**
  58736. * 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".
  58737. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58738. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58739. * @param value defines the value to clamp
  58740. * @param min defines the lower limit
  58741. * @param max defines the upper limit
  58742. * @returns a new Vector2
  58743. */
  58744. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58745. /**
  58746. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58747. * @param value1 defines the 1st control point
  58748. * @param tangent1 defines the outgoing tangent
  58749. * @param value2 defines the 2nd control point
  58750. * @param tangent2 defines the incoming tangent
  58751. * @param amount defines the interpolation factor
  58752. * @returns a new Vector2
  58753. */
  58754. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58755. /**
  58756. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58757. * @param start defines the start vector
  58758. * @param end defines the end vector
  58759. * @param amount defines the interpolation factor
  58760. * @returns a new Vector2
  58761. */
  58762. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58763. /**
  58764. * Gets the dot product of the vector "left" and the vector "right"
  58765. * @param left defines first vector
  58766. * @param right defines second vector
  58767. * @returns the dot product (float)
  58768. */
  58769. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58770. /**
  58771. * Returns a new Vector2 equal to the normalized given vector
  58772. * @param vector defines the vector to normalize
  58773. * @returns a new Vector2
  58774. */
  58775. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58776. /**
  58777. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58778. * @param left defines 1st vector
  58779. * @param right defines 2nd vector
  58780. * @returns a new Vector2
  58781. */
  58782. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58783. /**
  58784. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58785. * @param left defines 1st vector
  58786. * @param right defines 2nd vector
  58787. * @returns a new Vector2
  58788. */
  58789. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58790. /**
  58791. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58792. * @param vector defines the vector to transform
  58793. * @param transformation defines the matrix to apply
  58794. * @returns a new Vector2
  58795. */
  58796. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58797. /**
  58798. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58799. * @param vector defines the vector to transform
  58800. * @param transformation defines the matrix to apply
  58801. * @param result defines the target vector
  58802. */
  58803. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58804. /**
  58805. * Determines if a given vector is included in a triangle
  58806. * @param p defines the vector to test
  58807. * @param p0 defines 1st triangle point
  58808. * @param p1 defines 2nd triangle point
  58809. * @param p2 defines 3rd triangle point
  58810. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58811. */
  58812. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58813. /**
  58814. * Gets the distance between the vectors "value1" and "value2"
  58815. * @param value1 defines first vector
  58816. * @param value2 defines second vector
  58817. * @returns the distance between vectors
  58818. */
  58819. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58820. /**
  58821. * Returns the squared distance between the vectors "value1" and "value2"
  58822. * @param value1 defines first vector
  58823. * @param value2 defines second vector
  58824. * @returns the squared distance between vectors
  58825. */
  58826. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58827. /**
  58828. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58829. * @param value1 defines first vector
  58830. * @param value2 defines second vector
  58831. * @returns a new Vector2
  58832. */
  58833. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58834. /**
  58835. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58836. * @param p defines the middle point
  58837. * @param segA defines one point of the segment
  58838. * @param segB defines the other point of the segment
  58839. * @returns the shortest distance
  58840. */
  58841. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58842. }
  58843. /**
  58844. * Classed used to store (x,y,z) vector representation
  58845. * A Vector3 is the main object used in 3D geometry
  58846. * It can represent etiher the coordinates of a point the space, either a direction
  58847. * Reminder: js uses a left handed forward facing system
  58848. */
  58849. export class Vector3 {
  58850. /**
  58851. * Defines the first coordinates (on X axis)
  58852. */
  58853. x: number;
  58854. /**
  58855. * Defines the second coordinates (on Y axis)
  58856. */
  58857. y: number;
  58858. /**
  58859. * Defines the third coordinates (on Z axis)
  58860. */
  58861. z: number;
  58862. private static _UpReadOnly;
  58863. /**
  58864. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58865. * @param x defines the first coordinates (on X axis)
  58866. * @param y defines the second coordinates (on Y axis)
  58867. * @param z defines the third coordinates (on Z axis)
  58868. */
  58869. constructor(
  58870. /**
  58871. * Defines the first coordinates (on X axis)
  58872. */
  58873. x?: number,
  58874. /**
  58875. * Defines the second coordinates (on Y axis)
  58876. */
  58877. y?: number,
  58878. /**
  58879. * Defines the third coordinates (on Z axis)
  58880. */
  58881. z?: number);
  58882. /**
  58883. * Creates a string representation of the Vector3
  58884. * @returns a string with the Vector3 coordinates.
  58885. */
  58886. toString(): string;
  58887. /**
  58888. * Gets the class name
  58889. * @returns the string "Vector3"
  58890. */
  58891. getClassName(): string;
  58892. /**
  58893. * Creates the Vector3 hash code
  58894. * @returns a number which tends to be unique between Vector3 instances
  58895. */
  58896. getHashCode(): number;
  58897. /**
  58898. * Creates an array containing three elements : the coordinates of the Vector3
  58899. * @returns a new array of numbers
  58900. */
  58901. asArray(): number[];
  58902. /**
  58903. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58904. * @param array defines the destination array
  58905. * @param index defines the offset in the destination array
  58906. * @returns the current Vector3
  58907. */
  58908. toArray(array: FloatArray, index?: number): Vector3;
  58909. /**
  58910. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58911. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58912. */
  58913. toQuaternion(): Quaternion;
  58914. /**
  58915. * Adds the given vector to the current Vector3
  58916. * @param otherVector defines the second operand
  58917. * @returns the current updated Vector3
  58918. */
  58919. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58920. /**
  58921. * Adds the given coordinates to the current Vector3
  58922. * @param x defines the x coordinate of the operand
  58923. * @param y defines the y coordinate of the operand
  58924. * @param z defines the z coordinate of the operand
  58925. * @returns the current updated Vector3
  58926. */
  58927. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58928. /**
  58929. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58930. * @param otherVector defines the second operand
  58931. * @returns the resulting Vector3
  58932. */
  58933. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58934. /**
  58935. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58936. * @param otherVector defines the second operand
  58937. * @param result defines the Vector3 object where to store the result
  58938. * @returns the current Vector3
  58939. */
  58940. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58941. /**
  58942. * Subtract the given vector from the current Vector3
  58943. * @param otherVector defines the second operand
  58944. * @returns the current updated Vector3
  58945. */
  58946. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58947. /**
  58948. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58949. * @param otherVector defines the second operand
  58950. * @returns the resulting Vector3
  58951. */
  58952. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58953. /**
  58954. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58955. * @param otherVector defines the second operand
  58956. * @param result defines the Vector3 object where to store the result
  58957. * @returns the current Vector3
  58958. */
  58959. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58960. /**
  58961. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58962. * @param x defines the x coordinate of the operand
  58963. * @param y defines the y coordinate of the operand
  58964. * @param z defines the z coordinate of the operand
  58965. * @returns the resulting Vector3
  58966. */
  58967. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58968. /**
  58969. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58970. * @param x defines the x coordinate of the operand
  58971. * @param y defines the y coordinate of the operand
  58972. * @param z defines the z coordinate of the operand
  58973. * @param result defines the Vector3 object where to store the result
  58974. * @returns the current Vector3
  58975. */
  58976. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58977. /**
  58978. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58979. * @returns a new Vector3
  58980. */
  58981. negate(): Vector3;
  58982. /**
  58983. * Multiplies the Vector3 coordinates by the float "scale"
  58984. * @param scale defines the multiplier factor
  58985. * @returns the current updated Vector3
  58986. */
  58987. scaleInPlace(scale: number): Vector3;
  58988. /**
  58989. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58990. * @param scale defines the multiplier factor
  58991. * @returns a new Vector3
  58992. */
  58993. scale(scale: number): Vector3;
  58994. /**
  58995. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58996. * @param scale defines the multiplier factor
  58997. * @param result defines the Vector3 object where to store the result
  58998. * @returns the current Vector3
  58999. */
  59000. scaleToRef(scale: number, result: Vector3): Vector3;
  59001. /**
  59002. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59003. * @param scale defines the scale factor
  59004. * @param result defines the Vector3 object where to store the result
  59005. * @returns the unmodified current Vector3
  59006. */
  59007. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59008. /**
  59009. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59010. * @param otherVector defines the second operand
  59011. * @returns true if both vectors are equals
  59012. */
  59013. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59014. /**
  59015. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59016. * @param otherVector defines the second operand
  59017. * @param epsilon defines the minimal distance to define values as equals
  59018. * @returns true if both vectors are distant less than epsilon
  59019. */
  59020. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59021. /**
  59022. * Returns true if the current Vector3 coordinates equals the given floats
  59023. * @param x defines the x coordinate of the operand
  59024. * @param y defines the y coordinate of the operand
  59025. * @param z defines the z coordinate of the operand
  59026. * @returns true if both vectors are equals
  59027. */
  59028. equalsToFloats(x: number, y: number, z: number): boolean;
  59029. /**
  59030. * Multiplies the current Vector3 coordinates by the given ones
  59031. * @param otherVector defines the second operand
  59032. * @returns the current updated Vector3
  59033. */
  59034. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59035. /**
  59036. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59037. * @param otherVector defines the second operand
  59038. * @returns the new Vector3
  59039. */
  59040. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59041. /**
  59042. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59043. * @param otherVector defines the second operand
  59044. * @param result defines the Vector3 object where to store the result
  59045. * @returns the current Vector3
  59046. */
  59047. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59048. /**
  59049. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59050. * @param x defines the x coordinate of the operand
  59051. * @param y defines the y coordinate of the operand
  59052. * @param z defines the z coordinate of the operand
  59053. * @returns the new Vector3
  59054. */
  59055. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59056. /**
  59057. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59058. * @param otherVector defines the second operand
  59059. * @returns the new Vector3
  59060. */
  59061. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59062. /**
  59063. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59064. * @param otherVector defines the second operand
  59065. * @param result defines the Vector3 object where to store the result
  59066. * @returns the current Vector3
  59067. */
  59068. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59069. /**
  59070. * Divides the current Vector3 coordinates by the given ones.
  59071. * @param otherVector defines the second operand
  59072. * @returns the current updated Vector3
  59073. */
  59074. divideInPlace(otherVector: Vector3): Vector3;
  59075. /**
  59076. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59077. * @param other defines the second operand
  59078. * @returns the current updated Vector3
  59079. */
  59080. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59081. /**
  59082. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59083. * @param other defines the second operand
  59084. * @returns the current updated Vector3
  59085. */
  59086. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59087. /**
  59088. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59089. * @param x defines the x coordinate of the operand
  59090. * @param y defines the y coordinate of the operand
  59091. * @param z defines the z coordinate of the operand
  59092. * @returns the current updated Vector3
  59093. */
  59094. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59095. /**
  59096. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59097. * @param x defines the x coordinate of the operand
  59098. * @param y defines the y coordinate of the operand
  59099. * @param z defines the z coordinate of the operand
  59100. * @returns the current updated Vector3
  59101. */
  59102. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59103. /**
  59104. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59105. * Check if is non uniform within a certain amount of decimal places to account for this
  59106. * @param epsilon the amount the values can differ
  59107. * @returns if the the vector is non uniform to a certain number of decimal places
  59108. */
  59109. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59110. /**
  59111. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59112. */
  59113. readonly isNonUniform: boolean;
  59114. /**
  59115. * Gets a new Vector3 from current Vector3 floored values
  59116. * @returns a new Vector3
  59117. */
  59118. floor(): Vector3;
  59119. /**
  59120. * Gets a new Vector3 from current Vector3 floored values
  59121. * @returns a new Vector3
  59122. */
  59123. fract(): Vector3;
  59124. /**
  59125. * Gets the length of the Vector3
  59126. * @returns the length of the Vecto3
  59127. */
  59128. length(): number;
  59129. /**
  59130. * Gets the squared length of the Vector3
  59131. * @returns squared length of the Vector3
  59132. */
  59133. lengthSquared(): number;
  59134. /**
  59135. * Normalize the current Vector3.
  59136. * Please note that this is an in place operation.
  59137. * @returns the current updated Vector3
  59138. */
  59139. normalize(): Vector3;
  59140. /**
  59141. * Reorders the x y z properties of the vector in place
  59142. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59143. * @returns the current updated vector
  59144. */
  59145. reorderInPlace(order: string): this;
  59146. /**
  59147. * Rotates the vector around 0,0,0 by a quaternion
  59148. * @param quaternion the rotation quaternion
  59149. * @param result vector to store the result
  59150. * @returns the resulting vector
  59151. */
  59152. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59153. /**
  59154. * Rotates a vector around a given point
  59155. * @param quaternion the rotation quaternion
  59156. * @param point the point to rotate around
  59157. * @param result vector to store the result
  59158. * @returns the resulting vector
  59159. */
  59160. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59161. /**
  59162. * Normalize the current Vector3 with the given input length.
  59163. * Please note that this is an in place operation.
  59164. * @param len the length of the vector
  59165. * @returns the current updated Vector3
  59166. */
  59167. normalizeFromLength(len: number): Vector3;
  59168. /**
  59169. * Normalize the current Vector3 to a new vector
  59170. * @returns the new Vector3
  59171. */
  59172. normalizeToNew(): Vector3;
  59173. /**
  59174. * Normalize the current Vector3 to the reference
  59175. * @param reference define the Vector3 to update
  59176. * @returns the updated Vector3
  59177. */
  59178. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59179. /**
  59180. * Creates a new Vector3 copied from the current Vector3
  59181. * @returns the new Vector3
  59182. */
  59183. clone(): Vector3;
  59184. /**
  59185. * Copies the given vector coordinates to the current Vector3 ones
  59186. * @param source defines the source Vector3
  59187. * @returns the current updated Vector3
  59188. */
  59189. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59190. /**
  59191. * Copies the given floats to the current Vector3 coordinates
  59192. * @param x defines the x coordinate of the operand
  59193. * @param y defines the y coordinate of the operand
  59194. * @param z defines the z coordinate of the operand
  59195. * @returns the current updated Vector3
  59196. */
  59197. copyFromFloats(x: number, y: number, z: number): Vector3;
  59198. /**
  59199. * Copies the given floats to the current Vector3 coordinates
  59200. * @param x defines the x coordinate of the operand
  59201. * @param y defines the y coordinate of the operand
  59202. * @param z defines the z coordinate of the operand
  59203. * @returns the current updated Vector3
  59204. */
  59205. set(x: number, y: number, z: number): Vector3;
  59206. /**
  59207. * Copies the given float to the current Vector3 coordinates
  59208. * @param v defines the x, y and z coordinates of the operand
  59209. * @returns the current updated Vector3
  59210. */
  59211. setAll(v: number): Vector3;
  59212. /**
  59213. * Get the clip factor between two vectors
  59214. * @param vector0 defines the first operand
  59215. * @param vector1 defines the second operand
  59216. * @param axis defines the axis to use
  59217. * @param size defines the size along the axis
  59218. * @returns the clip factor
  59219. */
  59220. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59221. /**
  59222. * Get angle between two vectors
  59223. * @param vector0 angle between vector0 and vector1
  59224. * @param vector1 angle between vector0 and vector1
  59225. * @param normal direction of the normal
  59226. * @return the angle between vector0 and vector1
  59227. */
  59228. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59229. /**
  59230. * Returns a new Vector3 set from the index "offset" of the given array
  59231. * @param array defines the source array
  59232. * @param offset defines the offset in the source array
  59233. * @returns the new Vector3
  59234. */
  59235. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59236. /**
  59237. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59238. * This function is deprecated. Use FromArray instead
  59239. * @param array defines the source array
  59240. * @param offset defines the offset in the source array
  59241. * @returns the new Vector3
  59242. */
  59243. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59244. /**
  59245. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59246. * @param array defines the source array
  59247. * @param offset defines the offset in the source array
  59248. * @param result defines the Vector3 where to store the result
  59249. */
  59250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59251. /**
  59252. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59253. * This function is deprecated. Use FromArrayToRef instead.
  59254. * @param array defines the source array
  59255. * @param offset defines the offset in the source array
  59256. * @param result defines the Vector3 where to store the result
  59257. */
  59258. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59259. /**
  59260. * Sets the given vector "result" with the given floats.
  59261. * @param x defines the x coordinate of the source
  59262. * @param y defines the y coordinate of the source
  59263. * @param z defines the z coordinate of the source
  59264. * @param result defines the Vector3 where to store the result
  59265. */
  59266. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59267. /**
  59268. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59269. * @returns a new empty Vector3
  59270. */
  59271. static Zero(): Vector3;
  59272. /**
  59273. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59274. * @returns a new unit Vector3
  59275. */
  59276. static One(): Vector3;
  59277. /**
  59278. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59279. * @returns a new up Vector3
  59280. */
  59281. static Up(): Vector3;
  59282. /**
  59283. * Gets a up Vector3 that must not be updated
  59284. */
  59285. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59286. /**
  59287. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59288. * @returns a new down Vector3
  59289. */
  59290. static Down(): Vector3;
  59291. /**
  59292. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59293. * @returns a new forward Vector3
  59294. */
  59295. static Forward(): Vector3;
  59296. /**
  59297. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59298. * @returns a new forward Vector3
  59299. */
  59300. static Backward(): Vector3;
  59301. /**
  59302. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59303. * @returns a new right Vector3
  59304. */
  59305. static Right(): Vector3;
  59306. /**
  59307. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59308. * @returns a new left Vector3
  59309. */
  59310. static Left(): Vector3;
  59311. /**
  59312. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59313. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59314. * @param vector defines the Vector3 to transform
  59315. * @param transformation defines the transformation matrix
  59316. * @returns the transformed Vector3
  59317. */
  59318. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59319. /**
  59320. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59321. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59322. * @param vector defines the Vector3 to transform
  59323. * @param transformation defines the transformation matrix
  59324. * @param result defines the Vector3 where to store the result
  59325. */
  59326. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59327. /**
  59328. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59329. * This method computes tranformed coordinates only, not transformed direction vectors
  59330. * @param x define the x coordinate of the source vector
  59331. * @param y define the y coordinate of the source vector
  59332. * @param z define the z coordinate of the source vector
  59333. * @param transformation defines the transformation matrix
  59334. * @param result defines the Vector3 where to store the result
  59335. */
  59336. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59337. /**
  59338. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59339. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59340. * @param vector defines the Vector3 to transform
  59341. * @param transformation defines the transformation matrix
  59342. * @returns the new Vector3
  59343. */
  59344. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59345. /**
  59346. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59347. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59348. * @param vector defines the Vector3 to transform
  59349. * @param transformation defines the transformation matrix
  59350. * @param result defines the Vector3 where to store the result
  59351. */
  59352. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59353. /**
  59354. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59355. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59356. * @param x define the x coordinate of the source vector
  59357. * @param y define the y coordinate of the source vector
  59358. * @param z define the z coordinate of the source vector
  59359. * @param transformation defines the transformation matrix
  59360. * @param result defines the Vector3 where to store the result
  59361. */
  59362. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59363. /**
  59364. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59365. * @param value1 defines the first control point
  59366. * @param value2 defines the second control point
  59367. * @param value3 defines the third control point
  59368. * @param value4 defines the fourth control point
  59369. * @param amount defines the amount on the spline to use
  59370. * @returns the new Vector3
  59371. */
  59372. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59373. /**
  59374. * 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"
  59375. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59376. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59377. * @param value defines the current value
  59378. * @param min defines the lower range value
  59379. * @param max defines the upper range value
  59380. * @returns the new Vector3
  59381. */
  59382. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59383. /**
  59384. * 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"
  59385. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59386. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59387. * @param value defines the current value
  59388. * @param min defines the lower range value
  59389. * @param max defines the upper range value
  59390. * @param result defines the Vector3 where to store the result
  59391. */
  59392. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59393. /**
  59394. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59395. * @param value1 defines the first control point
  59396. * @param tangent1 defines the first tangent vector
  59397. * @param value2 defines the second control point
  59398. * @param tangent2 defines the second tangent vector
  59399. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59400. * @returns the new Vector3
  59401. */
  59402. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59403. /**
  59404. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59405. * @param start defines the start value
  59406. * @param end defines the end value
  59407. * @param amount max defines amount between both (between 0 and 1)
  59408. * @returns the new Vector3
  59409. */
  59410. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59411. /**
  59412. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59413. * @param start defines the start value
  59414. * @param end defines the end value
  59415. * @param amount max defines amount between both (between 0 and 1)
  59416. * @param result defines the Vector3 where to store the result
  59417. */
  59418. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59419. /**
  59420. * Returns the dot product (float) between the vectors "left" and "right"
  59421. * @param left defines the left operand
  59422. * @param right defines the right operand
  59423. * @returns the dot product
  59424. */
  59425. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59426. /**
  59427. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59428. * The cross product is then orthogonal to both "left" and "right"
  59429. * @param left defines the left operand
  59430. * @param right defines the right operand
  59431. * @returns the cross product
  59432. */
  59433. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59434. /**
  59435. * Sets the given vector "result" with the cross product of "left" and "right"
  59436. * The cross product is then orthogonal to both "left" and "right"
  59437. * @param left defines the left operand
  59438. * @param right defines the right operand
  59439. * @param result defines the Vector3 where to store the result
  59440. */
  59441. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59442. /**
  59443. * Returns a new Vector3 as the normalization of the given vector
  59444. * @param vector defines the Vector3 to normalize
  59445. * @returns the new Vector3
  59446. */
  59447. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59448. /**
  59449. * Sets the given vector "result" with the normalization of the given first vector
  59450. * @param vector defines the Vector3 to normalize
  59451. * @param result defines the Vector3 where to store the result
  59452. */
  59453. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59454. /**
  59455. * Project a Vector3 onto screen space
  59456. * @param vector defines the Vector3 to project
  59457. * @param world defines the world matrix to use
  59458. * @param transform defines the transform (view x projection) matrix to use
  59459. * @param viewport defines the screen viewport to use
  59460. * @returns the new Vector3
  59461. */
  59462. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59463. /** @hidden */
  59464. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59465. /**
  59466. * Unproject from screen space to object space
  59467. * @param source defines the screen space Vector3 to use
  59468. * @param viewportWidth defines the current width of the viewport
  59469. * @param viewportHeight defines the current height of the viewport
  59470. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59471. * @param transform defines the transform (view x projection) matrix to use
  59472. * @returns the new Vector3
  59473. */
  59474. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59475. /**
  59476. * Unproject from screen space to object space
  59477. * @param source defines the screen space Vector3 to use
  59478. * @param viewportWidth defines the current width of the viewport
  59479. * @param viewportHeight defines the current height of the viewport
  59480. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59481. * @param view defines the view matrix to use
  59482. * @param projection defines the projection matrix to use
  59483. * @returns the new Vector3
  59484. */
  59485. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59486. /**
  59487. * Unproject from screen space to object space
  59488. * @param source defines the screen space Vector3 to use
  59489. * @param viewportWidth defines the current width of the viewport
  59490. * @param viewportHeight defines the current height of the viewport
  59491. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59492. * @param view defines the view matrix to use
  59493. * @param projection defines the projection matrix to use
  59494. * @param result defines the Vector3 where to store the result
  59495. */
  59496. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59497. /**
  59498. * Unproject from screen space to object space
  59499. * @param sourceX defines the screen space x coordinate to use
  59500. * @param sourceY defines the screen space y coordinate to use
  59501. * @param sourceZ defines the screen space z coordinate to use
  59502. * @param viewportWidth defines the current width of the viewport
  59503. * @param viewportHeight defines the current height of the viewport
  59504. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59505. * @param view defines the view matrix to use
  59506. * @param projection defines the projection matrix to use
  59507. * @param result defines the Vector3 where to store the result
  59508. */
  59509. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59510. /**
  59511. * Gets the minimal coordinate values between two Vector3
  59512. * @param left defines the first operand
  59513. * @param right defines the second operand
  59514. * @returns the new Vector3
  59515. */
  59516. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59517. /**
  59518. * Gets the maximal coordinate values between two Vector3
  59519. * @param left defines the first operand
  59520. * @param right defines the second operand
  59521. * @returns the new Vector3
  59522. */
  59523. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59524. /**
  59525. * Returns the distance between the vectors "value1" and "value2"
  59526. * @param value1 defines the first operand
  59527. * @param value2 defines the second operand
  59528. * @returns the distance
  59529. */
  59530. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59531. /**
  59532. * Returns the squared distance between the vectors "value1" and "value2"
  59533. * @param value1 defines the first operand
  59534. * @param value2 defines the second operand
  59535. * @returns the squared distance
  59536. */
  59537. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59538. /**
  59539. * Returns a new Vector3 located at the center between "value1" and "value2"
  59540. * @param value1 defines the first operand
  59541. * @param value2 defines the second operand
  59542. * @returns the new Vector3
  59543. */
  59544. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59545. /**
  59546. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59547. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59548. * to something in order to rotate it from its local system to the given target system
  59549. * Note: axis1, axis2 and axis3 are normalized during this operation
  59550. * @param axis1 defines the first axis
  59551. * @param axis2 defines the second axis
  59552. * @param axis3 defines the third axis
  59553. * @returns a new Vector3
  59554. */
  59555. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59556. /**
  59557. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59558. * @param axis1 defines the first axis
  59559. * @param axis2 defines the second axis
  59560. * @param axis3 defines the third axis
  59561. * @param ref defines the Vector3 where to store the result
  59562. */
  59563. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59564. }
  59565. /**
  59566. * Vector4 class created for EulerAngle class conversion to Quaternion
  59567. */
  59568. export class Vector4 {
  59569. /** x value of the vector */
  59570. x: number;
  59571. /** y value of the vector */
  59572. y: number;
  59573. /** z value of the vector */
  59574. z: number;
  59575. /** w value of the vector */
  59576. w: number;
  59577. /**
  59578. * Creates a Vector4 object from the given floats.
  59579. * @param x x value of the vector
  59580. * @param y y value of the vector
  59581. * @param z z value of the vector
  59582. * @param w w value of the vector
  59583. */
  59584. constructor(
  59585. /** x value of the vector */
  59586. x: number,
  59587. /** y value of the vector */
  59588. y: number,
  59589. /** z value of the vector */
  59590. z: number,
  59591. /** w value of the vector */
  59592. w: number);
  59593. /**
  59594. * Returns the string with the Vector4 coordinates.
  59595. * @returns a string containing all the vector values
  59596. */
  59597. toString(): string;
  59598. /**
  59599. * Returns the string "Vector4".
  59600. * @returns "Vector4"
  59601. */
  59602. getClassName(): string;
  59603. /**
  59604. * Returns the Vector4 hash code.
  59605. * @returns a unique hash code
  59606. */
  59607. getHashCode(): number;
  59608. /**
  59609. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59610. * @returns the resulting array
  59611. */
  59612. asArray(): number[];
  59613. /**
  59614. * Populates the given array from the given index with the Vector4 coordinates.
  59615. * @param array array to populate
  59616. * @param index index of the array to start at (default: 0)
  59617. * @returns the Vector4.
  59618. */
  59619. toArray(array: FloatArray, index?: number): Vector4;
  59620. /**
  59621. * Adds the given vector to the current Vector4.
  59622. * @param otherVector the vector to add
  59623. * @returns the updated Vector4.
  59624. */
  59625. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59626. /**
  59627. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59628. * @param otherVector the vector to add
  59629. * @returns the resulting vector
  59630. */
  59631. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59632. /**
  59633. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59634. * @param otherVector the vector to add
  59635. * @param result the vector to store the result
  59636. * @returns the current Vector4.
  59637. */
  59638. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59639. /**
  59640. * Subtract in place the given vector from the current Vector4.
  59641. * @param otherVector the vector to subtract
  59642. * @returns the updated Vector4.
  59643. */
  59644. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59645. /**
  59646. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59647. * @param otherVector the vector to add
  59648. * @returns the new vector with the result
  59649. */
  59650. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59651. /**
  59652. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59653. * @param otherVector the vector to subtract
  59654. * @param result the vector to store the result
  59655. * @returns the current Vector4.
  59656. */
  59657. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59658. /**
  59659. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59660. */
  59661. /**
  59662. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59663. * @param x value to subtract
  59664. * @param y value to subtract
  59665. * @param z value to subtract
  59666. * @param w value to subtract
  59667. * @returns new vector containing the result
  59668. */
  59669. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59670. /**
  59671. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59672. * @param x value to subtract
  59673. * @param y value to subtract
  59674. * @param z value to subtract
  59675. * @param w value to subtract
  59676. * @param result the vector to store the result in
  59677. * @returns the current Vector4.
  59678. */
  59679. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59680. /**
  59681. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59682. * @returns a new vector with the negated values
  59683. */
  59684. negate(): Vector4;
  59685. /**
  59686. * Multiplies the current Vector4 coordinates by scale (float).
  59687. * @param scale the number to scale with
  59688. * @returns the updated Vector4.
  59689. */
  59690. scaleInPlace(scale: number): Vector4;
  59691. /**
  59692. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59693. * @param scale the number to scale with
  59694. * @returns a new vector with the result
  59695. */
  59696. scale(scale: number): Vector4;
  59697. /**
  59698. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59699. * @param scale the number to scale with
  59700. * @param result a vector to store the result in
  59701. * @returns the current Vector4.
  59702. */
  59703. scaleToRef(scale: number, result: Vector4): Vector4;
  59704. /**
  59705. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59706. * @param scale defines the scale factor
  59707. * @param result defines the Vector4 object where to store the result
  59708. * @returns the unmodified current Vector4
  59709. */
  59710. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59711. /**
  59712. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59713. * @param otherVector the vector to compare against
  59714. * @returns true if they are equal
  59715. */
  59716. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59717. /**
  59718. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59719. * @param otherVector vector to compare against
  59720. * @param epsilon (Default: very small number)
  59721. * @returns true if they are equal
  59722. */
  59723. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59724. /**
  59725. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59726. * @param x x value to compare against
  59727. * @param y y value to compare against
  59728. * @param z z value to compare against
  59729. * @param w w value to compare against
  59730. * @returns true if equal
  59731. */
  59732. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59733. /**
  59734. * Multiplies in place the current Vector4 by the given one.
  59735. * @param otherVector vector to multiple with
  59736. * @returns the updated Vector4.
  59737. */
  59738. multiplyInPlace(otherVector: Vector4): Vector4;
  59739. /**
  59740. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59741. * @param otherVector vector to multiple with
  59742. * @returns resulting new vector
  59743. */
  59744. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59745. /**
  59746. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59747. * @param otherVector vector to multiple with
  59748. * @param result vector to store the result
  59749. * @returns the current Vector4.
  59750. */
  59751. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59752. /**
  59753. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59754. * @param x x value multiply with
  59755. * @param y y value multiply with
  59756. * @param z z value multiply with
  59757. * @param w w value multiply with
  59758. * @returns resulting new vector
  59759. */
  59760. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59761. /**
  59762. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59763. * @param otherVector vector to devide with
  59764. * @returns resulting new vector
  59765. */
  59766. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59767. /**
  59768. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59769. * @param otherVector vector to devide with
  59770. * @param result vector to store the result
  59771. * @returns the current Vector4.
  59772. */
  59773. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59774. /**
  59775. * Divides the current Vector3 coordinates by the given ones.
  59776. * @param otherVector vector to devide with
  59777. * @returns the updated Vector3.
  59778. */
  59779. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59780. /**
  59781. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59782. * @param other defines the second operand
  59783. * @returns the current updated Vector4
  59784. */
  59785. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59786. /**
  59787. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59788. * @param other defines the second operand
  59789. * @returns the current updated Vector4
  59790. */
  59791. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59792. /**
  59793. * Gets a new Vector4 from current Vector4 floored values
  59794. * @returns a new Vector4
  59795. */
  59796. floor(): Vector4;
  59797. /**
  59798. * Gets a new Vector4 from current Vector3 floored values
  59799. * @returns a new Vector4
  59800. */
  59801. fract(): Vector4;
  59802. /**
  59803. * Returns the Vector4 length (float).
  59804. * @returns the length
  59805. */
  59806. length(): number;
  59807. /**
  59808. * Returns the Vector4 squared length (float).
  59809. * @returns the length squared
  59810. */
  59811. lengthSquared(): number;
  59812. /**
  59813. * Normalizes in place the Vector4.
  59814. * @returns the updated Vector4.
  59815. */
  59816. normalize(): Vector4;
  59817. /**
  59818. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59819. * @returns this converted to a new vector3
  59820. */
  59821. toVector3(): Vector3;
  59822. /**
  59823. * Returns a new Vector4 copied from the current one.
  59824. * @returns the new cloned vector
  59825. */
  59826. clone(): Vector4;
  59827. /**
  59828. * Updates the current Vector4 with the given one coordinates.
  59829. * @param source the source vector to copy from
  59830. * @returns the updated Vector4.
  59831. */
  59832. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59833. /**
  59834. * Updates the current Vector4 coordinates with the given floats.
  59835. * @param x float to copy from
  59836. * @param y float to copy from
  59837. * @param z float to copy from
  59838. * @param w float to copy from
  59839. * @returns the updated Vector4.
  59840. */
  59841. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59842. /**
  59843. * Updates the current Vector4 coordinates with the given floats.
  59844. * @param x float to set from
  59845. * @param y float to set from
  59846. * @param z float to set from
  59847. * @param w float to set from
  59848. * @returns the updated Vector4.
  59849. */
  59850. set(x: number, y: number, z: number, w: number): Vector4;
  59851. /**
  59852. * Copies the given float to the current Vector3 coordinates
  59853. * @param v defines the x, y, z and w coordinates of the operand
  59854. * @returns the current updated Vector3
  59855. */
  59856. setAll(v: number): Vector4;
  59857. /**
  59858. * Returns a new Vector4 set from the starting index of the given array.
  59859. * @param array the array to pull values from
  59860. * @param offset the offset into the array to start at
  59861. * @returns the new vector
  59862. */
  59863. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59864. /**
  59865. * Updates the given vector "result" from the starting index of the given array.
  59866. * @param array the array to pull values from
  59867. * @param offset the offset into the array to start at
  59868. * @param result the vector to store the result in
  59869. */
  59870. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59871. /**
  59872. * Updates the given vector "result" from the starting index of the given Float32Array.
  59873. * @param array the array to pull values from
  59874. * @param offset the offset into the array to start at
  59875. * @param result the vector to store the result in
  59876. */
  59877. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59878. /**
  59879. * Updates the given vector "result" coordinates from the given floats.
  59880. * @param x float to set from
  59881. * @param y float to set from
  59882. * @param z float to set from
  59883. * @param w float to set from
  59884. * @param result the vector to the floats in
  59885. */
  59886. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59887. /**
  59888. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59889. * @returns the new vector
  59890. */
  59891. static Zero(): Vector4;
  59892. /**
  59893. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59894. * @returns the new vector
  59895. */
  59896. static One(): Vector4;
  59897. /**
  59898. * Returns a new normalized Vector4 from the given one.
  59899. * @param vector the vector to normalize
  59900. * @returns the vector
  59901. */
  59902. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59903. /**
  59904. * Updates the given vector "result" from the normalization of the given one.
  59905. * @param vector the vector to normalize
  59906. * @param result the vector to store the result in
  59907. */
  59908. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59909. /**
  59910. * Returns a vector with the minimum values from the left and right vectors
  59911. * @param left left vector to minimize
  59912. * @param right right vector to minimize
  59913. * @returns a new vector with the minimum of the left and right vector values
  59914. */
  59915. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59916. /**
  59917. * Returns a vector with the maximum values from the left and right vectors
  59918. * @param left left vector to maximize
  59919. * @param right right vector to maximize
  59920. * @returns a new vector with the maximum of the left and right vector values
  59921. */
  59922. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59923. /**
  59924. * Returns the distance (float) between the vectors "value1" and "value2".
  59925. * @param value1 value to calulate the distance between
  59926. * @param value2 value to calulate the distance between
  59927. * @return the distance between the two vectors
  59928. */
  59929. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59930. /**
  59931. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59932. * @param value1 value to calulate the distance between
  59933. * @param value2 value to calulate the distance between
  59934. * @return the distance between the two vectors squared
  59935. */
  59936. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59937. /**
  59938. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59939. * @param value1 value to calulate the center between
  59940. * @param value2 value to calulate the center between
  59941. * @return the center between the two vectors
  59942. */
  59943. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59944. /**
  59945. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59946. * This methods computes transformed normalized direction vectors only.
  59947. * @param vector the vector to transform
  59948. * @param transformation the transformation matrix to apply
  59949. * @returns the new vector
  59950. */
  59951. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59952. /**
  59953. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59954. * This methods computes transformed normalized direction vectors only.
  59955. * @param vector the vector to transform
  59956. * @param transformation the transformation matrix to apply
  59957. * @param result the vector to store the result in
  59958. */
  59959. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59960. /**
  59961. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59962. * This methods computes transformed normalized direction vectors only.
  59963. * @param x value to transform
  59964. * @param y value to transform
  59965. * @param z value to transform
  59966. * @param w value to transform
  59967. * @param transformation the transformation matrix to apply
  59968. * @param result the vector to store the results in
  59969. */
  59970. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59971. /**
  59972. * Creates a new Vector4 from a Vector3
  59973. * @param source defines the source data
  59974. * @param w defines the 4th component (default is 0)
  59975. * @returns a new Vector4
  59976. */
  59977. static FromVector3(source: Vector3, w?: number): Vector4;
  59978. }
  59979. /**
  59980. * Interface for the size containing width and height
  59981. */
  59982. export interface ISize {
  59983. /**
  59984. * Width
  59985. */
  59986. width: number;
  59987. /**
  59988. * Heighht
  59989. */
  59990. height: number;
  59991. }
  59992. /**
  59993. * Size containing widht and height
  59994. */
  59995. export class Size implements ISize {
  59996. /**
  59997. * Width
  59998. */
  59999. width: number;
  60000. /**
  60001. * Height
  60002. */
  60003. height: number;
  60004. /**
  60005. * Creates a Size object from the given width and height (floats).
  60006. * @param width width of the new size
  60007. * @param height height of the new size
  60008. */
  60009. constructor(width: number, height: number);
  60010. /**
  60011. * Returns a string with the Size width and height
  60012. * @returns a string with the Size width and height
  60013. */
  60014. toString(): string;
  60015. /**
  60016. * "Size"
  60017. * @returns the string "Size"
  60018. */
  60019. getClassName(): string;
  60020. /**
  60021. * Returns the Size hash code.
  60022. * @returns a hash code for a unique width and height
  60023. */
  60024. getHashCode(): number;
  60025. /**
  60026. * Updates the current size from the given one.
  60027. * @param src the given size
  60028. */
  60029. copyFrom(src: Size): void;
  60030. /**
  60031. * Updates in place the current Size from the given floats.
  60032. * @param width width of the new size
  60033. * @param height height of the new size
  60034. * @returns the updated Size.
  60035. */
  60036. copyFromFloats(width: number, height: number): Size;
  60037. /**
  60038. * Updates in place the current Size from the given floats.
  60039. * @param width width to set
  60040. * @param height height to set
  60041. * @returns the updated Size.
  60042. */
  60043. set(width: number, height: number): Size;
  60044. /**
  60045. * Multiplies the width and height by numbers
  60046. * @param w factor to multiple the width by
  60047. * @param h factor to multiple the height by
  60048. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60049. */
  60050. multiplyByFloats(w: number, h: number): Size;
  60051. /**
  60052. * Clones the size
  60053. * @returns a new Size copied from the given one.
  60054. */
  60055. clone(): Size;
  60056. /**
  60057. * True if the current Size and the given one width and height are strictly equal.
  60058. * @param other the other size to compare against
  60059. * @returns True if the current Size and the given one width and height are strictly equal.
  60060. */
  60061. equals(other: Size): boolean;
  60062. /**
  60063. * The surface of the Size : width * height (float).
  60064. */
  60065. readonly surface: number;
  60066. /**
  60067. * Create a new size of zero
  60068. * @returns a new Size set to (0.0, 0.0)
  60069. */
  60070. static Zero(): Size;
  60071. /**
  60072. * Sums the width and height of two sizes
  60073. * @param otherSize size to add to this size
  60074. * @returns a new Size set as the addition result of the current Size and the given one.
  60075. */
  60076. add(otherSize: Size): Size;
  60077. /**
  60078. * Subtracts the width and height of two
  60079. * @param otherSize size to subtract to this size
  60080. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60081. */
  60082. subtract(otherSize: Size): Size;
  60083. /**
  60084. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60085. * @param start starting size to lerp between
  60086. * @param end end size to lerp between
  60087. * @param amount amount to lerp between the start and end values
  60088. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60089. */
  60090. static Lerp(start: Size, end: Size, amount: number): Size;
  60091. }
  60092. /**
  60093. * Class used to store quaternion data
  60094. * @see https://en.wikipedia.org/wiki/Quaternion
  60095. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60096. */
  60097. export class Quaternion {
  60098. /** defines the first component (0 by default) */
  60099. x: number;
  60100. /** defines the second component (0 by default) */
  60101. y: number;
  60102. /** defines the third component (0 by default) */
  60103. z: number;
  60104. /** defines the fourth component (1.0 by default) */
  60105. w: number;
  60106. /**
  60107. * Creates a new Quaternion from the given floats
  60108. * @param x defines the first component (0 by default)
  60109. * @param y defines the second component (0 by default)
  60110. * @param z defines the third component (0 by default)
  60111. * @param w defines the fourth component (1.0 by default)
  60112. */
  60113. constructor(
  60114. /** defines the first component (0 by default) */
  60115. x?: number,
  60116. /** defines the second component (0 by default) */
  60117. y?: number,
  60118. /** defines the third component (0 by default) */
  60119. z?: number,
  60120. /** defines the fourth component (1.0 by default) */
  60121. w?: number);
  60122. /**
  60123. * Gets a string representation for the current quaternion
  60124. * @returns a string with the Quaternion coordinates
  60125. */
  60126. toString(): string;
  60127. /**
  60128. * Gets the class name of the quaternion
  60129. * @returns the string "Quaternion"
  60130. */
  60131. getClassName(): string;
  60132. /**
  60133. * Gets a hash code for this quaternion
  60134. * @returns the quaternion hash code
  60135. */
  60136. getHashCode(): number;
  60137. /**
  60138. * Copy the quaternion to an array
  60139. * @returns a new array populated with 4 elements from the quaternion coordinates
  60140. */
  60141. asArray(): number[];
  60142. /**
  60143. * Check if two quaternions are equals
  60144. * @param otherQuaternion defines the second operand
  60145. * @return true if the current quaternion and the given one coordinates are strictly equals
  60146. */
  60147. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60148. /**
  60149. * Clone the current quaternion
  60150. * @returns a new quaternion copied from the current one
  60151. */
  60152. clone(): Quaternion;
  60153. /**
  60154. * Copy a quaternion to the current one
  60155. * @param other defines the other quaternion
  60156. * @returns the updated current quaternion
  60157. */
  60158. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60159. /**
  60160. * Updates the current quaternion with the given float coordinates
  60161. * @param x defines the x coordinate
  60162. * @param y defines the y coordinate
  60163. * @param z defines the z coordinate
  60164. * @param w defines the w coordinate
  60165. * @returns the updated current quaternion
  60166. */
  60167. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60168. /**
  60169. * Updates the current quaternion from the given float coordinates
  60170. * @param x defines the x coordinate
  60171. * @param y defines the y coordinate
  60172. * @param z defines the z coordinate
  60173. * @param w defines the w coordinate
  60174. * @returns the updated current quaternion
  60175. */
  60176. set(x: number, y: number, z: number, w: number): Quaternion;
  60177. /**
  60178. * Adds two quaternions
  60179. * @param other defines the second operand
  60180. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60181. */
  60182. add(other: DeepImmutable<Quaternion>): Quaternion;
  60183. /**
  60184. * Add a quaternion to the current one
  60185. * @param other defines the quaternion to add
  60186. * @returns the current quaternion
  60187. */
  60188. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60189. /**
  60190. * Subtract two quaternions
  60191. * @param other defines the second operand
  60192. * @returns a new quaternion as the subtraction result of the given one from the current one
  60193. */
  60194. subtract(other: Quaternion): Quaternion;
  60195. /**
  60196. * Multiplies the current quaternion by a scale factor
  60197. * @param value defines the scale factor
  60198. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60199. */
  60200. scale(value: number): Quaternion;
  60201. /**
  60202. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60203. * @param scale defines the scale factor
  60204. * @param result defines the Quaternion object where to store the result
  60205. * @returns the unmodified current quaternion
  60206. */
  60207. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60208. /**
  60209. * Multiplies in place the current quaternion by a scale factor
  60210. * @param value defines the scale factor
  60211. * @returns the current modified quaternion
  60212. */
  60213. scaleInPlace(value: number): Quaternion;
  60214. /**
  60215. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60216. * @param scale defines the scale factor
  60217. * @param result defines the Quaternion object where to store the result
  60218. * @returns the unmodified current quaternion
  60219. */
  60220. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60221. /**
  60222. * Multiplies two quaternions
  60223. * @param q1 defines the second operand
  60224. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60225. */
  60226. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60227. /**
  60228. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60229. * @param q1 defines the second operand
  60230. * @param result defines the target quaternion
  60231. * @returns the current quaternion
  60232. */
  60233. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60234. /**
  60235. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60236. * @param q1 defines the second operand
  60237. * @returns the currentupdated quaternion
  60238. */
  60239. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60240. /**
  60241. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60242. * @param ref defines the target quaternion
  60243. * @returns the current quaternion
  60244. */
  60245. conjugateToRef(ref: Quaternion): Quaternion;
  60246. /**
  60247. * Conjugates in place (1-q) the current quaternion
  60248. * @returns the current updated quaternion
  60249. */
  60250. conjugateInPlace(): Quaternion;
  60251. /**
  60252. * Conjugates in place (1-q) the current quaternion
  60253. * @returns a new quaternion
  60254. */
  60255. conjugate(): Quaternion;
  60256. /**
  60257. * Gets length of current quaternion
  60258. * @returns the quaternion length (float)
  60259. */
  60260. length(): number;
  60261. /**
  60262. * Normalize in place the current quaternion
  60263. * @returns the current updated quaternion
  60264. */
  60265. normalize(): Quaternion;
  60266. /**
  60267. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60268. * @param order is a reserved parameter and is ignore for now
  60269. * @returns a new Vector3 containing the Euler angles
  60270. */
  60271. toEulerAngles(order?: string): Vector3;
  60272. /**
  60273. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60274. * @param result defines the vector which will be filled with the Euler angles
  60275. * @param order is a reserved parameter and is ignore for now
  60276. * @returns the current unchanged quaternion
  60277. */
  60278. toEulerAnglesToRef(result: Vector3): Quaternion;
  60279. /**
  60280. * Updates the given rotation matrix with the current quaternion values
  60281. * @param result defines the target matrix
  60282. * @returns the current unchanged quaternion
  60283. */
  60284. toRotationMatrix(result: Matrix): Quaternion;
  60285. /**
  60286. * Updates the current quaternion from the given rotation matrix values
  60287. * @param matrix defines the source matrix
  60288. * @returns the current updated quaternion
  60289. */
  60290. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60291. /**
  60292. * Creates a new quaternion from a rotation matrix
  60293. * @param matrix defines the source matrix
  60294. * @returns a new quaternion created from the given rotation matrix values
  60295. */
  60296. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60297. /**
  60298. * Updates the given quaternion with the given rotation matrix values
  60299. * @param matrix defines the source matrix
  60300. * @param result defines the target quaternion
  60301. */
  60302. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60303. /**
  60304. * Returns the dot product (float) between the quaternions "left" and "right"
  60305. * @param left defines the left operand
  60306. * @param right defines the right operand
  60307. * @returns the dot product
  60308. */
  60309. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60310. /**
  60311. * Checks if the two quaternions are close to each other
  60312. * @param quat0 defines the first quaternion to check
  60313. * @param quat1 defines the second quaternion to check
  60314. * @returns true if the two quaternions are close to each other
  60315. */
  60316. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60317. /**
  60318. * Creates an empty quaternion
  60319. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60320. */
  60321. static Zero(): Quaternion;
  60322. /**
  60323. * Inverse a given quaternion
  60324. * @param q defines the source quaternion
  60325. * @returns a new quaternion as the inverted current quaternion
  60326. */
  60327. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60328. /**
  60329. * Inverse a given quaternion
  60330. * @param q defines the source quaternion
  60331. * @param result the quaternion the result will be stored in
  60332. * @returns the result quaternion
  60333. */
  60334. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60335. /**
  60336. * Creates an identity quaternion
  60337. * @returns the identity quaternion
  60338. */
  60339. static Identity(): Quaternion;
  60340. /**
  60341. * Gets a boolean indicating if the given quaternion is identity
  60342. * @param quaternion defines the quaternion to check
  60343. * @returns true if the quaternion is identity
  60344. */
  60345. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60346. /**
  60347. * Creates a quaternion from a rotation around an axis
  60348. * @param axis defines the axis to use
  60349. * @param angle defines the angle to use
  60350. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60351. */
  60352. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60353. /**
  60354. * Creates a rotation around an axis and stores it into the given quaternion
  60355. * @param axis defines the axis to use
  60356. * @param angle defines the angle to use
  60357. * @param result defines the target quaternion
  60358. * @returns the target quaternion
  60359. */
  60360. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60361. /**
  60362. * Creates a new quaternion from data stored into an array
  60363. * @param array defines the data source
  60364. * @param offset defines the offset in the source array where the data starts
  60365. * @returns a new quaternion
  60366. */
  60367. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60368. /**
  60369. * Create a quaternion from Euler rotation angles
  60370. * @param x Pitch
  60371. * @param y Yaw
  60372. * @param z Roll
  60373. * @returns the new Quaternion
  60374. */
  60375. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60376. /**
  60377. * Updates a quaternion from Euler rotation angles
  60378. * @param x Pitch
  60379. * @param y Yaw
  60380. * @param z Roll
  60381. * @param result the quaternion to store the result
  60382. * @returns the updated quaternion
  60383. */
  60384. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60385. /**
  60386. * Create a quaternion from Euler rotation vector
  60387. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60388. * @returns the new Quaternion
  60389. */
  60390. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60391. /**
  60392. * Updates a quaternion from Euler rotation vector
  60393. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60394. * @param result the quaternion to store the result
  60395. * @returns the updated quaternion
  60396. */
  60397. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60398. /**
  60399. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60400. * @param yaw defines the rotation around Y axis
  60401. * @param pitch defines the rotation around X axis
  60402. * @param roll defines the rotation around Z axis
  60403. * @returns the new quaternion
  60404. */
  60405. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60406. /**
  60407. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60408. * @param yaw defines the rotation around Y axis
  60409. * @param pitch defines the rotation around X axis
  60410. * @param roll defines the rotation around Z axis
  60411. * @param result defines the target quaternion
  60412. */
  60413. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60414. /**
  60415. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60416. * @param alpha defines the rotation around first axis
  60417. * @param beta defines the rotation around second axis
  60418. * @param gamma defines the rotation around third axis
  60419. * @returns the new quaternion
  60420. */
  60421. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60422. /**
  60423. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60424. * @param alpha defines the rotation around first axis
  60425. * @param beta defines the rotation around second axis
  60426. * @param gamma defines the rotation around third axis
  60427. * @param result defines the target quaternion
  60428. */
  60429. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60430. /**
  60431. * 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)
  60432. * @param axis1 defines the first axis
  60433. * @param axis2 defines the second axis
  60434. * @param axis3 defines the third axis
  60435. * @returns the new quaternion
  60436. */
  60437. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60438. /**
  60439. * 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
  60440. * @param axis1 defines the first axis
  60441. * @param axis2 defines the second axis
  60442. * @param axis3 defines the third axis
  60443. * @param ref defines the target quaternion
  60444. */
  60445. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60446. /**
  60447. * Interpolates between two quaternions
  60448. * @param left defines first quaternion
  60449. * @param right defines second quaternion
  60450. * @param amount defines the gradient to use
  60451. * @returns the new interpolated quaternion
  60452. */
  60453. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60454. /**
  60455. * Interpolates between two quaternions and stores it into a target quaternion
  60456. * @param left defines first quaternion
  60457. * @param right defines second quaternion
  60458. * @param amount defines the gradient to use
  60459. * @param result defines the target quaternion
  60460. */
  60461. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60462. /**
  60463. * Interpolate between two quaternions using Hermite interpolation
  60464. * @param value1 defines first quaternion
  60465. * @param tangent1 defines the incoming tangent
  60466. * @param value2 defines second quaternion
  60467. * @param tangent2 defines the outgoing tangent
  60468. * @param amount defines the target quaternion
  60469. * @returns the new interpolated quaternion
  60470. */
  60471. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60472. }
  60473. /**
  60474. * Class used to store matrix data (4x4)
  60475. */
  60476. export class Matrix {
  60477. private static _updateFlagSeed;
  60478. private static _identityReadOnly;
  60479. private _isIdentity;
  60480. private _isIdentityDirty;
  60481. private _isIdentity3x2;
  60482. private _isIdentity3x2Dirty;
  60483. /**
  60484. * Gets the update flag of the matrix which is an unique number for the matrix.
  60485. * It will be incremented every time the matrix data change.
  60486. * You can use it to speed the comparison between two versions of the same matrix.
  60487. */
  60488. updateFlag: number;
  60489. private readonly _m;
  60490. /**
  60491. * Gets the internal data of the matrix
  60492. */
  60493. readonly m: DeepImmutable<Float32Array>;
  60494. /** @hidden */
  60495. _markAsUpdated(): void;
  60496. /** @hidden */
  60497. private _updateIdentityStatus;
  60498. /**
  60499. * Creates an empty matrix (filled with zeros)
  60500. */
  60501. constructor();
  60502. /**
  60503. * Check if the current matrix is identity
  60504. * @returns true is the matrix is the identity matrix
  60505. */
  60506. isIdentity(): boolean;
  60507. /**
  60508. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60509. * @returns true is the matrix is the identity matrix
  60510. */
  60511. isIdentityAs3x2(): boolean;
  60512. /**
  60513. * Gets the determinant of the matrix
  60514. * @returns the matrix determinant
  60515. */
  60516. determinant(): number;
  60517. /**
  60518. * Returns the matrix as a Float32Array
  60519. * @returns the matrix underlying array
  60520. */
  60521. toArray(): DeepImmutable<Float32Array>;
  60522. /**
  60523. * Returns the matrix as a Float32Array
  60524. * @returns the matrix underlying array.
  60525. */
  60526. asArray(): DeepImmutable<Float32Array>;
  60527. /**
  60528. * Inverts the current matrix in place
  60529. * @returns the current inverted matrix
  60530. */
  60531. invert(): Matrix;
  60532. /**
  60533. * Sets all the matrix elements to zero
  60534. * @returns the current matrix
  60535. */
  60536. reset(): Matrix;
  60537. /**
  60538. * Adds the current matrix with a second one
  60539. * @param other defines the matrix to add
  60540. * @returns a new matrix as the addition of the current matrix and the given one
  60541. */
  60542. add(other: DeepImmutable<Matrix>): Matrix;
  60543. /**
  60544. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60545. * @param other defines the matrix to add
  60546. * @param result defines the target matrix
  60547. * @returns the current matrix
  60548. */
  60549. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60550. /**
  60551. * Adds in place the given matrix to the current matrix
  60552. * @param other defines the second operand
  60553. * @returns the current updated matrix
  60554. */
  60555. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60556. /**
  60557. * Sets the given matrix to the current inverted Matrix
  60558. * @param other defines the target matrix
  60559. * @returns the unmodified current matrix
  60560. */
  60561. invertToRef(other: Matrix): Matrix;
  60562. /**
  60563. * add a value at the specified position in the current Matrix
  60564. * @param index the index of the value within the matrix. between 0 and 15.
  60565. * @param value the value to be added
  60566. * @returns the current updated matrix
  60567. */
  60568. addAtIndex(index: number, value: number): Matrix;
  60569. /**
  60570. * mutiply the specified position in the current Matrix by a value
  60571. * @param index the index of the value within the matrix. between 0 and 15.
  60572. * @param value the value to be added
  60573. * @returns the current updated matrix
  60574. */
  60575. multiplyAtIndex(index: number, value: number): Matrix;
  60576. /**
  60577. * Inserts the translation vector (using 3 floats) in the current matrix
  60578. * @param x defines the 1st component of the translation
  60579. * @param y defines the 2nd component of the translation
  60580. * @param z defines the 3rd component of the translation
  60581. * @returns the current updated matrix
  60582. */
  60583. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60584. /**
  60585. * Inserts the translation vector in the current matrix
  60586. * @param vector3 defines the translation to insert
  60587. * @returns the current updated matrix
  60588. */
  60589. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60590. /**
  60591. * Gets the translation value of the current matrix
  60592. * @returns a new Vector3 as the extracted translation from the matrix
  60593. */
  60594. getTranslation(): Vector3;
  60595. /**
  60596. * Fill a Vector3 with the extracted translation from the matrix
  60597. * @param result defines the Vector3 where to store the translation
  60598. * @returns the current matrix
  60599. */
  60600. getTranslationToRef(result: Vector3): Matrix;
  60601. /**
  60602. * Remove rotation and scaling part from the matrix
  60603. * @returns the updated matrix
  60604. */
  60605. removeRotationAndScaling(): Matrix;
  60606. /**
  60607. * Multiply two matrices
  60608. * @param other defines the second operand
  60609. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60610. */
  60611. multiply(other: DeepImmutable<Matrix>): Matrix;
  60612. /**
  60613. * Copy the current matrix from the given one
  60614. * @param other defines the source matrix
  60615. * @returns the current updated matrix
  60616. */
  60617. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60618. /**
  60619. * Populates the given array from the starting index with the current matrix values
  60620. * @param array defines the target array
  60621. * @param offset defines the offset in the target array where to start storing values
  60622. * @returns the current matrix
  60623. */
  60624. copyToArray(array: Float32Array, offset?: number): Matrix;
  60625. /**
  60626. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60627. * @param other defines the second operand
  60628. * @param result defines the matrix where to store the multiplication
  60629. * @returns the current matrix
  60630. */
  60631. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60632. /**
  60633. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60634. * @param other defines the second operand
  60635. * @param result defines the array where to store the multiplication
  60636. * @param offset defines the offset in the target array where to start storing values
  60637. * @returns the current matrix
  60638. */
  60639. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60640. /**
  60641. * Check equality between this matrix and a second one
  60642. * @param value defines the second matrix to compare
  60643. * @returns true is the current matrix and the given one values are strictly equal
  60644. */
  60645. equals(value: DeepImmutable<Matrix>): boolean;
  60646. /**
  60647. * Clone the current matrix
  60648. * @returns a new matrix from the current matrix
  60649. */
  60650. clone(): Matrix;
  60651. /**
  60652. * Returns the name of the current matrix class
  60653. * @returns the string "Matrix"
  60654. */
  60655. getClassName(): string;
  60656. /**
  60657. * Gets the hash code of the current matrix
  60658. * @returns the hash code
  60659. */
  60660. getHashCode(): number;
  60661. /**
  60662. * Decomposes the current Matrix into a translation, rotation and scaling components
  60663. * @param scale defines the scale vector3 given as a reference to update
  60664. * @param rotation defines the rotation quaternion given as a reference to update
  60665. * @param translation defines the translation vector3 given as a reference to update
  60666. * @returns true if operation was successful
  60667. */
  60668. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60669. /**
  60670. * Gets specific row of the matrix
  60671. * @param index defines the number of the row to get
  60672. * @returns the index-th row of the current matrix as a new Vector4
  60673. */
  60674. getRow(index: number): Nullable<Vector4>;
  60675. /**
  60676. * Sets the index-th row of the current matrix to the vector4 values
  60677. * @param index defines the number of the row to set
  60678. * @param row defines the target vector4
  60679. * @returns the updated current matrix
  60680. */
  60681. setRow(index: number, row: Vector4): Matrix;
  60682. /**
  60683. * Compute the transpose of the matrix
  60684. * @returns the new transposed matrix
  60685. */
  60686. transpose(): Matrix;
  60687. /**
  60688. * Compute the transpose of the matrix and store it in a given matrix
  60689. * @param result defines the target matrix
  60690. * @returns the current matrix
  60691. */
  60692. transposeToRef(result: Matrix): Matrix;
  60693. /**
  60694. * Sets the index-th row of the current matrix with the given 4 x float values
  60695. * @param index defines the row index
  60696. * @param x defines the x component to set
  60697. * @param y defines the y component to set
  60698. * @param z defines the z component to set
  60699. * @param w defines the w component to set
  60700. * @returns the updated current matrix
  60701. */
  60702. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60703. /**
  60704. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60705. * @param scale defines the scale factor
  60706. * @returns a new matrix
  60707. */
  60708. scale(scale: number): Matrix;
  60709. /**
  60710. * Scale the current matrix values by a factor to a given result matrix
  60711. * @param scale defines the scale factor
  60712. * @param result defines the matrix to store the result
  60713. * @returns the current matrix
  60714. */
  60715. scaleToRef(scale: number, result: Matrix): Matrix;
  60716. /**
  60717. * Scale the current matrix values by a factor and add the result to a given matrix
  60718. * @param scale defines the scale factor
  60719. * @param result defines the Matrix to store the result
  60720. * @returns the current matrix
  60721. */
  60722. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60723. /**
  60724. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60725. * @param ref matrix to store the result
  60726. */
  60727. toNormalMatrix(ref: Matrix): void;
  60728. /**
  60729. * Gets only rotation part of the current matrix
  60730. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60731. */
  60732. getRotationMatrix(): Matrix;
  60733. /**
  60734. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60735. * @param result defines the target matrix to store data to
  60736. * @returns the current matrix
  60737. */
  60738. getRotationMatrixToRef(result: Matrix): Matrix;
  60739. /**
  60740. * Toggles model matrix from being right handed to left handed in place and vice versa
  60741. */
  60742. toggleModelMatrixHandInPlace(): void;
  60743. /**
  60744. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60745. */
  60746. toggleProjectionMatrixHandInPlace(): void;
  60747. /**
  60748. * Creates a matrix from an array
  60749. * @param array defines the source array
  60750. * @param offset defines an offset in the source array
  60751. * @returns a new Matrix set from the starting index of the given array
  60752. */
  60753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60754. /**
  60755. * Copy the content of an array into a given matrix
  60756. * @param array defines the source array
  60757. * @param offset defines an offset in the source array
  60758. * @param result defines the target matrix
  60759. */
  60760. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60761. /**
  60762. * Stores an array into a matrix after having multiplied each component by a given factor
  60763. * @param array defines the source array
  60764. * @param offset defines the offset in the source array
  60765. * @param scale defines the scaling factor
  60766. * @param result defines the target matrix
  60767. */
  60768. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60769. /**
  60770. * Gets an identity matrix that must not be updated
  60771. */
  60772. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60773. /**
  60774. * Stores a list of values (16) inside a given matrix
  60775. * @param initialM11 defines 1st value of 1st row
  60776. * @param initialM12 defines 2nd value of 1st row
  60777. * @param initialM13 defines 3rd value of 1st row
  60778. * @param initialM14 defines 4th value of 1st row
  60779. * @param initialM21 defines 1st value of 2nd row
  60780. * @param initialM22 defines 2nd value of 2nd row
  60781. * @param initialM23 defines 3rd value of 2nd row
  60782. * @param initialM24 defines 4th value of 2nd row
  60783. * @param initialM31 defines 1st value of 3rd row
  60784. * @param initialM32 defines 2nd value of 3rd row
  60785. * @param initialM33 defines 3rd value of 3rd row
  60786. * @param initialM34 defines 4th value of 3rd row
  60787. * @param initialM41 defines 1st value of 4th row
  60788. * @param initialM42 defines 2nd value of 4th row
  60789. * @param initialM43 defines 3rd value of 4th row
  60790. * @param initialM44 defines 4th value of 4th row
  60791. * @param result defines the target matrix
  60792. */
  60793. 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;
  60794. /**
  60795. * Creates new matrix from a list of values (16)
  60796. * @param initialM11 defines 1st value of 1st row
  60797. * @param initialM12 defines 2nd value of 1st row
  60798. * @param initialM13 defines 3rd value of 1st row
  60799. * @param initialM14 defines 4th value of 1st row
  60800. * @param initialM21 defines 1st value of 2nd row
  60801. * @param initialM22 defines 2nd value of 2nd row
  60802. * @param initialM23 defines 3rd value of 2nd row
  60803. * @param initialM24 defines 4th value of 2nd row
  60804. * @param initialM31 defines 1st value of 3rd row
  60805. * @param initialM32 defines 2nd value of 3rd row
  60806. * @param initialM33 defines 3rd value of 3rd row
  60807. * @param initialM34 defines 4th value of 3rd row
  60808. * @param initialM41 defines 1st value of 4th row
  60809. * @param initialM42 defines 2nd value of 4th row
  60810. * @param initialM43 defines 3rd value of 4th row
  60811. * @param initialM44 defines 4th value of 4th row
  60812. * @returns the new matrix
  60813. */
  60814. 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;
  60815. /**
  60816. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60817. * @param scale defines the scale vector3
  60818. * @param rotation defines the rotation quaternion
  60819. * @param translation defines the translation vector3
  60820. * @returns a new matrix
  60821. */
  60822. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60823. /**
  60824. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60825. * @param scale defines the scale vector3
  60826. * @param rotation defines the rotation quaternion
  60827. * @param translation defines the translation vector3
  60828. * @param result defines the target matrix
  60829. */
  60830. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60831. /**
  60832. * Creates a new identity matrix
  60833. * @returns a new identity matrix
  60834. */
  60835. static Identity(): Matrix;
  60836. /**
  60837. * Creates a new identity matrix and stores the result in a given matrix
  60838. * @param result defines the target matrix
  60839. */
  60840. static IdentityToRef(result: Matrix): void;
  60841. /**
  60842. * Creates a new zero matrix
  60843. * @returns a new zero matrix
  60844. */
  60845. static Zero(): Matrix;
  60846. /**
  60847. * Creates a new rotation matrix for "angle" radians around the X axis
  60848. * @param angle defines the angle (in radians) to use
  60849. * @return the new matrix
  60850. */
  60851. static RotationX(angle: number): Matrix;
  60852. /**
  60853. * Creates a new matrix as the invert of a given matrix
  60854. * @param source defines the source matrix
  60855. * @returns the new matrix
  60856. */
  60857. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60858. /**
  60859. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60860. * @param angle defines the angle (in radians) to use
  60861. * @param result defines the target matrix
  60862. */
  60863. static RotationXToRef(angle: number, result: Matrix): void;
  60864. /**
  60865. * Creates a new rotation matrix for "angle" radians around the Y axis
  60866. * @param angle defines the angle (in radians) to use
  60867. * @return the new matrix
  60868. */
  60869. static RotationY(angle: number): Matrix;
  60870. /**
  60871. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60872. * @param angle defines the angle (in radians) to use
  60873. * @param result defines the target matrix
  60874. */
  60875. static RotationYToRef(angle: number, result: Matrix): void;
  60876. /**
  60877. * Creates a new rotation matrix for "angle" radians around the Z axis
  60878. * @param angle defines the angle (in radians) to use
  60879. * @return the new matrix
  60880. */
  60881. static RotationZ(angle: number): Matrix;
  60882. /**
  60883. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60884. * @param angle defines the angle (in radians) to use
  60885. * @param result defines the target matrix
  60886. */
  60887. static RotationZToRef(angle: number, result: Matrix): void;
  60888. /**
  60889. * Creates a new rotation matrix for "angle" radians around the given axis
  60890. * @param axis defines the axis to use
  60891. * @param angle defines the angle (in radians) to use
  60892. * @return the new matrix
  60893. */
  60894. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60895. /**
  60896. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60897. * @param axis defines the axis to use
  60898. * @param angle defines the angle (in radians) to use
  60899. * @param result defines the target matrix
  60900. */
  60901. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60902. /**
  60903. * Creates a rotation matrix
  60904. * @param yaw defines the yaw angle in radians (Y axis)
  60905. * @param pitch defines the pitch angle in radians (X axis)
  60906. * @param roll defines the roll angle in radians (X axis)
  60907. * @returns the new rotation matrix
  60908. */
  60909. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60910. /**
  60911. * Creates a rotation matrix and stores it in a given matrix
  60912. * @param yaw defines the yaw angle in radians (Y axis)
  60913. * @param pitch defines the pitch angle in radians (X axis)
  60914. * @param roll defines the roll angle in radians (X axis)
  60915. * @param result defines the target matrix
  60916. */
  60917. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60918. /**
  60919. * Creates a scaling matrix
  60920. * @param x defines the scale factor on X axis
  60921. * @param y defines the scale factor on Y axis
  60922. * @param z defines the scale factor on Z axis
  60923. * @returns the new matrix
  60924. */
  60925. static Scaling(x: number, y: number, z: number): Matrix;
  60926. /**
  60927. * Creates a scaling matrix and stores it in a given matrix
  60928. * @param x defines the scale factor on X axis
  60929. * @param y defines the scale factor on Y axis
  60930. * @param z defines the scale factor on Z axis
  60931. * @param result defines the target matrix
  60932. */
  60933. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60934. /**
  60935. * Creates a translation matrix
  60936. * @param x defines the translation on X axis
  60937. * @param y defines the translation on Y axis
  60938. * @param z defines the translationon Z axis
  60939. * @returns the new matrix
  60940. */
  60941. static Translation(x: number, y: number, z: number): Matrix;
  60942. /**
  60943. * Creates a translation matrix and stores it in a given matrix
  60944. * @param x defines the translation on X axis
  60945. * @param y defines the translation on Y axis
  60946. * @param z defines the translationon Z axis
  60947. * @param result defines the target matrix
  60948. */
  60949. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60950. /**
  60951. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60952. * @param startValue defines the start value
  60953. * @param endValue defines the end value
  60954. * @param gradient defines the gradient factor
  60955. * @returns the new matrix
  60956. */
  60957. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60958. /**
  60959. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60960. * @param startValue defines the start value
  60961. * @param endValue defines the end value
  60962. * @param gradient defines the gradient factor
  60963. * @param result defines the Matrix object where to store data
  60964. */
  60965. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60966. /**
  60967. * Builds a new matrix whose values are computed by:
  60968. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60969. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60970. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60971. * @param startValue defines the first matrix
  60972. * @param endValue defines the second matrix
  60973. * @param gradient defines the gradient between the two matrices
  60974. * @returns the new matrix
  60975. */
  60976. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60977. /**
  60978. * Update a matrix to values which are computed by:
  60979. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60980. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60981. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60982. * @param startValue defines the first matrix
  60983. * @param endValue defines the second matrix
  60984. * @param gradient defines the gradient between the two matrices
  60985. * @param result defines the target matrix
  60986. */
  60987. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60988. /**
  60989. * 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"
  60990. * This function works in left handed mode
  60991. * @param eye defines the final position of the entity
  60992. * @param target defines where the entity should look at
  60993. * @param up defines the up vector for the entity
  60994. * @returns the new matrix
  60995. */
  60996. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60997. /**
  60998. * 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".
  60999. * This function works in left handed mode
  61000. * @param eye defines the final position of the entity
  61001. * @param target defines where the entity should look at
  61002. * @param up defines the up vector for the entity
  61003. * @param result defines the target matrix
  61004. */
  61005. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61006. /**
  61007. * 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"
  61008. * This function works in right handed mode
  61009. * @param eye defines the final position of the entity
  61010. * @param target defines where the entity should look at
  61011. * @param up defines the up vector for the entity
  61012. * @returns the new matrix
  61013. */
  61014. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61015. /**
  61016. * 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".
  61017. * This function works in right handed mode
  61018. * @param eye defines the final position of the entity
  61019. * @param target defines where the entity should look at
  61020. * @param up defines the up vector for the entity
  61021. * @param result defines the target matrix
  61022. */
  61023. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61024. /**
  61025. * Create a left-handed orthographic projection matrix
  61026. * @param width defines the viewport width
  61027. * @param height defines the viewport height
  61028. * @param znear defines the near clip plane
  61029. * @param zfar defines the far clip plane
  61030. * @returns a new matrix as a left-handed orthographic projection matrix
  61031. */
  61032. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61033. /**
  61034. * Store a left-handed orthographic projection to a given matrix
  61035. * @param width defines the viewport width
  61036. * @param height defines the viewport height
  61037. * @param znear defines the near clip plane
  61038. * @param zfar defines the far clip plane
  61039. * @param result defines the target matrix
  61040. */
  61041. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61042. /**
  61043. * Create a left-handed orthographic projection matrix
  61044. * @param left defines the viewport left coordinate
  61045. * @param right defines the viewport right coordinate
  61046. * @param bottom defines the viewport bottom coordinate
  61047. * @param top defines the viewport top coordinate
  61048. * @param znear defines the near clip plane
  61049. * @param zfar defines the far clip plane
  61050. * @returns a new matrix as a left-handed orthographic projection matrix
  61051. */
  61052. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61053. /**
  61054. * Stores a left-handed orthographic projection into a given matrix
  61055. * @param left defines the viewport left coordinate
  61056. * @param right defines the viewport right coordinate
  61057. * @param bottom defines the viewport bottom coordinate
  61058. * @param top defines the viewport top coordinate
  61059. * @param znear defines the near clip plane
  61060. * @param zfar defines the far clip plane
  61061. * @param result defines the target matrix
  61062. */
  61063. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61064. /**
  61065. * Creates a right-handed orthographic projection matrix
  61066. * @param left defines the viewport left coordinate
  61067. * @param right defines the viewport right coordinate
  61068. * @param bottom defines the viewport bottom coordinate
  61069. * @param top defines the viewport top coordinate
  61070. * @param znear defines the near clip plane
  61071. * @param zfar defines the far clip plane
  61072. * @returns a new matrix as a right-handed orthographic projection matrix
  61073. */
  61074. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61075. /**
  61076. * Stores a right-handed orthographic projection into a given matrix
  61077. * @param left defines the viewport left coordinate
  61078. * @param right defines the viewport right coordinate
  61079. * @param bottom defines the viewport bottom coordinate
  61080. * @param top defines the viewport top coordinate
  61081. * @param znear defines the near clip plane
  61082. * @param zfar defines the far clip plane
  61083. * @param result defines the target matrix
  61084. */
  61085. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61086. /**
  61087. * Creates a left-handed perspective projection matrix
  61088. * @param width defines the viewport width
  61089. * @param height defines the viewport height
  61090. * @param znear defines the near clip plane
  61091. * @param zfar defines the far clip plane
  61092. * @returns a new matrix as a left-handed perspective projection matrix
  61093. */
  61094. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61095. /**
  61096. * Creates a left-handed perspective projection matrix
  61097. * @param fov defines the horizontal field of view
  61098. * @param aspect defines the aspect ratio
  61099. * @param znear defines the near clip plane
  61100. * @param zfar defines the far clip plane
  61101. * @returns a new matrix as a left-handed perspective projection matrix
  61102. */
  61103. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61104. /**
  61105. * Stores a left-handed perspective projection into a given matrix
  61106. * @param fov defines the horizontal field of view
  61107. * @param aspect defines the aspect ratio
  61108. * @param znear defines the near clip plane
  61109. * @param zfar defines the far clip plane
  61110. * @param result defines the target matrix
  61111. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61112. */
  61113. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61114. /**
  61115. * Creates a right-handed perspective projection matrix
  61116. * @param fov defines the horizontal field of view
  61117. * @param aspect defines the aspect ratio
  61118. * @param znear defines the near clip plane
  61119. * @param zfar defines the far clip plane
  61120. * @returns a new matrix as a right-handed perspective projection matrix
  61121. */
  61122. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61123. /**
  61124. * Stores a right-handed perspective projection into a given matrix
  61125. * @param fov defines the horizontal field of view
  61126. * @param aspect defines the aspect ratio
  61127. * @param znear defines the near clip plane
  61128. * @param zfar defines the far clip plane
  61129. * @param result defines the target matrix
  61130. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61131. */
  61132. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61133. /**
  61134. * Stores a perspective projection for WebVR info a given matrix
  61135. * @param fov defines the field of view
  61136. * @param znear defines the near clip plane
  61137. * @param zfar defines the far clip plane
  61138. * @param result defines the target matrix
  61139. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61140. */
  61141. static PerspectiveFovWebVRToRef(fov: {
  61142. upDegrees: number;
  61143. downDegrees: number;
  61144. leftDegrees: number;
  61145. rightDegrees: number;
  61146. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61147. /**
  61148. * Computes a complete transformation matrix
  61149. * @param viewport defines the viewport to use
  61150. * @param world defines the world matrix
  61151. * @param view defines the view matrix
  61152. * @param projection defines the projection matrix
  61153. * @param zmin defines the near clip plane
  61154. * @param zmax defines the far clip plane
  61155. * @returns the transformation matrix
  61156. */
  61157. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61158. /**
  61159. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61160. * @param matrix defines the matrix to use
  61161. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61162. */
  61163. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61164. /**
  61165. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61166. * @param matrix defines the matrix to use
  61167. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61168. */
  61169. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61170. /**
  61171. * Compute the transpose of a given matrix
  61172. * @param matrix defines the matrix to transpose
  61173. * @returns the new matrix
  61174. */
  61175. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61176. /**
  61177. * Compute the transpose of a matrix and store it in a target matrix
  61178. * @param matrix defines the matrix to transpose
  61179. * @param result defines the target matrix
  61180. */
  61181. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61182. /**
  61183. * Computes a reflection matrix from a plane
  61184. * @param plane defines the reflection plane
  61185. * @returns a new matrix
  61186. */
  61187. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61188. /**
  61189. * Computes a reflection matrix from a plane
  61190. * @param plane defines the reflection plane
  61191. * @param result defines the target matrix
  61192. */
  61193. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61194. /**
  61195. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61196. * @param xaxis defines the value of the 1st axis
  61197. * @param yaxis defines the value of the 2nd axis
  61198. * @param zaxis defines the value of the 3rd axis
  61199. * @param result defines the target matrix
  61200. */
  61201. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61202. /**
  61203. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61204. * @param quat defines the quaternion to use
  61205. * @param result defines the target matrix
  61206. */
  61207. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61208. }
  61209. /**
  61210. * Represens a plane by the equation ax + by + cz + d = 0
  61211. */
  61212. export class Plane {
  61213. /**
  61214. * Normal of the plane (a,b,c)
  61215. */
  61216. normal: Vector3;
  61217. /**
  61218. * d component of the plane
  61219. */
  61220. d: number;
  61221. /**
  61222. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61223. * @param a a component of the plane
  61224. * @param b b component of the plane
  61225. * @param c c component of the plane
  61226. * @param d d component of the plane
  61227. */
  61228. constructor(a: number, b: number, c: number, d: number);
  61229. /**
  61230. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61231. */
  61232. asArray(): number[];
  61233. /**
  61234. * @returns a new plane copied from the current Plane.
  61235. */
  61236. clone(): Plane;
  61237. /**
  61238. * @returns the string "Plane".
  61239. */
  61240. getClassName(): string;
  61241. /**
  61242. * @returns the Plane hash code.
  61243. */
  61244. getHashCode(): number;
  61245. /**
  61246. * Normalize the current Plane in place.
  61247. * @returns the updated Plane.
  61248. */
  61249. normalize(): Plane;
  61250. /**
  61251. * Applies a transformation the plane and returns the result
  61252. * @param transformation the transformation matrix to be applied to the plane
  61253. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61254. */
  61255. transform(transformation: DeepImmutable<Matrix>): Plane;
  61256. /**
  61257. * Calcualtte the dot product between the point and the plane normal
  61258. * @param point point to calculate the dot product with
  61259. * @returns the dot product (float) of the point coordinates and the plane normal.
  61260. */
  61261. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61262. /**
  61263. * Updates the current Plane from the plane defined by the three given points.
  61264. * @param point1 one of the points used to contruct the plane
  61265. * @param point2 one of the points used to contruct the plane
  61266. * @param point3 one of the points used to contruct the plane
  61267. * @returns the updated Plane.
  61268. */
  61269. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61270. /**
  61271. * Checks if the plane is facing a given direction
  61272. * @param direction the direction to check if the plane is facing
  61273. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61274. * @returns True is the vector "direction" is the same side than the plane normal.
  61275. */
  61276. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61277. /**
  61278. * Calculates the distance to a point
  61279. * @param point point to calculate distance to
  61280. * @returns the signed distance (float) from the given point to the Plane.
  61281. */
  61282. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61283. /**
  61284. * Creates a plane from an array
  61285. * @param array the array to create a plane from
  61286. * @returns a new Plane from the given array.
  61287. */
  61288. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61289. /**
  61290. * Creates a plane from three points
  61291. * @param point1 point used to create the plane
  61292. * @param point2 point used to create the plane
  61293. * @param point3 point used to create the plane
  61294. * @returns a new Plane defined by the three given points.
  61295. */
  61296. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61297. /**
  61298. * Creates a plane from an origin point and a normal
  61299. * @param origin origin of the plane to be constructed
  61300. * @param normal normal of the plane to be constructed
  61301. * @returns a new Plane the normal vector to this plane at the given origin point.
  61302. * Note : the vector "normal" is updated because normalized.
  61303. */
  61304. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61305. /**
  61306. * Calculates the distance from a plane and a point
  61307. * @param origin origin of the plane to be constructed
  61308. * @param normal normal of the plane to be constructed
  61309. * @param point point to calculate distance to
  61310. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61311. */
  61312. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61313. }
  61314. /**
  61315. * Class used to represent a viewport on screen
  61316. */
  61317. export class Viewport {
  61318. /** viewport left coordinate */
  61319. x: number;
  61320. /** viewport top coordinate */
  61321. y: number;
  61322. /**viewport width */
  61323. width: number;
  61324. /** viewport height */
  61325. height: number;
  61326. /**
  61327. * Creates a Viewport object located at (x, y) and sized (width, height)
  61328. * @param x defines viewport left coordinate
  61329. * @param y defines viewport top coordinate
  61330. * @param width defines the viewport width
  61331. * @param height defines the viewport height
  61332. */
  61333. constructor(
  61334. /** viewport left coordinate */
  61335. x: number,
  61336. /** viewport top coordinate */
  61337. y: number,
  61338. /**viewport width */
  61339. width: number,
  61340. /** viewport height */
  61341. height: number);
  61342. /**
  61343. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61344. * @param renderWidth defines the rendering width
  61345. * @param renderHeight defines the rendering height
  61346. * @returns a new Viewport
  61347. */
  61348. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61349. /**
  61350. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61351. * @param renderWidth defines the rendering width
  61352. * @param renderHeight defines the rendering height
  61353. * @param ref defines the target viewport
  61354. * @returns the current viewport
  61355. */
  61356. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61357. /**
  61358. * Returns a new Viewport copied from the current one
  61359. * @returns a new Viewport
  61360. */
  61361. clone(): Viewport;
  61362. }
  61363. /**
  61364. * Reprasents a camera frustum
  61365. */
  61366. export class Frustum {
  61367. /**
  61368. * Gets the planes representing the frustum
  61369. * @param transform matrix to be applied to the returned planes
  61370. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61371. */
  61372. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61373. /**
  61374. * Gets the near frustum plane transformed by the transform matrix
  61375. * @param transform transformation matrix to be applied to the resulting frustum plane
  61376. * @param frustumPlane the resuling frustum plane
  61377. */
  61378. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61379. /**
  61380. * Gets the far frustum plane transformed by the transform matrix
  61381. * @param transform transformation matrix to be applied to the resulting frustum plane
  61382. * @param frustumPlane the resuling frustum plane
  61383. */
  61384. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61385. /**
  61386. * Gets the left frustum plane transformed by the transform matrix
  61387. * @param transform transformation matrix to be applied to the resulting frustum plane
  61388. * @param frustumPlane the resuling frustum plane
  61389. */
  61390. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61391. /**
  61392. * Gets the right frustum plane transformed by the transform matrix
  61393. * @param transform transformation matrix to be applied to the resulting frustum plane
  61394. * @param frustumPlane the resuling frustum plane
  61395. */
  61396. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61397. /**
  61398. * Gets the top frustum plane transformed by the transform matrix
  61399. * @param transform transformation matrix to be applied to the resulting frustum plane
  61400. * @param frustumPlane the resuling frustum plane
  61401. */
  61402. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61403. /**
  61404. * Gets the bottom frustum plane transformed by the transform matrix
  61405. * @param transform transformation matrix to be applied to the resulting frustum plane
  61406. * @param frustumPlane the resuling frustum plane
  61407. */
  61408. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61409. /**
  61410. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61411. * @param transform transformation matrix to be applied to the resulting frustum planes
  61412. * @param frustumPlanes the resuling frustum planes
  61413. */
  61414. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61415. }
  61416. /** Defines supported spaces */
  61417. export enum Space {
  61418. /** Local (object) space */
  61419. LOCAL = 0,
  61420. /** World space */
  61421. WORLD = 1,
  61422. /** Bone space */
  61423. BONE = 2
  61424. }
  61425. /** Defines the 3 main axes */
  61426. export class Axis {
  61427. /** X axis */
  61428. static X: Vector3;
  61429. /** Y axis */
  61430. static Y: Vector3;
  61431. /** Z axis */
  61432. static Z: Vector3;
  61433. }
  61434. /** Class used to represent a Bezier curve */
  61435. export class BezierCurve {
  61436. /**
  61437. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61438. * @param t defines the time
  61439. * @param x1 defines the left coordinate on X axis
  61440. * @param y1 defines the left coordinate on Y axis
  61441. * @param x2 defines the right coordinate on X axis
  61442. * @param y2 defines the right coordinate on Y axis
  61443. * @returns the interpolated value
  61444. */
  61445. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61446. }
  61447. /**
  61448. * Defines potential orientation for back face culling
  61449. */
  61450. export enum Orientation {
  61451. /**
  61452. * Clockwise
  61453. */
  61454. CW = 0,
  61455. /** Counter clockwise */
  61456. CCW = 1
  61457. }
  61458. /**
  61459. * Defines angle representation
  61460. */
  61461. export class Angle {
  61462. private _radians;
  61463. /**
  61464. * Creates an Angle object of "radians" radians (float).
  61465. * @param radians the angle in radians
  61466. */
  61467. constructor(radians: number);
  61468. /**
  61469. * Get value in degrees
  61470. * @returns the Angle value in degrees (float)
  61471. */
  61472. degrees(): number;
  61473. /**
  61474. * Get value in radians
  61475. * @returns the Angle value in radians (float)
  61476. */
  61477. radians(): number;
  61478. /**
  61479. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61480. * @param a defines first vector
  61481. * @param b defines second vector
  61482. * @returns a new Angle
  61483. */
  61484. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61485. /**
  61486. * Gets a new Angle object from the given float in radians
  61487. * @param radians defines the angle value in radians
  61488. * @returns a new Angle
  61489. */
  61490. static FromRadians(radians: number): Angle;
  61491. /**
  61492. * Gets a new Angle object from the given float in degrees
  61493. * @param degrees defines the angle value in degrees
  61494. * @returns a new Angle
  61495. */
  61496. static FromDegrees(degrees: number): Angle;
  61497. }
  61498. /**
  61499. * This represents an arc in a 2d space.
  61500. */
  61501. export class Arc2 {
  61502. /** Defines the start point of the arc */
  61503. startPoint: Vector2;
  61504. /** Defines the mid point of the arc */
  61505. midPoint: Vector2;
  61506. /** Defines the end point of the arc */
  61507. endPoint: Vector2;
  61508. /**
  61509. * Defines the center point of the arc.
  61510. */
  61511. centerPoint: Vector2;
  61512. /**
  61513. * Defines the radius of the arc.
  61514. */
  61515. radius: number;
  61516. /**
  61517. * Defines the angle of the arc (from mid point to end point).
  61518. */
  61519. angle: Angle;
  61520. /**
  61521. * Defines the start angle of the arc (from start point to middle point).
  61522. */
  61523. startAngle: Angle;
  61524. /**
  61525. * Defines the orientation of the arc (clock wise/counter clock wise).
  61526. */
  61527. orientation: Orientation;
  61528. /**
  61529. * Creates an Arc object from the three given points : start, middle and end.
  61530. * @param startPoint Defines the start point of the arc
  61531. * @param midPoint Defines the midlle point of the arc
  61532. * @param endPoint Defines the end point of the arc
  61533. */
  61534. constructor(
  61535. /** Defines the start point of the arc */
  61536. startPoint: Vector2,
  61537. /** Defines the mid point of the arc */
  61538. midPoint: Vector2,
  61539. /** Defines the end point of the arc */
  61540. endPoint: Vector2);
  61541. }
  61542. /**
  61543. * Represents a 2D path made up of multiple 2D points
  61544. */
  61545. export class Path2 {
  61546. private _points;
  61547. private _length;
  61548. /**
  61549. * If the path start and end point are the same
  61550. */
  61551. closed: boolean;
  61552. /**
  61553. * Creates a Path2 object from the starting 2D coordinates x and y.
  61554. * @param x the starting points x value
  61555. * @param y the starting points y value
  61556. */
  61557. constructor(x: number, y: number);
  61558. /**
  61559. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61560. * @param x the added points x value
  61561. * @param y the added points y value
  61562. * @returns the updated Path2.
  61563. */
  61564. addLineTo(x: number, y: number): Path2;
  61565. /**
  61566. * 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.
  61567. * @param midX middle point x value
  61568. * @param midY middle point y value
  61569. * @param endX end point x value
  61570. * @param endY end point y value
  61571. * @param numberOfSegments (default: 36)
  61572. * @returns the updated Path2.
  61573. */
  61574. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61575. /**
  61576. * Closes the Path2.
  61577. * @returns the Path2.
  61578. */
  61579. close(): Path2;
  61580. /**
  61581. * Gets the sum of the distance between each sequential point in the path
  61582. * @returns the Path2 total length (float).
  61583. */
  61584. length(): number;
  61585. /**
  61586. * Gets the points which construct the path
  61587. * @returns the Path2 internal array of points.
  61588. */
  61589. getPoints(): Vector2[];
  61590. /**
  61591. * Retreives the point at the distance aways from the starting point
  61592. * @param normalizedLengthPosition the length along the path to retreive the point from
  61593. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61594. */
  61595. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61596. /**
  61597. * Creates a new path starting from an x and y position
  61598. * @param x starting x value
  61599. * @param y starting y value
  61600. * @returns a new Path2 starting at the coordinates (x, y).
  61601. */
  61602. static StartingAt(x: number, y: number): Path2;
  61603. }
  61604. /**
  61605. * Represents a 3D path made up of multiple 3D points
  61606. */
  61607. export class Path3D {
  61608. /**
  61609. * an array of Vector3, the curve axis of the Path3D
  61610. */
  61611. path: Vector3[];
  61612. private _curve;
  61613. private _distances;
  61614. private _tangents;
  61615. private _normals;
  61616. private _binormals;
  61617. private _raw;
  61618. /**
  61619. * new Path3D(path, normal, raw)
  61620. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61621. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61622. * @param path an array of Vector3, the curve axis of the Path3D
  61623. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61624. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61625. */
  61626. constructor(
  61627. /**
  61628. * an array of Vector3, the curve axis of the Path3D
  61629. */
  61630. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61631. /**
  61632. * Returns the Path3D array of successive Vector3 designing its curve.
  61633. * @returns the Path3D array of successive Vector3 designing its curve.
  61634. */
  61635. getCurve(): Vector3[];
  61636. /**
  61637. * Returns an array populated with tangent vectors on each Path3D curve point.
  61638. * @returns an array populated with tangent vectors on each Path3D curve point.
  61639. */
  61640. getTangents(): Vector3[];
  61641. /**
  61642. * Returns an array populated with normal vectors on each Path3D curve point.
  61643. * @returns an array populated with normal vectors on each Path3D curve point.
  61644. */
  61645. getNormals(): Vector3[];
  61646. /**
  61647. * Returns an array populated with binormal vectors on each Path3D curve point.
  61648. * @returns an array populated with binormal vectors on each Path3D curve point.
  61649. */
  61650. getBinormals(): Vector3[];
  61651. /**
  61652. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61653. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61654. */
  61655. getDistances(): number[];
  61656. /**
  61657. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61658. * @param path path which all values are copied into the curves points
  61659. * @param firstNormal which should be projected onto the curve
  61660. * @returns the same object updated.
  61661. */
  61662. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61663. private _compute;
  61664. private _getFirstNonNullVector;
  61665. private _getLastNonNullVector;
  61666. private _normalVector;
  61667. }
  61668. /**
  61669. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61670. * A Curve3 is designed from a series of successive Vector3.
  61671. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61672. */
  61673. export class Curve3 {
  61674. private _points;
  61675. private _length;
  61676. /**
  61677. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61678. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61679. * @param v1 (Vector3) the control point
  61680. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61681. * @param nbPoints (integer) the wanted number of points in the curve
  61682. * @returns the created Curve3
  61683. */
  61684. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61685. /**
  61686. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61687. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61688. * @param v1 (Vector3) the first control point
  61689. * @param v2 (Vector3) the second control point
  61690. * @param v3 (Vector3) the end point of the Cubic Bezier
  61691. * @param nbPoints (integer) the wanted number of points in the curve
  61692. * @returns the created Curve3
  61693. */
  61694. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61695. /**
  61696. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61697. * @param p1 (Vector3) the origin point of the Hermite Spline
  61698. * @param t1 (Vector3) the tangent vector at the origin point
  61699. * @param p2 (Vector3) the end point of the Hermite Spline
  61700. * @param t2 (Vector3) the tangent vector at the end point
  61701. * @param nbPoints (integer) the wanted number of points in the curve
  61702. * @returns the created Curve3
  61703. */
  61704. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61705. /**
  61706. * Returns a Curve3 object along a CatmullRom Spline curve :
  61707. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61708. * @param nbPoints (integer) the wanted number of points between each curve control points
  61709. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61710. * @returns the created Curve3
  61711. */
  61712. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61713. /**
  61714. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61715. * A Curve3 is designed from a series of successive Vector3.
  61716. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61717. * @param points points which make up the curve
  61718. */
  61719. constructor(points: Vector3[]);
  61720. /**
  61721. * @returns the Curve3 stored array of successive Vector3
  61722. */
  61723. getPoints(): Vector3[];
  61724. /**
  61725. * @returns the computed length (float) of the curve.
  61726. */
  61727. length(): number;
  61728. /**
  61729. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61730. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61731. * curveA and curveB keep unchanged.
  61732. * @param curve the curve to continue from this curve
  61733. * @returns the newly constructed curve
  61734. */
  61735. continue(curve: DeepImmutable<Curve3>): Curve3;
  61736. private _computeLength;
  61737. }
  61738. /**
  61739. * Contains position and normal vectors for a vertex
  61740. */
  61741. export class PositionNormalVertex {
  61742. /** the position of the vertex (defaut: 0,0,0) */
  61743. position: Vector3;
  61744. /** the normal of the vertex (defaut: 0,1,0) */
  61745. normal: Vector3;
  61746. /**
  61747. * Creates a PositionNormalVertex
  61748. * @param position the position of the vertex (defaut: 0,0,0)
  61749. * @param normal the normal of the vertex (defaut: 0,1,0)
  61750. */
  61751. constructor(
  61752. /** the position of the vertex (defaut: 0,0,0) */
  61753. position?: Vector3,
  61754. /** the normal of the vertex (defaut: 0,1,0) */
  61755. normal?: Vector3);
  61756. /**
  61757. * Clones the PositionNormalVertex
  61758. * @returns the cloned PositionNormalVertex
  61759. */
  61760. clone(): PositionNormalVertex;
  61761. }
  61762. /**
  61763. * Contains position, normal and uv vectors for a vertex
  61764. */
  61765. export class PositionNormalTextureVertex {
  61766. /** the position of the vertex (defaut: 0,0,0) */
  61767. position: Vector3;
  61768. /** the normal of the vertex (defaut: 0,1,0) */
  61769. normal: Vector3;
  61770. /** the uv of the vertex (default: 0,0) */
  61771. uv: Vector2;
  61772. /**
  61773. * Creates a PositionNormalTextureVertex
  61774. * @param position the position of the vertex (defaut: 0,0,0)
  61775. * @param normal the normal of the vertex (defaut: 0,1,0)
  61776. * @param uv the uv of the vertex (default: 0,0)
  61777. */
  61778. constructor(
  61779. /** the position of the vertex (defaut: 0,0,0) */
  61780. position?: Vector3,
  61781. /** the normal of the vertex (defaut: 0,1,0) */
  61782. normal?: Vector3,
  61783. /** the uv of the vertex (default: 0,0) */
  61784. uv?: Vector2);
  61785. /**
  61786. * Clones the PositionNormalTextureVertex
  61787. * @returns the cloned PositionNormalTextureVertex
  61788. */
  61789. clone(): PositionNormalTextureVertex;
  61790. }
  61791. /**
  61792. * @hidden
  61793. */
  61794. export class Tmp {
  61795. static Color3: Color3[];
  61796. static Color4: Color4[];
  61797. static Vector2: Vector2[];
  61798. static Vector3: Vector3[];
  61799. static Vector4: Vector4[];
  61800. static Quaternion: Quaternion[];
  61801. static Matrix: Matrix[];
  61802. }
  61803. }
  61804. declare module BABYLON {
  61805. /**
  61806. * Class used to enable access to offline support
  61807. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61808. */
  61809. export interface IOfflineProvider {
  61810. /**
  61811. * Gets a boolean indicating if scene must be saved in the database
  61812. */
  61813. enableSceneOffline: boolean;
  61814. /**
  61815. * Gets a boolean indicating if textures must be saved in the database
  61816. */
  61817. enableTexturesOffline: boolean;
  61818. /**
  61819. * Open the offline support and make it available
  61820. * @param successCallback defines the callback to call on success
  61821. * @param errorCallback defines the callback to call on error
  61822. */
  61823. open(successCallback: () => void, errorCallback: () => void): void;
  61824. /**
  61825. * Loads an image from the offline support
  61826. * @param url defines the url to load from
  61827. * @param image defines the target DOM image
  61828. */
  61829. loadImage(url: string, image: HTMLImageElement): void;
  61830. /**
  61831. * Loads a file from offline support
  61832. * @param url defines the URL to load from
  61833. * @param sceneLoaded defines a callback to call on success
  61834. * @param progressCallBack defines a callback to call when progress changed
  61835. * @param errorCallback defines a callback to call on error
  61836. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61837. */
  61838. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61839. }
  61840. }
  61841. declare module BABYLON {
  61842. /**
  61843. * A class serves as a medium between the observable and its observers
  61844. */
  61845. export class EventState {
  61846. /**
  61847. * Create a new EventState
  61848. * @param mask defines the mask associated with this state
  61849. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61850. * @param target defines the original target of the state
  61851. * @param currentTarget defines the current target of the state
  61852. */
  61853. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61854. /**
  61855. * Initialize the current event state
  61856. * @param mask defines the mask associated with this state
  61857. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61858. * @param target defines the original target of the state
  61859. * @param currentTarget defines the current target of the state
  61860. * @returns the current event state
  61861. */
  61862. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61863. /**
  61864. * An Observer can set this property to true to prevent subsequent observers of being notified
  61865. */
  61866. skipNextObservers: boolean;
  61867. /**
  61868. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61869. */
  61870. mask: number;
  61871. /**
  61872. * The object that originally notified the event
  61873. */
  61874. target?: any;
  61875. /**
  61876. * The current object in the bubbling phase
  61877. */
  61878. currentTarget?: any;
  61879. /**
  61880. * This will be populated with the return value of the last function that was executed.
  61881. * If it is the first function in the callback chain it will be the event data.
  61882. */
  61883. lastReturnValue?: any;
  61884. }
  61885. /**
  61886. * Represent an Observer registered to a given Observable object.
  61887. */
  61888. export class Observer<T> {
  61889. /**
  61890. * Defines the callback to call when the observer is notified
  61891. */
  61892. callback: (eventData: T, eventState: EventState) => void;
  61893. /**
  61894. * Defines the mask of the observer (used to filter notifications)
  61895. */
  61896. mask: number;
  61897. /**
  61898. * Defines the current scope used to restore the JS context
  61899. */
  61900. scope: any;
  61901. /** @hidden */
  61902. _willBeUnregistered: boolean;
  61903. /**
  61904. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61905. */
  61906. unregisterOnNextCall: boolean;
  61907. /**
  61908. * Creates a new observer
  61909. * @param callback defines the callback to call when the observer is notified
  61910. * @param mask defines the mask of the observer (used to filter notifications)
  61911. * @param scope defines the current scope used to restore the JS context
  61912. */
  61913. constructor(
  61914. /**
  61915. * Defines the callback to call when the observer is notified
  61916. */
  61917. callback: (eventData: T, eventState: EventState) => void,
  61918. /**
  61919. * Defines the mask of the observer (used to filter notifications)
  61920. */
  61921. mask: number,
  61922. /**
  61923. * Defines the current scope used to restore the JS context
  61924. */
  61925. scope?: any);
  61926. }
  61927. /**
  61928. * Represent a list of observers registered to multiple Observables object.
  61929. */
  61930. export class MultiObserver<T> {
  61931. private _observers;
  61932. private _observables;
  61933. /**
  61934. * Release associated resources
  61935. */
  61936. dispose(): void;
  61937. /**
  61938. * Raise a callback when one of the observable will notify
  61939. * @param observables defines a list of observables to watch
  61940. * @param callback defines the callback to call on notification
  61941. * @param mask defines the mask used to filter notifications
  61942. * @param scope defines the current scope used to restore the JS context
  61943. * @returns the new MultiObserver
  61944. */
  61945. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61946. }
  61947. /**
  61948. * The Observable class is a simple implementation of the Observable pattern.
  61949. *
  61950. * 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.
  61951. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61952. * 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).
  61953. * 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.
  61954. */
  61955. export class Observable<T> {
  61956. private _observers;
  61957. private _eventState;
  61958. private _onObserverAdded;
  61959. /**
  61960. * Creates a new observable
  61961. * @param onObserverAdded defines a callback to call when a new observer is added
  61962. */
  61963. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61964. /**
  61965. * Create a new Observer with the specified callback
  61966. * @param callback the callback that will be executed for that Observer
  61967. * @param mask the mask used to filter observers
  61968. * @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.
  61969. * @param scope optional scope for the callback to be called from
  61970. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61971. * @returns the new observer created for the callback
  61972. */
  61973. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61974. /**
  61975. * Create a new Observer with the specified callback and unregisters after the next notification
  61976. * @param callback the callback that will be executed for that Observer
  61977. * @returns the new observer created for the callback
  61978. */
  61979. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61980. /**
  61981. * Remove an Observer from the Observable object
  61982. * @param observer the instance of the Observer to remove
  61983. * @returns false if it doesn't belong to this Observable
  61984. */
  61985. remove(observer: Nullable<Observer<T>>): boolean;
  61986. /**
  61987. * Remove a callback from the Observable object
  61988. * @param callback the callback to remove
  61989. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61990. * @returns false if it doesn't belong to this Observable
  61991. */
  61992. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61993. private _deferUnregister;
  61994. private _remove;
  61995. /**
  61996. * Notify all Observers by calling their respective callback with the given data
  61997. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61998. * @param eventData defines the data to send to all observers
  61999. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62000. * @param target defines the original target of the state
  62001. * @param currentTarget defines the current target of the state
  62002. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62003. */
  62004. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62005. /**
  62006. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62007. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62008. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62009. * and it is crucial that all callbacks will be executed.
  62010. * The order of the callbacks is kept, callbacks are not executed parallel.
  62011. *
  62012. * @param eventData The data to be sent to each callback
  62013. * @param mask is used to filter observers defaults to -1
  62014. * @param target defines the callback target (see EventState)
  62015. * @param currentTarget defines he current object in the bubbling phase
  62016. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62017. */
  62018. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62019. /**
  62020. * Notify a specific observer
  62021. * @param observer defines the observer to notify
  62022. * @param eventData defines the data to be sent to each callback
  62023. * @param mask is used to filter observers defaults to -1
  62024. */
  62025. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62026. /**
  62027. * Gets a boolean indicating if the observable has at least one observer
  62028. * @returns true is the Observable has at least one Observer registered
  62029. */
  62030. hasObservers(): boolean;
  62031. /**
  62032. * Clear the list of observers
  62033. */
  62034. clear(): void;
  62035. /**
  62036. * Clone the current observable
  62037. * @returns a new observable
  62038. */
  62039. clone(): Observable<T>;
  62040. /**
  62041. * Does this observable handles observer registered with a given mask
  62042. * @param mask defines the mask to be tested
  62043. * @return whether or not one observer registered with the given mask is handeled
  62044. **/
  62045. hasSpecificMask(mask?: number): boolean;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Class used to help managing file picking and drag'n'drop
  62051. * File Storage
  62052. */
  62053. export class FilesInputStore {
  62054. /**
  62055. * List of files ready to be loaded
  62056. */
  62057. static FilesToLoad: {
  62058. [key: string]: File;
  62059. };
  62060. }
  62061. }
  62062. declare module BABYLON {
  62063. /** Defines the cross module used constants to avoid circular dependncies */
  62064. export class Constants {
  62065. /** Defines that alpha blending is disabled */
  62066. static readonly ALPHA_DISABLE: number;
  62067. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62068. static readonly ALPHA_ADD: number;
  62069. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62070. static readonly ALPHA_COMBINE: number;
  62071. /** Defines that alpha blending to DEST - SRC * DEST */
  62072. static readonly ALPHA_SUBTRACT: number;
  62073. /** Defines that alpha blending to SRC * DEST */
  62074. static readonly ALPHA_MULTIPLY: number;
  62075. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62076. static readonly ALPHA_MAXIMIZED: number;
  62077. /** Defines that alpha blending to SRC + DEST */
  62078. static readonly ALPHA_ONEONE: number;
  62079. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62080. static readonly ALPHA_PREMULTIPLIED: number;
  62081. /**
  62082. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62083. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62084. */
  62085. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62086. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62087. static readonly ALPHA_INTERPOLATE: number;
  62088. /**
  62089. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62090. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62091. */
  62092. static readonly ALPHA_SCREENMODE: number;
  62093. /** Defines that the ressource is not delayed*/
  62094. static readonly DELAYLOADSTATE_NONE: number;
  62095. /** Defines that the ressource was successfully delay loaded */
  62096. static readonly DELAYLOADSTATE_LOADED: number;
  62097. /** Defines that the ressource is currently delay loading */
  62098. static readonly DELAYLOADSTATE_LOADING: number;
  62099. /** Defines that the ressource is delayed and has not started loading */
  62100. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62102. static readonly NEVER: number;
  62103. /** 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 */
  62104. static readonly ALWAYS: number;
  62105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62106. static readonly LESS: number;
  62107. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62108. static readonly EQUAL: number;
  62109. /** 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 */
  62110. static readonly LEQUAL: number;
  62111. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62112. static readonly GREATER: number;
  62113. /** 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 */
  62114. static readonly GEQUAL: number;
  62115. /** 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 */
  62116. static readonly NOTEQUAL: number;
  62117. /** Passed to stencilOperation to specify that stencil value must be kept */
  62118. static readonly KEEP: number;
  62119. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62120. static readonly REPLACE: number;
  62121. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62122. static readonly INCR: number;
  62123. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62124. static readonly DECR: number;
  62125. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62126. static readonly INVERT: number;
  62127. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62128. static readonly INCR_WRAP: number;
  62129. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62130. static readonly DECR_WRAP: number;
  62131. /** Texture is not repeating outside of 0..1 UVs */
  62132. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62133. /** Texture is repeating outside of 0..1 UVs */
  62134. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62135. /** Texture is repeating and mirrored */
  62136. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62137. /** ALPHA */
  62138. static readonly TEXTUREFORMAT_ALPHA: number;
  62139. /** LUMINANCE */
  62140. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62141. /** LUMINANCE_ALPHA */
  62142. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62143. /** RGB */
  62144. static readonly TEXTUREFORMAT_RGB: number;
  62145. /** RGBA */
  62146. static readonly TEXTUREFORMAT_RGBA: number;
  62147. /** RED */
  62148. static readonly TEXTUREFORMAT_RED: number;
  62149. /** RED (2nd reference) */
  62150. static readonly TEXTUREFORMAT_R: number;
  62151. /** RG */
  62152. static readonly TEXTUREFORMAT_RG: number;
  62153. /** RED_INTEGER */
  62154. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62155. /** RED_INTEGER (2nd reference) */
  62156. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62157. /** RG_INTEGER */
  62158. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62159. /** RGB_INTEGER */
  62160. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62161. /** RGBA_INTEGER */
  62162. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62163. /** UNSIGNED_BYTE */
  62164. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62165. /** UNSIGNED_BYTE (2nd reference) */
  62166. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62167. /** FLOAT */
  62168. static readonly TEXTURETYPE_FLOAT: number;
  62169. /** HALF_FLOAT */
  62170. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62171. /** BYTE */
  62172. static readonly TEXTURETYPE_BYTE: number;
  62173. /** SHORT */
  62174. static readonly TEXTURETYPE_SHORT: number;
  62175. /** UNSIGNED_SHORT */
  62176. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62177. /** INT */
  62178. static readonly TEXTURETYPE_INT: number;
  62179. /** UNSIGNED_INT */
  62180. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62181. /** UNSIGNED_SHORT_4_4_4_4 */
  62182. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62183. /** UNSIGNED_SHORT_5_5_5_1 */
  62184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62185. /** UNSIGNED_SHORT_5_6_5 */
  62186. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62187. /** UNSIGNED_INT_2_10_10_10_REV */
  62188. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62189. /** UNSIGNED_INT_24_8 */
  62190. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62191. /** UNSIGNED_INT_10F_11F_11F_REV */
  62192. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62193. /** UNSIGNED_INT_5_9_9_9_REV */
  62194. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62195. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62196. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62197. /** nearest is mag = nearest and min = nearest and mip = linear */
  62198. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62199. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62200. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62201. /** Trilinear is mag = linear and min = linear and mip = linear */
  62202. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62203. /** nearest is mag = nearest and min = nearest and mip = linear */
  62204. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62205. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62206. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62207. /** Trilinear is mag = linear and min = linear and mip = linear */
  62208. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62209. /** mag = nearest and min = nearest and mip = nearest */
  62210. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62211. /** mag = nearest and min = linear and mip = nearest */
  62212. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62213. /** mag = nearest and min = linear and mip = linear */
  62214. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62215. /** mag = nearest and min = linear and mip = none */
  62216. static readonly TEXTURE_NEAREST_LINEAR: number;
  62217. /** mag = nearest and min = nearest and mip = none */
  62218. static readonly TEXTURE_NEAREST_NEAREST: number;
  62219. /** mag = linear and min = nearest and mip = nearest */
  62220. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62221. /** mag = linear and min = nearest and mip = linear */
  62222. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62223. /** mag = linear and min = linear and mip = none */
  62224. static readonly TEXTURE_LINEAR_LINEAR: number;
  62225. /** mag = linear and min = nearest and mip = none */
  62226. static readonly TEXTURE_LINEAR_NEAREST: number;
  62227. /** Explicit coordinates mode */
  62228. static readonly TEXTURE_EXPLICIT_MODE: number;
  62229. /** Spherical coordinates mode */
  62230. static readonly TEXTURE_SPHERICAL_MODE: number;
  62231. /** Planar coordinates mode */
  62232. static readonly TEXTURE_PLANAR_MODE: number;
  62233. /** Cubic coordinates mode */
  62234. static readonly TEXTURE_CUBIC_MODE: number;
  62235. /** Projection coordinates mode */
  62236. static readonly TEXTURE_PROJECTION_MODE: number;
  62237. /** Skybox coordinates mode */
  62238. static readonly TEXTURE_SKYBOX_MODE: number;
  62239. /** Inverse Cubic coordinates mode */
  62240. static readonly TEXTURE_INVCUBIC_MODE: number;
  62241. /** Equirectangular coordinates mode */
  62242. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62243. /** Equirectangular Fixed coordinates mode */
  62244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62245. /** Equirectangular Fixed Mirrored coordinates mode */
  62246. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62247. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62248. static readonly SCALEMODE_FLOOR: number;
  62249. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62250. static readonly SCALEMODE_NEAREST: number;
  62251. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62252. static readonly SCALEMODE_CEILING: number;
  62253. /**
  62254. * The dirty texture flag value
  62255. */
  62256. static readonly MATERIAL_TextureDirtyFlag: number;
  62257. /**
  62258. * The dirty light flag value
  62259. */
  62260. static readonly MATERIAL_LightDirtyFlag: number;
  62261. /**
  62262. * The dirty fresnel flag value
  62263. */
  62264. static readonly MATERIAL_FresnelDirtyFlag: number;
  62265. /**
  62266. * The dirty attribute flag value
  62267. */
  62268. static readonly MATERIAL_AttributesDirtyFlag: number;
  62269. /**
  62270. * The dirty misc flag value
  62271. */
  62272. static readonly MATERIAL_MiscDirtyFlag: number;
  62273. /**
  62274. * The all dirty flag value
  62275. */
  62276. static readonly MATERIAL_AllDirtyFlag: number;
  62277. /**
  62278. * Returns the triangle fill mode
  62279. */
  62280. static readonly MATERIAL_TriangleFillMode: number;
  62281. /**
  62282. * Returns the wireframe mode
  62283. */
  62284. static readonly MATERIAL_WireFrameFillMode: number;
  62285. /**
  62286. * Returns the point fill mode
  62287. */
  62288. static readonly MATERIAL_PointFillMode: number;
  62289. /**
  62290. * Returns the point list draw mode
  62291. */
  62292. static readonly MATERIAL_PointListDrawMode: number;
  62293. /**
  62294. * Returns the line list draw mode
  62295. */
  62296. static readonly MATERIAL_LineListDrawMode: number;
  62297. /**
  62298. * Returns the line loop draw mode
  62299. */
  62300. static readonly MATERIAL_LineLoopDrawMode: number;
  62301. /**
  62302. * Returns the line strip draw mode
  62303. */
  62304. static readonly MATERIAL_LineStripDrawMode: number;
  62305. /**
  62306. * Returns the triangle strip draw mode
  62307. */
  62308. static readonly MATERIAL_TriangleStripDrawMode: number;
  62309. /**
  62310. * Returns the triangle fan draw mode
  62311. */
  62312. static readonly MATERIAL_TriangleFanDrawMode: number;
  62313. /**
  62314. * Stores the clock-wise side orientation
  62315. */
  62316. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62317. /**
  62318. * Stores the counter clock-wise side orientation
  62319. */
  62320. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62321. /**
  62322. * Nothing
  62323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62324. */
  62325. static readonly ACTION_NothingTrigger: number;
  62326. /**
  62327. * On pick
  62328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62329. */
  62330. static readonly ACTION_OnPickTrigger: number;
  62331. /**
  62332. * On left pick
  62333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62334. */
  62335. static readonly ACTION_OnLeftPickTrigger: number;
  62336. /**
  62337. * On right pick
  62338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62339. */
  62340. static readonly ACTION_OnRightPickTrigger: number;
  62341. /**
  62342. * On center pick
  62343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62344. */
  62345. static readonly ACTION_OnCenterPickTrigger: number;
  62346. /**
  62347. * On pick down
  62348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62349. */
  62350. static readonly ACTION_OnPickDownTrigger: number;
  62351. /**
  62352. * On double pick
  62353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62354. */
  62355. static readonly ACTION_OnDoublePickTrigger: number;
  62356. /**
  62357. * On pick up
  62358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62359. */
  62360. static readonly ACTION_OnPickUpTrigger: number;
  62361. /**
  62362. * On pick out.
  62363. * This trigger will only be raised if you also declared a OnPickDown
  62364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62365. */
  62366. static readonly ACTION_OnPickOutTrigger: number;
  62367. /**
  62368. * On long press
  62369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62370. */
  62371. static readonly ACTION_OnLongPressTrigger: number;
  62372. /**
  62373. * On pointer over
  62374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62375. */
  62376. static readonly ACTION_OnPointerOverTrigger: number;
  62377. /**
  62378. * On pointer out
  62379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62380. */
  62381. static readonly ACTION_OnPointerOutTrigger: number;
  62382. /**
  62383. * On every frame
  62384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62385. */
  62386. static readonly ACTION_OnEveryFrameTrigger: number;
  62387. /**
  62388. * On intersection enter
  62389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62390. */
  62391. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62392. /**
  62393. * On intersection exit
  62394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62395. */
  62396. static readonly ACTION_OnIntersectionExitTrigger: number;
  62397. /**
  62398. * On key down
  62399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62400. */
  62401. static readonly ACTION_OnKeyDownTrigger: number;
  62402. /**
  62403. * On key up
  62404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62405. */
  62406. static readonly ACTION_OnKeyUpTrigger: number;
  62407. /**
  62408. * Billboard mode will only apply to Y axis
  62409. */
  62410. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62411. /**
  62412. * Billboard mode will apply to all axes
  62413. */
  62414. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62415. /**
  62416. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62417. */
  62418. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62419. /**
  62420. * Gets or sets base Assets URL
  62421. */
  62422. static readonly PARTICLES_BaseAssetsUrl: string;
  62423. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62424. * Test order :
  62425. * Is the bounding sphere outside the frustum ?
  62426. * If not, are the bounding box vertices outside the frustum ?
  62427. * It not, then the cullable object is in the frustum.
  62428. */
  62429. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62430. /** Culling strategy : Bounding Sphere Only.
  62431. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62432. * It's also less accurate than the standard because some not visible objects can still be selected.
  62433. * Test : is the bounding sphere outside the frustum ?
  62434. * If not, then the cullable object is in the frustum.
  62435. */
  62436. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62437. /** Culling strategy : Optimistic Inclusion.
  62438. * This in an inclusion test first, then the standard exclusion test.
  62439. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62440. * 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.
  62441. * Anyway, it's as accurate as the standard strategy.
  62442. * Test :
  62443. * Is the cullable object bounding sphere center in the frustum ?
  62444. * If not, apply the default culling strategy.
  62445. */
  62446. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62447. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62448. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62449. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62450. * 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.
  62451. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62452. * Test :
  62453. * Is the cullable object bounding sphere center in the frustum ?
  62454. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62455. */
  62456. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62457. /**
  62458. * No logging while loading
  62459. */
  62460. static readonly SCENELOADER_NO_LOGGING: number;
  62461. /**
  62462. * Minimal logging while loading
  62463. */
  62464. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62465. /**
  62466. * Summary logging while loading
  62467. */
  62468. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62469. /**
  62470. * Detailled logging while loading
  62471. */
  62472. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62473. }
  62474. }
  62475. declare module BABYLON {
  62476. /**
  62477. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62478. * Babylon.js
  62479. */
  62480. export class DomManagement {
  62481. /**
  62482. * Checks if the window object exists
  62483. * @returns true if the window object exists
  62484. */
  62485. static IsWindowObjectExist(): boolean;
  62486. /**
  62487. * Extracts text content from a DOM element hierarchy
  62488. * @param element defines the root element
  62489. * @returns a string
  62490. */
  62491. static GetDOMTextContent(element: HTMLElement): string;
  62492. }
  62493. }
  62494. declare module BABYLON {
  62495. /**
  62496. * Logger used througouht the application to allow configuration of
  62497. * the log level required for the messages.
  62498. */
  62499. export class Logger {
  62500. /**
  62501. * No log
  62502. */
  62503. static readonly NoneLogLevel: number;
  62504. /**
  62505. * Only message logs
  62506. */
  62507. static readonly MessageLogLevel: number;
  62508. /**
  62509. * Only warning logs
  62510. */
  62511. static readonly WarningLogLevel: number;
  62512. /**
  62513. * Only error logs
  62514. */
  62515. static readonly ErrorLogLevel: number;
  62516. /**
  62517. * All logs
  62518. */
  62519. static readonly AllLogLevel: number;
  62520. private static _LogCache;
  62521. /**
  62522. * Gets a value indicating the number of loading errors
  62523. * @ignorenaming
  62524. */
  62525. static errorsCount: number;
  62526. /**
  62527. * Callback called when a new log is added
  62528. */
  62529. static OnNewCacheEntry: (entry: string) => void;
  62530. private static _AddLogEntry;
  62531. private static _FormatMessage;
  62532. private static _LogDisabled;
  62533. private static _LogEnabled;
  62534. private static _WarnDisabled;
  62535. private static _WarnEnabled;
  62536. private static _ErrorDisabled;
  62537. private static _ErrorEnabled;
  62538. /**
  62539. * Log a message to the console
  62540. */
  62541. static Log: (message: string) => void;
  62542. /**
  62543. * Write a warning message to the console
  62544. */
  62545. static Warn: (message: string) => void;
  62546. /**
  62547. * Write an error message to the console
  62548. */
  62549. static Error: (message: string) => void;
  62550. /**
  62551. * Gets current log cache (list of logs)
  62552. */
  62553. static readonly LogCache: string;
  62554. /**
  62555. * Clears the log cache
  62556. */
  62557. static ClearLogCache(): void;
  62558. /**
  62559. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62560. */
  62561. static LogLevels: number;
  62562. }
  62563. }
  62564. declare module BABYLON {
  62565. /** @hidden */
  62566. export class _TypeStore {
  62567. /** @hidden */
  62568. static RegisteredTypes: {
  62569. [key: string]: Object;
  62570. };
  62571. /** @hidden */
  62572. static GetClass(fqdn: string): any;
  62573. }
  62574. }
  62575. declare module BABYLON {
  62576. /**
  62577. * Class containing a set of static utilities functions for deep copy.
  62578. */
  62579. export class DeepCopier {
  62580. /**
  62581. * Tries to copy an object by duplicating every property
  62582. * @param source defines the source object
  62583. * @param destination defines the target object
  62584. * @param doNotCopyList defines a list of properties to avoid
  62585. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62586. */
  62587. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62588. }
  62589. }
  62590. declare module BABYLON {
  62591. /**
  62592. * Class containing a set of static utilities functions for precision date
  62593. */
  62594. export class PrecisionDate {
  62595. /**
  62596. * Gets either window.performance.now() if supported or Date.now() else
  62597. */
  62598. static readonly Now: number;
  62599. }
  62600. }
  62601. declare module BABYLON {
  62602. /** @hidden */
  62603. export class _DevTools {
  62604. static WarnImport(name: string): string;
  62605. }
  62606. }
  62607. declare module BABYLON {
  62608. /**
  62609. * Class used to evalaute queries containing `and` and `or` operators
  62610. */
  62611. export class AndOrNotEvaluator {
  62612. /**
  62613. * Evaluate a query
  62614. * @param query defines the query to evaluate
  62615. * @param evaluateCallback defines the callback used to filter result
  62616. * @returns true if the query matches
  62617. */
  62618. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62619. private static _HandleParenthesisContent;
  62620. private static _SimplifyNegation;
  62621. }
  62622. }
  62623. declare module BABYLON {
  62624. /**
  62625. * Class used to store custom tags
  62626. */
  62627. export class Tags {
  62628. /**
  62629. * Adds support for tags on the given object
  62630. * @param obj defines the object to use
  62631. */
  62632. static EnableFor(obj: any): void;
  62633. /**
  62634. * Removes tags support
  62635. * @param obj defines the object to use
  62636. */
  62637. static DisableFor(obj: any): void;
  62638. /**
  62639. * Gets a boolean indicating if the given object has tags
  62640. * @param obj defines the object to use
  62641. * @returns a boolean
  62642. */
  62643. static HasTags(obj: any): boolean;
  62644. /**
  62645. * Gets the tags available on a given object
  62646. * @param obj defines the object to use
  62647. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62648. * @returns the tags
  62649. */
  62650. static GetTags(obj: any, asString?: boolean): any;
  62651. /**
  62652. * Adds tags to an object
  62653. * @param obj defines the object to use
  62654. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62655. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62656. */
  62657. static AddTagsTo(obj: any, tagsString: string): void;
  62658. /**
  62659. * @hidden
  62660. */
  62661. static _AddTagTo(obj: any, tag: string): void;
  62662. /**
  62663. * Removes specific tags from a specific object
  62664. * @param obj defines the object to use
  62665. * @param tagsString defines the tags to remove
  62666. */
  62667. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62668. /**
  62669. * @hidden
  62670. */
  62671. static _RemoveTagFrom(obj: any, tag: string): void;
  62672. /**
  62673. * Defines if tags hosted on an object match a given query
  62674. * @param obj defines the object to use
  62675. * @param tagsQuery defines the tag query
  62676. * @returns a boolean
  62677. */
  62678. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62679. }
  62680. }
  62681. declare module BABYLON {
  62682. /**
  62683. * Manages the defines for the Material
  62684. */
  62685. export class MaterialDefines {
  62686. private _keys;
  62687. private _isDirty;
  62688. /** @hidden */
  62689. _renderId: number;
  62690. /** @hidden */
  62691. _areLightsDirty: boolean;
  62692. /** @hidden */
  62693. _areAttributesDirty: boolean;
  62694. /** @hidden */
  62695. _areTexturesDirty: boolean;
  62696. /** @hidden */
  62697. _areFresnelDirty: boolean;
  62698. /** @hidden */
  62699. _areMiscDirty: boolean;
  62700. /** @hidden */
  62701. _areImageProcessingDirty: boolean;
  62702. /** @hidden */
  62703. _normals: boolean;
  62704. /** @hidden */
  62705. _uvs: boolean;
  62706. /** @hidden */
  62707. _needNormals: boolean;
  62708. /** @hidden */
  62709. _needUVs: boolean;
  62710. /**
  62711. * Specifies if the material needs to be re-calculated
  62712. */
  62713. readonly isDirty: boolean;
  62714. /**
  62715. * Marks the material to indicate that it has been re-calculated
  62716. */
  62717. markAsProcessed(): void;
  62718. /**
  62719. * Marks the material to indicate that it needs to be re-calculated
  62720. */
  62721. markAsUnprocessed(): void;
  62722. /**
  62723. * Marks the material to indicate all of its defines need to be re-calculated
  62724. */
  62725. markAllAsDirty(): void;
  62726. /**
  62727. * Marks the material to indicate that image processing needs to be re-calculated
  62728. */
  62729. markAsImageProcessingDirty(): void;
  62730. /**
  62731. * Marks the material to indicate the lights need to be re-calculated
  62732. */
  62733. markAsLightDirty(): void;
  62734. /**
  62735. * Marks the attribute state as changed
  62736. */
  62737. markAsAttributesDirty(): void;
  62738. /**
  62739. * Marks the texture state as changed
  62740. */
  62741. markAsTexturesDirty(): void;
  62742. /**
  62743. * Marks the fresnel state as changed
  62744. */
  62745. markAsFresnelDirty(): void;
  62746. /**
  62747. * Marks the misc state as changed
  62748. */
  62749. markAsMiscDirty(): void;
  62750. /**
  62751. * Rebuilds the material defines
  62752. */
  62753. rebuild(): void;
  62754. /**
  62755. * Specifies if two material defines are equal
  62756. * @param other - A material define instance to compare to
  62757. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62758. */
  62759. isEqual(other: MaterialDefines): boolean;
  62760. /**
  62761. * Clones this instance's defines to another instance
  62762. * @param other - material defines to clone values to
  62763. */
  62764. cloneTo(other: MaterialDefines): void;
  62765. /**
  62766. * Resets the material define values
  62767. */
  62768. reset(): void;
  62769. /**
  62770. * Converts the material define values to a string
  62771. * @returns - String of material define information
  62772. */
  62773. toString(): string;
  62774. }
  62775. }
  62776. declare module BABYLON {
  62777. /**
  62778. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62779. */
  62780. export class PerformanceMonitor {
  62781. private _enabled;
  62782. private _rollingFrameTime;
  62783. private _lastFrameTimeMs;
  62784. /**
  62785. * constructor
  62786. * @param frameSampleSize The number of samples required to saturate the sliding window
  62787. */
  62788. constructor(frameSampleSize?: number);
  62789. /**
  62790. * Samples current frame
  62791. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62792. */
  62793. sampleFrame(timeMs?: number): void;
  62794. /**
  62795. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62796. */
  62797. readonly averageFrameTime: number;
  62798. /**
  62799. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62800. */
  62801. readonly averageFrameTimeVariance: number;
  62802. /**
  62803. * Returns the frame time of the most recent frame
  62804. */
  62805. readonly instantaneousFrameTime: number;
  62806. /**
  62807. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62808. */
  62809. readonly averageFPS: number;
  62810. /**
  62811. * Returns the average framerate in frames per second using the most recent frame time
  62812. */
  62813. readonly instantaneousFPS: number;
  62814. /**
  62815. * Returns true if enough samples have been taken to completely fill the sliding window
  62816. */
  62817. readonly isSaturated: boolean;
  62818. /**
  62819. * Enables contributions to the sliding window sample set
  62820. */
  62821. enable(): void;
  62822. /**
  62823. * Disables contributions to the sliding window sample set
  62824. * Samples will not be interpolated over the disabled period
  62825. */
  62826. disable(): void;
  62827. /**
  62828. * Returns true if sampling is enabled
  62829. */
  62830. readonly isEnabled: boolean;
  62831. /**
  62832. * Resets performance monitor
  62833. */
  62834. reset(): void;
  62835. }
  62836. /**
  62837. * RollingAverage
  62838. *
  62839. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62840. */
  62841. export class RollingAverage {
  62842. /**
  62843. * Current average
  62844. */
  62845. average: number;
  62846. /**
  62847. * Current variance
  62848. */
  62849. variance: number;
  62850. protected _samples: Array<number>;
  62851. protected _sampleCount: number;
  62852. protected _pos: number;
  62853. protected _m2: number;
  62854. /**
  62855. * constructor
  62856. * @param length The number of samples required to saturate the sliding window
  62857. */
  62858. constructor(length: number);
  62859. /**
  62860. * Adds a sample to the sample set
  62861. * @param v The sample value
  62862. */
  62863. add(v: number): void;
  62864. /**
  62865. * Returns previously added values or null if outside of history or outside the sliding window domain
  62866. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62867. * @return Value previously recorded with add() or null if outside of range
  62868. */
  62869. history(i: number): number;
  62870. /**
  62871. * Returns true if enough samples have been taken to completely fill the sliding window
  62872. * @return true if sample-set saturated
  62873. */
  62874. isSaturated(): boolean;
  62875. /**
  62876. * Resets the rolling average (equivalent to 0 samples taken so far)
  62877. */
  62878. reset(): void;
  62879. /**
  62880. * Wraps a value around the sample range boundaries
  62881. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62882. * @return Wrapped position in sample range
  62883. */
  62884. protected _wrapPosition(i: number): number;
  62885. }
  62886. }
  62887. declare module BABYLON {
  62888. /**
  62889. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62890. * The underlying implementation relies on an associative array to ensure the best performances.
  62891. * The value can be anything including 'null' but except 'undefined'
  62892. */
  62893. export class StringDictionary<T> {
  62894. /**
  62895. * This will clear this dictionary and copy the content from the 'source' one.
  62896. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62897. * @param source the dictionary to take the content from and copy to this dictionary
  62898. */
  62899. copyFrom(source: StringDictionary<T>): void;
  62900. /**
  62901. * Get a value based from its key
  62902. * @param key the given key to get the matching value from
  62903. * @return the value if found, otherwise undefined is returned
  62904. */
  62905. get(key: string): T | undefined;
  62906. /**
  62907. * Get a value from its key or add it if it doesn't exist.
  62908. * This method will ensure you that a given key/data will be present in the dictionary.
  62909. * @param key the given key to get the matching value from
  62910. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62911. * The factory will only be invoked if there's no data for the given key.
  62912. * @return the value corresponding to the key.
  62913. */
  62914. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62915. /**
  62916. * Get a value from its key if present in the dictionary otherwise add it
  62917. * @param key the key to get the value from
  62918. * @param val if there's no such key/value pair in the dictionary add it with this value
  62919. * @return the value corresponding to the key
  62920. */
  62921. getOrAdd(key: string, val: T): T;
  62922. /**
  62923. * Check if there's a given key in the dictionary
  62924. * @param key the key to check for
  62925. * @return true if the key is present, false otherwise
  62926. */
  62927. contains(key: string): boolean;
  62928. /**
  62929. * Add a new key and its corresponding value
  62930. * @param key the key to add
  62931. * @param value the value corresponding to the key
  62932. * @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
  62933. */
  62934. add(key: string, value: T): boolean;
  62935. /**
  62936. * Update a specific value associated to a key
  62937. * @param key defines the key to use
  62938. * @param value defines the value to store
  62939. * @returns true if the value was updated (or false if the key was not found)
  62940. */
  62941. set(key: string, value: T): boolean;
  62942. /**
  62943. * Get the element of the given key and remove it from the dictionary
  62944. * @param key defines the key to search
  62945. * @returns the value associated with the key or null if not found
  62946. */
  62947. getAndRemove(key: string): Nullable<T>;
  62948. /**
  62949. * Remove a key/value from the dictionary.
  62950. * @param key the key to remove
  62951. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62952. */
  62953. remove(key: string): boolean;
  62954. /**
  62955. * Clear the whole content of the dictionary
  62956. */
  62957. clear(): void;
  62958. /**
  62959. * Gets the current count
  62960. */
  62961. readonly count: number;
  62962. /**
  62963. * Execute a callback on each key/val of the dictionary.
  62964. * Note that you can remove any element in this dictionary in the callback implementation
  62965. * @param callback the callback to execute on a given key/value pair
  62966. */
  62967. forEach(callback: (key: string, val: T) => void): void;
  62968. /**
  62969. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62970. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62971. * Note that you can remove any element in this dictionary in the callback implementation
  62972. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62973. * @returns the first item
  62974. */
  62975. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62976. private _count;
  62977. private _data;
  62978. }
  62979. }
  62980. declare module BABYLON {
  62981. /**
  62982. * Helper class that provides a small promise polyfill
  62983. */
  62984. export class PromisePolyfill {
  62985. /**
  62986. * Static function used to check if the polyfill is required
  62987. * If this is the case then the function will inject the polyfill to window.Promise
  62988. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62989. */
  62990. static Apply(force?: boolean): void;
  62991. }
  62992. }
  62993. declare module BABYLON {
  62994. /**
  62995. * Class used to store data that will be store in GPU memory
  62996. */
  62997. export class Buffer {
  62998. private _engine;
  62999. private _buffer;
  63000. /** @hidden */
  63001. _data: Nullable<DataArray>;
  63002. private _updatable;
  63003. private _instanced;
  63004. /**
  63005. * Gets the byte stride.
  63006. */
  63007. readonly byteStride: number;
  63008. /**
  63009. * Constructor
  63010. * @param engine the engine
  63011. * @param data the data to use for this buffer
  63012. * @param updatable whether the data is updatable
  63013. * @param stride the stride (optional)
  63014. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63015. * @param instanced whether the buffer is instanced (optional)
  63016. * @param useBytes set to true if the stride in in bytes (optional)
  63017. */
  63018. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63019. /**
  63020. * Create a new VertexBuffer based on the current buffer
  63021. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63022. * @param offset defines offset in the buffer (0 by default)
  63023. * @param size defines the size in floats of attributes (position is 3 for instance)
  63024. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63025. * @param instanced defines if the vertex buffer contains indexed data
  63026. * @param useBytes defines if the offset and stride are in bytes
  63027. * @returns the new vertex buffer
  63028. */
  63029. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63030. /**
  63031. * Gets a boolean indicating if the Buffer is updatable?
  63032. * @returns true if the buffer is updatable
  63033. */
  63034. isUpdatable(): boolean;
  63035. /**
  63036. * Gets current buffer's data
  63037. * @returns a DataArray or null
  63038. */
  63039. getData(): Nullable<DataArray>;
  63040. /**
  63041. * Gets underlying native buffer
  63042. * @returns underlying native buffer
  63043. */
  63044. getBuffer(): Nullable<WebGLBuffer>;
  63045. /**
  63046. * Gets the stride in float32 units (i.e. byte stride / 4).
  63047. * May not be an integer if the byte stride is not divisible by 4.
  63048. * DEPRECATED. Use byteStride instead.
  63049. * @returns the stride in float32 units
  63050. */
  63051. getStrideSize(): number;
  63052. /**
  63053. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63054. * @param data defines the data to store
  63055. */
  63056. create(data?: Nullable<DataArray>): void;
  63057. /** @hidden */
  63058. _rebuild(): void;
  63059. /**
  63060. * Update current buffer data
  63061. * @param data defines the data to store
  63062. */
  63063. update(data: DataArray): void;
  63064. /**
  63065. * Updates the data directly.
  63066. * @param data the new data
  63067. * @param offset the new offset
  63068. * @param vertexCount the vertex count (optional)
  63069. * @param useBytes set to true if the offset is in bytes
  63070. */
  63071. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63072. /**
  63073. * Release all resources
  63074. */
  63075. dispose(): void;
  63076. }
  63077. /**
  63078. * Specialized buffer used to store vertex data
  63079. */
  63080. export class VertexBuffer {
  63081. /** @hidden */
  63082. _buffer: Buffer;
  63083. private _kind;
  63084. private _size;
  63085. private _ownsBuffer;
  63086. private _instanced;
  63087. private _instanceDivisor;
  63088. /**
  63089. * The byte type.
  63090. */
  63091. static readonly BYTE: number;
  63092. /**
  63093. * The unsigned byte type.
  63094. */
  63095. static readonly UNSIGNED_BYTE: number;
  63096. /**
  63097. * The short type.
  63098. */
  63099. static readonly SHORT: number;
  63100. /**
  63101. * The unsigned short type.
  63102. */
  63103. static readonly UNSIGNED_SHORT: number;
  63104. /**
  63105. * The integer type.
  63106. */
  63107. static readonly INT: number;
  63108. /**
  63109. * The unsigned integer type.
  63110. */
  63111. static readonly UNSIGNED_INT: number;
  63112. /**
  63113. * The float type.
  63114. */
  63115. static readonly FLOAT: number;
  63116. /**
  63117. * Gets or sets the instance divisor when in instanced mode
  63118. */
  63119. instanceDivisor: number;
  63120. /**
  63121. * Gets the byte stride.
  63122. */
  63123. readonly byteStride: number;
  63124. /**
  63125. * Gets the byte offset.
  63126. */
  63127. readonly byteOffset: number;
  63128. /**
  63129. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63130. */
  63131. readonly normalized: boolean;
  63132. /**
  63133. * Gets the data type of each component in the array.
  63134. */
  63135. readonly type: number;
  63136. /**
  63137. * Constructor
  63138. * @param engine the engine
  63139. * @param data the data to use for this vertex buffer
  63140. * @param kind the vertex buffer kind
  63141. * @param updatable whether the data is updatable
  63142. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63143. * @param stride the stride (optional)
  63144. * @param instanced whether the buffer is instanced (optional)
  63145. * @param offset the offset of the data (optional)
  63146. * @param size the number of components (optional)
  63147. * @param type the type of the component (optional)
  63148. * @param normalized whether the data contains normalized data (optional)
  63149. * @param useBytes set to true if stride and offset are in bytes (optional)
  63150. */
  63151. 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);
  63152. /** @hidden */
  63153. _rebuild(): void;
  63154. /**
  63155. * Returns the kind of the VertexBuffer (string)
  63156. * @returns a string
  63157. */
  63158. getKind(): string;
  63159. /**
  63160. * Gets a boolean indicating if the VertexBuffer is updatable?
  63161. * @returns true if the buffer is updatable
  63162. */
  63163. isUpdatable(): boolean;
  63164. /**
  63165. * Gets current buffer's data
  63166. * @returns a DataArray or null
  63167. */
  63168. getData(): Nullable<DataArray>;
  63169. /**
  63170. * Gets underlying native buffer
  63171. * @returns underlying native buffer
  63172. */
  63173. getBuffer(): Nullable<WebGLBuffer>;
  63174. /**
  63175. * Gets the stride in float32 units (i.e. byte stride / 4).
  63176. * May not be an integer if the byte stride is not divisible by 4.
  63177. * DEPRECATED. Use byteStride instead.
  63178. * @returns the stride in float32 units
  63179. */
  63180. getStrideSize(): number;
  63181. /**
  63182. * Returns the offset as a multiple of the type byte length.
  63183. * DEPRECATED. Use byteOffset instead.
  63184. * @returns the offset in bytes
  63185. */
  63186. getOffset(): number;
  63187. /**
  63188. * Returns the number of components per vertex attribute (integer)
  63189. * @returns the size in float
  63190. */
  63191. getSize(): number;
  63192. /**
  63193. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63194. * @returns true if this buffer is instanced
  63195. */
  63196. getIsInstanced(): boolean;
  63197. /**
  63198. * Returns the instancing divisor, zero for non-instanced (integer).
  63199. * @returns a number
  63200. */
  63201. getInstanceDivisor(): number;
  63202. /**
  63203. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63204. * @param data defines the data to store
  63205. */
  63206. create(data?: DataArray): void;
  63207. /**
  63208. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63209. * This function will create a new buffer if the current one is not updatable
  63210. * @param data defines the data to store
  63211. */
  63212. update(data: DataArray): void;
  63213. /**
  63214. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63215. * Returns the directly updated WebGLBuffer.
  63216. * @param data the new data
  63217. * @param offset the new offset
  63218. * @param useBytes set to true if the offset is in bytes
  63219. */
  63220. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63221. /**
  63222. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63223. */
  63224. dispose(): void;
  63225. /**
  63226. * Enumerates each value of this vertex buffer as numbers.
  63227. * @param count the number of values to enumerate
  63228. * @param callback the callback function called for each value
  63229. */
  63230. forEach(count: number, callback: (value: number, index: number) => void): void;
  63231. /**
  63232. * Positions
  63233. */
  63234. static readonly PositionKind: string;
  63235. /**
  63236. * Normals
  63237. */
  63238. static readonly NormalKind: string;
  63239. /**
  63240. * Tangents
  63241. */
  63242. static readonly TangentKind: string;
  63243. /**
  63244. * Texture coordinates
  63245. */
  63246. static readonly UVKind: string;
  63247. /**
  63248. * Texture coordinates 2
  63249. */
  63250. static readonly UV2Kind: string;
  63251. /**
  63252. * Texture coordinates 3
  63253. */
  63254. static readonly UV3Kind: string;
  63255. /**
  63256. * Texture coordinates 4
  63257. */
  63258. static readonly UV4Kind: string;
  63259. /**
  63260. * Texture coordinates 5
  63261. */
  63262. static readonly UV5Kind: string;
  63263. /**
  63264. * Texture coordinates 6
  63265. */
  63266. static readonly UV6Kind: string;
  63267. /**
  63268. * Colors
  63269. */
  63270. static readonly ColorKind: string;
  63271. /**
  63272. * Matrix indices (for bones)
  63273. */
  63274. static readonly MatricesIndicesKind: string;
  63275. /**
  63276. * Matrix weights (for bones)
  63277. */
  63278. static readonly MatricesWeightsKind: string;
  63279. /**
  63280. * Additional matrix indices (for bones)
  63281. */
  63282. static readonly MatricesIndicesExtraKind: string;
  63283. /**
  63284. * Additional matrix weights (for bones)
  63285. */
  63286. static readonly MatricesWeightsExtraKind: string;
  63287. /**
  63288. * Deduces the stride given a kind.
  63289. * @param kind The kind string to deduce
  63290. * @returns The deduced stride
  63291. */
  63292. static DeduceStride(kind: string): number;
  63293. /**
  63294. * Gets the byte length of the given type.
  63295. * @param type the type
  63296. * @returns the number of bytes
  63297. */
  63298. static GetTypeByteLength(type: number): number;
  63299. /**
  63300. * Enumerates each value of the given parameters as numbers.
  63301. * @param data the data to enumerate
  63302. * @param byteOffset the byte offset of the data
  63303. * @param byteStride the byte stride of the data
  63304. * @param componentCount the number of components per element
  63305. * @param componentType the type of the component
  63306. * @param count the total number of components
  63307. * @param normalized whether the data is normalized
  63308. * @param callback the callback function called for each value
  63309. */
  63310. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63311. private static _GetFloatValue;
  63312. }
  63313. }
  63314. declare module BABYLON {
  63315. /**
  63316. * Class representing spherical polynomial coefficients to the 3rd degree
  63317. */
  63318. export class SphericalPolynomial {
  63319. /**
  63320. * The x coefficients of the spherical polynomial
  63321. */
  63322. x: Vector3;
  63323. /**
  63324. * The y coefficients of the spherical polynomial
  63325. */
  63326. y: Vector3;
  63327. /**
  63328. * The z coefficients of the spherical polynomial
  63329. */
  63330. z: Vector3;
  63331. /**
  63332. * The xx coefficients of the spherical polynomial
  63333. */
  63334. xx: Vector3;
  63335. /**
  63336. * The yy coefficients of the spherical polynomial
  63337. */
  63338. yy: Vector3;
  63339. /**
  63340. * The zz coefficients of the spherical polynomial
  63341. */
  63342. zz: Vector3;
  63343. /**
  63344. * The xy coefficients of the spherical polynomial
  63345. */
  63346. xy: Vector3;
  63347. /**
  63348. * The yz coefficients of the spherical polynomial
  63349. */
  63350. yz: Vector3;
  63351. /**
  63352. * The zx coefficients of the spherical polynomial
  63353. */
  63354. zx: Vector3;
  63355. /**
  63356. * Adds an ambient color to the spherical polynomial
  63357. * @param color the color to add
  63358. */
  63359. addAmbient(color: Color3): void;
  63360. /**
  63361. * Scales the spherical polynomial by the given amount
  63362. * @param scale the amount to scale
  63363. */
  63364. scale(scale: number): void;
  63365. /**
  63366. * Gets the spherical polynomial from harmonics
  63367. * @param harmonics the spherical harmonics
  63368. * @returns the spherical polynomial
  63369. */
  63370. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63371. /**
  63372. * Constructs a spherical polynomial from an array.
  63373. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63374. * @returns the spherical polynomial
  63375. */
  63376. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63377. }
  63378. /**
  63379. * Class representing spherical harmonics coefficients to the 3rd degree
  63380. */
  63381. export class SphericalHarmonics {
  63382. /**
  63383. * The l0,0 coefficients of the spherical harmonics
  63384. */
  63385. l00: Vector3;
  63386. /**
  63387. * The l1,-1 coefficients of the spherical harmonics
  63388. */
  63389. l1_1: Vector3;
  63390. /**
  63391. * The l1,0 coefficients of the spherical harmonics
  63392. */
  63393. l10: Vector3;
  63394. /**
  63395. * The l1,1 coefficients of the spherical harmonics
  63396. */
  63397. l11: Vector3;
  63398. /**
  63399. * The l2,-2 coefficients of the spherical harmonics
  63400. */
  63401. l2_2: Vector3;
  63402. /**
  63403. * The l2,-1 coefficients of the spherical harmonics
  63404. */
  63405. l2_1: Vector3;
  63406. /**
  63407. * The l2,0 coefficients of the spherical harmonics
  63408. */
  63409. l20: Vector3;
  63410. /**
  63411. * The l2,1 coefficients of the spherical harmonics
  63412. */
  63413. l21: Vector3;
  63414. /**
  63415. * The l2,2 coefficients of the spherical harmonics
  63416. */
  63417. lL22: Vector3;
  63418. /**
  63419. * Adds a light to the spherical harmonics
  63420. * @param direction the direction of the light
  63421. * @param color the color of the light
  63422. * @param deltaSolidAngle the delta solid angle of the light
  63423. */
  63424. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63425. /**
  63426. * Scales the spherical harmonics by the given amount
  63427. * @param scale the amount to scale
  63428. */
  63429. scale(scale: number): void;
  63430. /**
  63431. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63432. *
  63433. * ```
  63434. * E_lm = A_l * L_lm
  63435. * ```
  63436. *
  63437. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63438. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63439. * the scaling factors are given in equation 9.
  63440. */
  63441. convertIncidentRadianceToIrradiance(): void;
  63442. /**
  63443. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63444. *
  63445. * ```
  63446. * L = (1/pi) * E * rho
  63447. * ```
  63448. *
  63449. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63450. */
  63451. convertIrradianceToLambertianRadiance(): void;
  63452. /**
  63453. * Gets the spherical harmonics from polynomial
  63454. * @param polynomial the spherical polynomial
  63455. * @returns the spherical harmonics
  63456. */
  63457. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63458. /**
  63459. * Constructs a spherical harmonics from an array.
  63460. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63461. * @returns the spherical harmonics
  63462. */
  63463. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63464. }
  63465. }
  63466. declare module BABYLON {
  63467. /**
  63468. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63469. */
  63470. export interface CubeMapInfo {
  63471. /**
  63472. * The pixel array for the front face.
  63473. * This is stored in format, left to right, up to down format.
  63474. */
  63475. front: Nullable<ArrayBufferView>;
  63476. /**
  63477. * The pixel array for the back face.
  63478. * This is stored in format, left to right, up to down format.
  63479. */
  63480. back: Nullable<ArrayBufferView>;
  63481. /**
  63482. * The pixel array for the left face.
  63483. * This is stored in format, left to right, up to down format.
  63484. */
  63485. left: Nullable<ArrayBufferView>;
  63486. /**
  63487. * The pixel array for the right face.
  63488. * This is stored in format, left to right, up to down format.
  63489. */
  63490. right: Nullable<ArrayBufferView>;
  63491. /**
  63492. * The pixel array for the up face.
  63493. * This is stored in format, left to right, up to down format.
  63494. */
  63495. up: Nullable<ArrayBufferView>;
  63496. /**
  63497. * The pixel array for the down face.
  63498. * This is stored in format, left to right, up to down format.
  63499. */
  63500. down: Nullable<ArrayBufferView>;
  63501. /**
  63502. * The size of the cubemap stored.
  63503. *
  63504. * Each faces will be size * size pixels.
  63505. */
  63506. size: number;
  63507. /**
  63508. * The format of the texture.
  63509. *
  63510. * RGBA, RGB.
  63511. */
  63512. format: number;
  63513. /**
  63514. * The type of the texture data.
  63515. *
  63516. * UNSIGNED_INT, FLOAT.
  63517. */
  63518. type: number;
  63519. /**
  63520. * Specifies whether the texture is in gamma space.
  63521. */
  63522. gammaSpace: boolean;
  63523. }
  63524. /**
  63525. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63526. */
  63527. export class PanoramaToCubeMapTools {
  63528. private static FACE_FRONT;
  63529. private static FACE_BACK;
  63530. private static FACE_RIGHT;
  63531. private static FACE_LEFT;
  63532. private static FACE_DOWN;
  63533. private static FACE_UP;
  63534. /**
  63535. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63536. *
  63537. * @param float32Array The source data.
  63538. * @param inputWidth The width of the input panorama.
  63539. * @param inputHeight The height of the input panorama.
  63540. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63541. * @return The cubemap data
  63542. */
  63543. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63544. private static CreateCubemapTexture;
  63545. private static CalcProjectionSpherical;
  63546. }
  63547. }
  63548. declare module BABYLON {
  63549. /**
  63550. * Helper class dealing with the extraction of spherical polynomial dataArray
  63551. * from a cube map.
  63552. */
  63553. export class CubeMapToSphericalPolynomialTools {
  63554. private static FileFaces;
  63555. /**
  63556. * Converts a texture to the according Spherical Polynomial data.
  63557. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63558. *
  63559. * @param texture The texture to extract the information from.
  63560. * @return The Spherical Polynomial data.
  63561. */
  63562. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63563. /**
  63564. * Converts a cubemap to the according Spherical Polynomial data.
  63565. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63566. *
  63567. * @param cubeInfo The Cube map to extract the information from.
  63568. * @return The Spherical Polynomial data.
  63569. */
  63570. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63571. }
  63572. }
  63573. declare module BABYLON {
  63574. /**
  63575. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63576. * during the life time of the application.
  63577. */
  63578. export class EngineStore {
  63579. /** Gets the list of created engines */
  63580. static Instances: Engine[];
  63581. /**
  63582. * Gets the latest created engine
  63583. */
  63584. static readonly LastCreatedEngine: Nullable<Engine>;
  63585. /**
  63586. * Gets the latest created scene
  63587. */
  63588. static readonly LastCreatedScene: Nullable<Scene>;
  63589. }
  63590. }
  63591. declare module BABYLON {
  63592. /**
  63593. * Define options used to create a render target texture
  63594. */
  63595. export class RenderTargetCreationOptions {
  63596. /**
  63597. * Specifies is mipmaps must be generated
  63598. */
  63599. generateMipMaps?: boolean;
  63600. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63601. generateDepthBuffer?: boolean;
  63602. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63603. generateStencilBuffer?: boolean;
  63604. /** Defines texture type (int by default) */
  63605. type?: number;
  63606. /** Defines sampling mode (trilinear by default) */
  63607. samplingMode?: number;
  63608. /** Defines format (RGBA by default) */
  63609. format?: number;
  63610. }
  63611. }
  63612. declare module BABYLON {
  63613. /**
  63614. * @hidden
  63615. **/
  63616. export class _AlphaState {
  63617. private _isAlphaBlendDirty;
  63618. private _isBlendFunctionParametersDirty;
  63619. private _isBlendEquationParametersDirty;
  63620. private _isBlendConstantsDirty;
  63621. private _alphaBlend;
  63622. private _blendFunctionParameters;
  63623. private _blendEquationParameters;
  63624. private _blendConstants;
  63625. /**
  63626. * Initializes the state.
  63627. */
  63628. constructor();
  63629. readonly isDirty: boolean;
  63630. alphaBlend: boolean;
  63631. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63632. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63633. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63634. reset(): void;
  63635. apply(gl: WebGLRenderingContext): void;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * @hidden
  63641. **/
  63642. export class _DepthCullingState {
  63643. private _isDepthTestDirty;
  63644. private _isDepthMaskDirty;
  63645. private _isDepthFuncDirty;
  63646. private _isCullFaceDirty;
  63647. private _isCullDirty;
  63648. private _isZOffsetDirty;
  63649. private _isFrontFaceDirty;
  63650. private _depthTest;
  63651. private _depthMask;
  63652. private _depthFunc;
  63653. private _cull;
  63654. private _cullFace;
  63655. private _zOffset;
  63656. private _frontFace;
  63657. /**
  63658. * Initializes the state.
  63659. */
  63660. constructor();
  63661. readonly isDirty: boolean;
  63662. zOffset: number;
  63663. cullFace: Nullable<number>;
  63664. cull: Nullable<boolean>;
  63665. depthFunc: Nullable<number>;
  63666. depthMask: boolean;
  63667. depthTest: boolean;
  63668. frontFace: Nullable<number>;
  63669. reset(): void;
  63670. apply(gl: WebGLRenderingContext): void;
  63671. }
  63672. }
  63673. declare module BABYLON {
  63674. /**
  63675. * @hidden
  63676. **/
  63677. export class _StencilState {
  63678. /** 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 */
  63679. static readonly ALWAYS: number;
  63680. /** Passed to stencilOperation to specify that stencil value must be kept */
  63681. static readonly KEEP: number;
  63682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63683. static readonly REPLACE: number;
  63684. private _isStencilTestDirty;
  63685. private _isStencilMaskDirty;
  63686. private _isStencilFuncDirty;
  63687. private _isStencilOpDirty;
  63688. private _stencilTest;
  63689. private _stencilMask;
  63690. private _stencilFunc;
  63691. private _stencilFuncRef;
  63692. private _stencilFuncMask;
  63693. private _stencilOpStencilFail;
  63694. private _stencilOpDepthFail;
  63695. private _stencilOpStencilDepthPass;
  63696. readonly isDirty: boolean;
  63697. stencilFunc: number;
  63698. stencilFuncRef: number;
  63699. stencilFuncMask: number;
  63700. stencilOpStencilFail: number;
  63701. stencilOpDepthFail: number;
  63702. stencilOpStencilDepthPass: number;
  63703. stencilMask: number;
  63704. stencilTest: boolean;
  63705. constructor();
  63706. reset(): void;
  63707. apply(gl: WebGLRenderingContext): void;
  63708. }
  63709. }
  63710. declare module BABYLON {
  63711. /**
  63712. * @hidden
  63713. **/
  63714. export class _TimeToken {
  63715. _startTimeQuery: Nullable<WebGLQuery>;
  63716. _endTimeQuery: Nullable<WebGLQuery>;
  63717. _timeElapsedQuery: Nullable<WebGLQuery>;
  63718. _timeElapsedQueryEnded: boolean;
  63719. }
  63720. }
  63721. declare module BABYLON {
  63722. /**
  63723. * Internal interface used to track InternalTexture already bound to the GL context
  63724. */
  63725. export interface IInternalTextureTracker {
  63726. /**
  63727. * Gets or set the previous tracker in the list
  63728. */
  63729. previous: Nullable<IInternalTextureTracker>;
  63730. /**
  63731. * Gets or set the next tracker in the list
  63732. */
  63733. next: Nullable<IInternalTextureTracker>;
  63734. }
  63735. /**
  63736. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63737. */
  63738. export class DummyInternalTextureTracker {
  63739. /**
  63740. * Gets or set the previous tracker in the list
  63741. */
  63742. previous: Nullable<IInternalTextureTracker>;
  63743. /**
  63744. * Gets or set the next tracker in the list
  63745. */
  63746. next: Nullable<IInternalTextureTracker>;
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. /**
  63751. * Class used to store data associated with WebGL texture data for the engine
  63752. * This class should not be used directly
  63753. */
  63754. export class InternalTexture implements IInternalTextureTracker {
  63755. /** hidden */
  63756. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63757. /**
  63758. * The source of the texture data is unknown
  63759. */
  63760. static DATASOURCE_UNKNOWN: number;
  63761. /**
  63762. * Texture data comes from an URL
  63763. */
  63764. static DATASOURCE_URL: number;
  63765. /**
  63766. * Texture data is only used for temporary storage
  63767. */
  63768. static DATASOURCE_TEMP: number;
  63769. /**
  63770. * Texture data comes from raw data (ArrayBuffer)
  63771. */
  63772. static DATASOURCE_RAW: number;
  63773. /**
  63774. * Texture content is dynamic (video or dynamic texture)
  63775. */
  63776. static DATASOURCE_DYNAMIC: number;
  63777. /**
  63778. * Texture content is generated by rendering to it
  63779. */
  63780. static DATASOURCE_RENDERTARGET: number;
  63781. /**
  63782. * Texture content is part of a multi render target process
  63783. */
  63784. static DATASOURCE_MULTIRENDERTARGET: number;
  63785. /**
  63786. * Texture data comes from a cube data file
  63787. */
  63788. static DATASOURCE_CUBE: number;
  63789. /**
  63790. * Texture data comes from a raw cube data
  63791. */
  63792. static DATASOURCE_CUBERAW: number;
  63793. /**
  63794. * Texture data come from a prefiltered cube data file
  63795. */
  63796. static DATASOURCE_CUBEPREFILTERED: number;
  63797. /**
  63798. * Texture content is raw 3D data
  63799. */
  63800. static DATASOURCE_RAW3D: number;
  63801. /**
  63802. * Texture content is a depth texture
  63803. */
  63804. static DATASOURCE_DEPTHTEXTURE: number;
  63805. /**
  63806. * Texture data comes from a raw cube data encoded with RGBD
  63807. */
  63808. static DATASOURCE_CUBERAW_RGBD: number;
  63809. /**
  63810. * Defines if the texture is ready
  63811. */
  63812. isReady: boolean;
  63813. /**
  63814. * Defines if the texture is a cube texture
  63815. */
  63816. isCube: boolean;
  63817. /**
  63818. * Defines if the texture contains 3D data
  63819. */
  63820. is3D: boolean;
  63821. /**
  63822. * Gets the URL used to load this texture
  63823. */
  63824. url: string;
  63825. /**
  63826. * Gets the sampling mode of the texture
  63827. */
  63828. samplingMode: number;
  63829. /**
  63830. * Gets a boolean indicating if the texture needs mipmaps generation
  63831. */
  63832. generateMipMaps: boolean;
  63833. /**
  63834. * Gets the number of samples used by the texture (WebGL2+ only)
  63835. */
  63836. samples: number;
  63837. /**
  63838. * Gets the type of the texture (int, float...)
  63839. */
  63840. type: number;
  63841. /**
  63842. * Gets the format of the texture (RGB, RGBA...)
  63843. */
  63844. format: number;
  63845. /**
  63846. * Observable called when the texture is loaded
  63847. */
  63848. onLoadedObservable: Observable<InternalTexture>;
  63849. /**
  63850. * Gets the width of the texture
  63851. */
  63852. width: number;
  63853. /**
  63854. * Gets the height of the texture
  63855. */
  63856. height: number;
  63857. /**
  63858. * Gets the depth of the texture
  63859. */
  63860. depth: number;
  63861. /**
  63862. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63863. */
  63864. baseWidth: number;
  63865. /**
  63866. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63867. */
  63868. baseHeight: number;
  63869. /**
  63870. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63871. */
  63872. baseDepth: number;
  63873. /**
  63874. * Gets a boolean indicating if the texture is inverted on Y axis
  63875. */
  63876. invertY: boolean;
  63877. /**
  63878. * Gets or set the previous tracker in the list
  63879. */
  63880. previous: Nullable<IInternalTextureTracker>;
  63881. /**
  63882. * Gets or set the next tracker in the list
  63883. */
  63884. next: Nullable<IInternalTextureTracker>;
  63885. /** @hidden */
  63886. _invertVScale: boolean;
  63887. /** @hidden */
  63888. _initialSlot: number;
  63889. /** @hidden */
  63890. _designatedSlot: number;
  63891. /** @hidden */
  63892. _dataSource: number;
  63893. /** @hidden */
  63894. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63895. /** @hidden */
  63896. _bufferView: Nullable<ArrayBufferView>;
  63897. /** @hidden */
  63898. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63899. /** @hidden */
  63900. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63901. /** @hidden */
  63902. _size: number;
  63903. /** @hidden */
  63904. _extension: string;
  63905. /** @hidden */
  63906. _files: Nullable<string[]>;
  63907. /** @hidden */
  63908. _workingCanvas: HTMLCanvasElement;
  63909. /** @hidden */
  63910. _workingContext: CanvasRenderingContext2D;
  63911. /** @hidden */
  63912. _framebuffer: Nullable<WebGLFramebuffer>;
  63913. /** @hidden */
  63914. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63915. /** @hidden */
  63916. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63917. /** @hidden */
  63918. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63919. /** @hidden */
  63920. _attachments: Nullable<number[]>;
  63921. /** @hidden */
  63922. _cachedCoordinatesMode: Nullable<number>;
  63923. /** @hidden */
  63924. _cachedWrapU: Nullable<number>;
  63925. /** @hidden */
  63926. _cachedWrapV: Nullable<number>;
  63927. /** @hidden */
  63928. _cachedWrapR: Nullable<number>;
  63929. /** @hidden */
  63930. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63931. /** @hidden */
  63932. _isDisabled: boolean;
  63933. /** @hidden */
  63934. _compression: Nullable<string>;
  63935. /** @hidden */
  63936. _generateStencilBuffer: boolean;
  63937. /** @hidden */
  63938. _generateDepthBuffer: boolean;
  63939. /** @hidden */
  63940. _comparisonFunction: number;
  63941. /** @hidden */
  63942. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63943. /** @hidden */
  63944. _lodGenerationScale: number;
  63945. /** @hidden */
  63946. _lodGenerationOffset: number;
  63947. /** @hidden */
  63948. _lodTextureHigh: BaseTexture;
  63949. /** @hidden */
  63950. _lodTextureMid: BaseTexture;
  63951. /** @hidden */
  63952. _lodTextureLow: BaseTexture;
  63953. /** @hidden */
  63954. _isRGBD: boolean;
  63955. /** @hidden */
  63956. _webGLTexture: Nullable<WebGLTexture>;
  63957. /** @hidden */
  63958. _references: number;
  63959. private _engine;
  63960. /**
  63961. * Gets the Engine the texture belongs to.
  63962. * @returns The babylon engine
  63963. */
  63964. getEngine(): Engine;
  63965. /**
  63966. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63967. */
  63968. readonly dataSource: number;
  63969. /**
  63970. * Creates a new InternalTexture
  63971. * @param engine defines the engine to use
  63972. * @param dataSource defines the type of data that will be used
  63973. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63974. */
  63975. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63976. /**
  63977. * Increments the number of references (ie. the number of Texture that point to it)
  63978. */
  63979. incrementReferences(): void;
  63980. /**
  63981. * Change the size of the texture (not the size of the content)
  63982. * @param width defines the new width
  63983. * @param height defines the new height
  63984. * @param depth defines the new depth (1 by default)
  63985. */
  63986. updateSize(width: int, height: int, depth?: int): void;
  63987. /** @hidden */
  63988. _rebuild(): void;
  63989. /** @hidden */
  63990. _swapAndDie(target: InternalTexture): void;
  63991. /**
  63992. * Dispose the current allocated resources
  63993. */
  63994. dispose(): void;
  63995. }
  63996. }
  63997. declare module BABYLON {
  63998. /**
  63999. * This represents the main contract an easing function should follow.
  64000. * Easing functions are used throughout the animation system.
  64001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64002. */
  64003. export interface IEasingFunction {
  64004. /**
  64005. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64006. * of the easing function.
  64007. * The link below provides some of the most common examples of easing functions.
  64008. * @see https://easings.net/
  64009. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64010. * @returns the corresponding value on the curve defined by the easing function
  64011. */
  64012. ease(gradient: number): number;
  64013. }
  64014. /**
  64015. * Base class used for every default easing function.
  64016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64017. */
  64018. export class EasingFunction implements IEasingFunction {
  64019. /**
  64020. * Interpolation follows the mathematical formula associated with the easing function.
  64021. */
  64022. static readonly EASINGMODE_EASEIN: number;
  64023. /**
  64024. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64025. */
  64026. static readonly EASINGMODE_EASEOUT: number;
  64027. /**
  64028. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64029. */
  64030. static readonly EASINGMODE_EASEINOUT: number;
  64031. private _easingMode;
  64032. /**
  64033. * Sets the easing mode of the current function.
  64034. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64035. */
  64036. setEasingMode(easingMode: number): void;
  64037. /**
  64038. * Gets the current easing mode.
  64039. * @returns the easing mode
  64040. */
  64041. getEasingMode(): number;
  64042. /**
  64043. * @hidden
  64044. */
  64045. easeInCore(gradient: number): number;
  64046. /**
  64047. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64048. * of the easing function.
  64049. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64050. * @returns the corresponding value on the curve defined by the easing function
  64051. */
  64052. ease(gradient: number): number;
  64053. }
  64054. /**
  64055. * Easing function with a circle shape (see link below).
  64056. * @see https://easings.net/#easeInCirc
  64057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64058. */
  64059. export class CircleEase extends EasingFunction implements IEasingFunction {
  64060. /** @hidden */
  64061. easeInCore(gradient: number): number;
  64062. }
  64063. /**
  64064. * Easing function with a ease back shape (see link below).
  64065. * @see https://easings.net/#easeInBack
  64066. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64067. */
  64068. export class BackEase extends EasingFunction implements IEasingFunction {
  64069. /** Defines the amplitude of the function */
  64070. amplitude: number;
  64071. /**
  64072. * Instantiates a back ease easing
  64073. * @see https://easings.net/#easeInBack
  64074. * @param amplitude Defines the amplitude of the function
  64075. */
  64076. constructor(
  64077. /** Defines the amplitude of the function */
  64078. amplitude?: number);
  64079. /** @hidden */
  64080. easeInCore(gradient: number): number;
  64081. }
  64082. /**
  64083. * Easing function with a bouncing shape (see link below).
  64084. * @see https://easings.net/#easeInBounce
  64085. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64086. */
  64087. export class BounceEase extends EasingFunction implements IEasingFunction {
  64088. /** Defines the number of bounces */
  64089. bounces: number;
  64090. /** Defines the amplitude of the bounce */
  64091. bounciness: number;
  64092. /**
  64093. * Instantiates a bounce easing
  64094. * @see https://easings.net/#easeInBounce
  64095. * @param bounces Defines the number of bounces
  64096. * @param bounciness Defines the amplitude of the bounce
  64097. */
  64098. constructor(
  64099. /** Defines the number of bounces */
  64100. bounces?: number,
  64101. /** Defines the amplitude of the bounce */
  64102. bounciness?: number);
  64103. /** @hidden */
  64104. easeInCore(gradient: number): number;
  64105. }
  64106. /**
  64107. * Easing function with a power of 3 shape (see link below).
  64108. * @see https://easings.net/#easeInCubic
  64109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64110. */
  64111. export class CubicEase extends EasingFunction implements IEasingFunction {
  64112. /** @hidden */
  64113. easeInCore(gradient: number): number;
  64114. }
  64115. /**
  64116. * Easing function with an elastic shape (see link below).
  64117. * @see https://easings.net/#easeInElastic
  64118. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64119. */
  64120. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64121. /** Defines the number of oscillations*/
  64122. oscillations: number;
  64123. /** Defines the amplitude of the oscillations*/
  64124. springiness: number;
  64125. /**
  64126. * Instantiates an elastic easing function
  64127. * @see https://easings.net/#easeInElastic
  64128. * @param oscillations Defines the number of oscillations
  64129. * @param springiness Defines the amplitude of the oscillations
  64130. */
  64131. constructor(
  64132. /** Defines the number of oscillations*/
  64133. oscillations?: number,
  64134. /** Defines the amplitude of the oscillations*/
  64135. springiness?: number);
  64136. /** @hidden */
  64137. easeInCore(gradient: number): number;
  64138. }
  64139. /**
  64140. * Easing function with an exponential shape (see link below).
  64141. * @see https://easings.net/#easeInExpo
  64142. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64143. */
  64144. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64145. /** Defines the exponent of the function */
  64146. exponent: number;
  64147. /**
  64148. * Instantiates an exponential easing function
  64149. * @see https://easings.net/#easeInExpo
  64150. * @param exponent Defines the exponent of the function
  64151. */
  64152. constructor(
  64153. /** Defines the exponent of the function */
  64154. exponent?: number);
  64155. /** @hidden */
  64156. easeInCore(gradient: number): number;
  64157. }
  64158. /**
  64159. * Easing function with a power shape (see link below).
  64160. * @see https://easings.net/#easeInQuad
  64161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64162. */
  64163. export class PowerEase extends EasingFunction implements IEasingFunction {
  64164. /** Defines the power of the function */
  64165. power: number;
  64166. /**
  64167. * Instantiates an power base easing function
  64168. * @see https://easings.net/#easeInQuad
  64169. * @param power Defines the power of the function
  64170. */
  64171. constructor(
  64172. /** Defines the power of the function */
  64173. power?: number);
  64174. /** @hidden */
  64175. easeInCore(gradient: number): number;
  64176. }
  64177. /**
  64178. * Easing function with a power of 2 shape (see link below).
  64179. * @see https://easings.net/#easeInQuad
  64180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64181. */
  64182. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64183. /** @hidden */
  64184. easeInCore(gradient: number): number;
  64185. }
  64186. /**
  64187. * Easing function with a power of 4 shape (see link below).
  64188. * @see https://easings.net/#easeInQuart
  64189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64190. */
  64191. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64192. /** @hidden */
  64193. easeInCore(gradient: number): number;
  64194. }
  64195. /**
  64196. * Easing function with a power of 5 shape (see link below).
  64197. * @see https://easings.net/#easeInQuint
  64198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64199. */
  64200. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64201. /** @hidden */
  64202. easeInCore(gradient: number): number;
  64203. }
  64204. /**
  64205. * Easing function with a sin shape (see link below).
  64206. * @see https://easings.net/#easeInSine
  64207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64208. */
  64209. export class SineEase extends EasingFunction implements IEasingFunction {
  64210. /** @hidden */
  64211. easeInCore(gradient: number): number;
  64212. }
  64213. /**
  64214. * Easing function with a bezier shape (see link below).
  64215. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64217. */
  64218. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64219. /** Defines the x component of the start tangent in the bezier curve */
  64220. x1: number;
  64221. /** Defines the y component of the start tangent in the bezier curve */
  64222. y1: number;
  64223. /** Defines the x component of the end tangent in the bezier curve */
  64224. x2: number;
  64225. /** Defines the y component of the end tangent in the bezier curve */
  64226. y2: number;
  64227. /**
  64228. * Instantiates a bezier function
  64229. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64230. * @param x1 Defines the x component of the start tangent in the bezier curve
  64231. * @param y1 Defines the y component of the start tangent in the bezier curve
  64232. * @param x2 Defines the x component of the end tangent in the bezier curve
  64233. * @param y2 Defines the y component of the end tangent in the bezier curve
  64234. */
  64235. constructor(
  64236. /** Defines the x component of the start tangent in the bezier curve */
  64237. x1?: number,
  64238. /** Defines the y component of the start tangent in the bezier curve */
  64239. y1?: number,
  64240. /** Defines the x component of the end tangent in the bezier curve */
  64241. x2?: number,
  64242. /** Defines the y component of the end tangent in the bezier curve */
  64243. y2?: number);
  64244. /** @hidden */
  64245. easeInCore(gradient: number): number;
  64246. }
  64247. }
  64248. declare module BABYLON {
  64249. /**
  64250. * Defines an interface which represents an animation key frame
  64251. */
  64252. export interface IAnimationKey {
  64253. /**
  64254. * Frame of the key frame
  64255. */
  64256. frame: number;
  64257. /**
  64258. * Value at the specifies key frame
  64259. */
  64260. value: any;
  64261. /**
  64262. * The input tangent for the cubic hermite spline
  64263. */
  64264. inTangent?: any;
  64265. /**
  64266. * The output tangent for the cubic hermite spline
  64267. */
  64268. outTangent?: any;
  64269. /**
  64270. * The animation interpolation type
  64271. */
  64272. interpolation?: AnimationKeyInterpolation;
  64273. }
  64274. /**
  64275. * Enum for the animation key frame interpolation type
  64276. */
  64277. export enum AnimationKeyInterpolation {
  64278. /**
  64279. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64280. */
  64281. STEP = 1
  64282. }
  64283. }
  64284. declare module BABYLON {
  64285. /**
  64286. * Represents the range of an animation
  64287. */
  64288. export class AnimationRange {
  64289. /**The name of the animation range**/
  64290. name: string;
  64291. /**The starting frame of the animation */
  64292. from: number;
  64293. /**The ending frame of the animation*/
  64294. to: number;
  64295. /**
  64296. * Initializes the range of an animation
  64297. * @param name The name of the animation range
  64298. * @param from The starting frame of the animation
  64299. * @param to The ending frame of the animation
  64300. */
  64301. constructor(
  64302. /**The name of the animation range**/
  64303. name: string,
  64304. /**The starting frame of the animation */
  64305. from: number,
  64306. /**The ending frame of the animation*/
  64307. to: number);
  64308. /**
  64309. * Makes a copy of the animation range
  64310. * @returns A copy of the animation range
  64311. */
  64312. clone(): AnimationRange;
  64313. }
  64314. }
  64315. declare module BABYLON {
  64316. /**
  64317. * Composed of a frame, and an action function
  64318. */
  64319. export class AnimationEvent {
  64320. /** The frame for which the event is triggered **/
  64321. frame: number;
  64322. /** The event to perform when triggered **/
  64323. action: (currentFrame: number) => void;
  64324. /** Specifies if the event should be triggered only once**/
  64325. onlyOnce?: boolean | undefined;
  64326. /**
  64327. * Specifies if the animation event is done
  64328. */
  64329. isDone: boolean;
  64330. /**
  64331. * Initializes the animation event
  64332. * @param frame The frame for which the event is triggered
  64333. * @param action The event to perform when triggered
  64334. * @param onlyOnce Specifies if the event should be triggered only once
  64335. */
  64336. constructor(
  64337. /** The frame for which the event is triggered **/
  64338. frame: number,
  64339. /** The event to perform when triggered **/
  64340. action: (currentFrame: number) => void,
  64341. /** Specifies if the event should be triggered only once**/
  64342. onlyOnce?: boolean | undefined);
  64343. /** @hidden */
  64344. _clone(): AnimationEvent;
  64345. }
  64346. }
  64347. declare module BABYLON {
  64348. /**
  64349. * Interface used to define a behavior
  64350. */
  64351. export interface Behavior<T> {
  64352. /** gets or sets behavior's name */
  64353. name: string;
  64354. /**
  64355. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64356. */
  64357. init(): void;
  64358. /**
  64359. * Called when the behavior is attached to a target
  64360. * @param target defines the target where the behavior is attached to
  64361. */
  64362. attach(target: T): void;
  64363. /**
  64364. * Called when the behavior is detached from its target
  64365. */
  64366. detach(): void;
  64367. }
  64368. /**
  64369. * Interface implemented by classes supporting behaviors
  64370. */
  64371. export interface IBehaviorAware<T> {
  64372. /**
  64373. * Attach a behavior
  64374. * @param behavior defines the behavior to attach
  64375. * @returns the current host
  64376. */
  64377. addBehavior(behavior: Behavior<T>): T;
  64378. /**
  64379. * Remove a behavior from the current object
  64380. * @param behavior defines the behavior to detach
  64381. * @returns the current host
  64382. */
  64383. removeBehavior(behavior: Behavior<T>): T;
  64384. /**
  64385. * Gets a behavior using its name to search
  64386. * @param name defines the name to search
  64387. * @returns the behavior or null if not found
  64388. */
  64389. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64390. }
  64391. }
  64392. declare module BABYLON {
  64393. /**
  64394. * @hidden
  64395. */
  64396. export class IntersectionInfo {
  64397. bu: Nullable<number>;
  64398. bv: Nullable<number>;
  64399. distance: number;
  64400. faceId: number;
  64401. subMeshId: number;
  64402. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64403. }
  64404. }
  64405. declare module BABYLON {
  64406. /**
  64407. * Class used to store bounding sphere information
  64408. */
  64409. export class BoundingSphere {
  64410. /**
  64411. * Gets the center of the bounding sphere in local space
  64412. */
  64413. readonly center: Vector3;
  64414. /**
  64415. * Radius of the bounding sphere in local space
  64416. */
  64417. radius: number;
  64418. /**
  64419. * Gets the center of the bounding sphere in world space
  64420. */
  64421. readonly centerWorld: Vector3;
  64422. /**
  64423. * Radius of the bounding sphere in world space
  64424. */
  64425. radiusWorld: number;
  64426. /**
  64427. * Gets the minimum vector in local space
  64428. */
  64429. readonly minimum: Vector3;
  64430. /**
  64431. * Gets the maximum vector in local space
  64432. */
  64433. readonly maximum: Vector3;
  64434. private _worldMatrix;
  64435. private static readonly TmpVector3;
  64436. /**
  64437. * Creates a new bounding sphere
  64438. * @param min defines the minimum vector (in local space)
  64439. * @param max defines the maximum vector (in local space)
  64440. * @param worldMatrix defines the new world matrix
  64441. */
  64442. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64443. /**
  64444. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64445. * @param min defines the new minimum vector (in local space)
  64446. * @param max defines the new maximum vector (in local space)
  64447. * @param worldMatrix defines the new world matrix
  64448. */
  64449. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64450. /**
  64451. * Scale the current bounding sphere by applying a scale factor
  64452. * @param factor defines the scale factor to apply
  64453. * @returns the current bounding box
  64454. */
  64455. scale(factor: number): BoundingSphere;
  64456. /**
  64457. * Gets the world matrix of the bounding box
  64458. * @returns a matrix
  64459. */
  64460. getWorldMatrix(): DeepImmutable<Matrix>;
  64461. /** @hidden */
  64462. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64463. /**
  64464. * Tests if the bounding sphere is intersecting the frustum planes
  64465. * @param frustumPlanes defines the frustum planes to test
  64466. * @returns true if there is an intersection
  64467. */
  64468. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64469. /**
  64470. * Tests if the bounding sphere center is in between the frustum planes.
  64471. * Used for optimistic fast inclusion.
  64472. * @param frustumPlanes defines the frustum planes to test
  64473. * @returns true if the sphere center is in between the frustum planes
  64474. */
  64475. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64476. /**
  64477. * Tests if a point is inside the bounding sphere
  64478. * @param point defines the point to test
  64479. * @returns true if the point is inside the bounding sphere
  64480. */
  64481. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64482. /**
  64483. * Checks if two sphere intersct
  64484. * @param sphere0 sphere 0
  64485. * @param sphere1 sphere 1
  64486. * @returns true if the speres intersect
  64487. */
  64488. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64489. }
  64490. }
  64491. declare module BABYLON {
  64492. /**
  64493. * Class used to store bounding box information
  64494. */
  64495. export class BoundingBox implements ICullable {
  64496. /**
  64497. * Gets the 8 vectors representing the bounding box in local space
  64498. */
  64499. readonly vectors: Vector3[];
  64500. /**
  64501. * Gets the center of the bounding box in local space
  64502. */
  64503. readonly center: Vector3;
  64504. /**
  64505. * Gets the center of the bounding box in world space
  64506. */
  64507. readonly centerWorld: Vector3;
  64508. /**
  64509. * Gets the extend size in local space
  64510. */
  64511. readonly extendSize: Vector3;
  64512. /**
  64513. * Gets the extend size in world space
  64514. */
  64515. readonly extendSizeWorld: Vector3;
  64516. /**
  64517. * Gets the OBB (object bounding box) directions
  64518. */
  64519. readonly directions: Vector3[];
  64520. /**
  64521. * Gets the 8 vectors representing the bounding box in world space
  64522. */
  64523. readonly vectorsWorld: Vector3[];
  64524. /**
  64525. * Gets the minimum vector in world space
  64526. */
  64527. readonly minimumWorld: Vector3;
  64528. /**
  64529. * Gets the maximum vector in world space
  64530. */
  64531. readonly maximumWorld: Vector3;
  64532. /**
  64533. * Gets the minimum vector in local space
  64534. */
  64535. readonly minimum: Vector3;
  64536. /**
  64537. * Gets the maximum vector in local space
  64538. */
  64539. readonly maximum: Vector3;
  64540. private _worldMatrix;
  64541. private static readonly TmpVector3;
  64542. /**
  64543. * @hidden
  64544. */
  64545. _tag: number;
  64546. /**
  64547. * Creates a new bounding box
  64548. * @param min defines the minimum vector (in local space)
  64549. * @param max defines the maximum vector (in local space)
  64550. * @param worldMatrix defines the new world matrix
  64551. */
  64552. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64553. /**
  64554. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64555. * @param min defines the new minimum vector (in local space)
  64556. * @param max defines the new maximum vector (in local space)
  64557. * @param worldMatrix defines the new world matrix
  64558. */
  64559. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64560. /**
  64561. * Scale the current bounding box by applying a scale factor
  64562. * @param factor defines the scale factor to apply
  64563. * @returns the current bounding box
  64564. */
  64565. scale(factor: number): BoundingBox;
  64566. /**
  64567. * Gets the world matrix of the bounding box
  64568. * @returns a matrix
  64569. */
  64570. getWorldMatrix(): DeepImmutable<Matrix>;
  64571. /** @hidden */
  64572. _update(world: DeepImmutable<Matrix>): void;
  64573. /**
  64574. * Tests if the bounding box is intersecting the frustum planes
  64575. * @param frustumPlanes defines the frustum planes to test
  64576. * @returns true if there is an intersection
  64577. */
  64578. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64579. /**
  64580. * Tests if the bounding box is entirely inside the frustum planes
  64581. * @param frustumPlanes defines the frustum planes to test
  64582. * @returns true if there is an inclusion
  64583. */
  64584. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64585. /**
  64586. * Tests if a point is inside the bounding box
  64587. * @param point defines the point to test
  64588. * @returns true if the point is inside the bounding box
  64589. */
  64590. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64591. /**
  64592. * Tests if the bounding box intersects with a bounding sphere
  64593. * @param sphere defines the sphere to test
  64594. * @returns true if there is an intersection
  64595. */
  64596. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64597. /**
  64598. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64599. * @param min defines the min vector to use
  64600. * @param max defines the max vector to use
  64601. * @returns true if there is an intersection
  64602. */
  64603. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64604. /**
  64605. * Tests if two bounding boxes are intersections
  64606. * @param box0 defines the first box to test
  64607. * @param box1 defines the second box to test
  64608. * @returns true if there is an intersection
  64609. */
  64610. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64611. /**
  64612. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64613. * @param minPoint defines the minimum vector of the bounding box
  64614. * @param maxPoint defines the maximum vector of the bounding box
  64615. * @param sphereCenter defines the sphere center
  64616. * @param sphereRadius defines the sphere radius
  64617. * @returns true if there is an intersection
  64618. */
  64619. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64620. /**
  64621. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64622. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64623. * @param frustumPlanes defines the frustum planes to test
  64624. * @return true if there is an inclusion
  64625. */
  64626. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64627. /**
  64628. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64629. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64630. * @param frustumPlanes defines the frustum planes to test
  64631. * @return true if there is an intersection
  64632. */
  64633. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64634. }
  64635. }
  64636. declare module BABYLON {
  64637. /** @hidden */
  64638. export class Collider {
  64639. /** Define if a collision was found */
  64640. collisionFound: boolean;
  64641. /**
  64642. * Define last intersection point in local space
  64643. */
  64644. intersectionPoint: Vector3;
  64645. /**
  64646. * Define last collided mesh
  64647. */
  64648. collidedMesh: Nullable<AbstractMesh>;
  64649. private _collisionPoint;
  64650. private _planeIntersectionPoint;
  64651. private _tempVector;
  64652. private _tempVector2;
  64653. private _tempVector3;
  64654. private _tempVector4;
  64655. private _edge;
  64656. private _baseToVertex;
  64657. private _destinationPoint;
  64658. private _slidePlaneNormal;
  64659. private _displacementVector;
  64660. /** @hidden */
  64661. _radius: Vector3;
  64662. /** @hidden */
  64663. _retry: number;
  64664. private _velocity;
  64665. private _basePoint;
  64666. private _epsilon;
  64667. /** @hidden */
  64668. _velocityWorldLength: number;
  64669. /** @hidden */
  64670. _basePointWorld: Vector3;
  64671. private _velocityWorld;
  64672. private _normalizedVelocity;
  64673. /** @hidden */
  64674. _initialVelocity: Vector3;
  64675. /** @hidden */
  64676. _initialPosition: Vector3;
  64677. private _nearestDistance;
  64678. private _collisionMask;
  64679. collisionMask: number;
  64680. /**
  64681. * Gets the plane normal used to compute the sliding response (in local space)
  64682. */
  64683. readonly slidePlaneNormal: Vector3;
  64684. /** @hidden */
  64685. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64686. /** @hidden */
  64687. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64688. /** @hidden */
  64689. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64690. /** @hidden */
  64691. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64692. /** @hidden */
  64693. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64694. /** @hidden */
  64695. _getResponse(pos: Vector3, vel: Vector3): void;
  64696. }
  64697. }
  64698. declare module BABYLON {
  64699. /**
  64700. * Interface for cullable objects
  64701. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64702. */
  64703. export interface ICullable {
  64704. /**
  64705. * Checks if the object or part of the object is in the frustum
  64706. * @param frustumPlanes Camera near/planes
  64707. * @returns true if the object is in frustum otherwise false
  64708. */
  64709. isInFrustum(frustumPlanes: Plane[]): boolean;
  64710. /**
  64711. * Checks if a cullable object (mesh...) is in the camera frustum
  64712. * Unlike isInFrustum this cheks the full bounding box
  64713. * @param frustumPlanes Camera near/planes
  64714. * @returns true if the object is in frustum otherwise false
  64715. */
  64716. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64717. }
  64718. /**
  64719. * Info for a bounding data of a mesh
  64720. */
  64721. export class BoundingInfo implements ICullable {
  64722. /**
  64723. * Bounding box for the mesh
  64724. */
  64725. readonly boundingBox: BoundingBox;
  64726. /**
  64727. * Bounding sphere for the mesh
  64728. */
  64729. readonly boundingSphere: BoundingSphere;
  64730. private _isLocked;
  64731. private static readonly TmpVector3;
  64732. /**
  64733. * Constructs bounding info
  64734. * @param minimum min vector of the bounding box/sphere
  64735. * @param maximum max vector of the bounding box/sphere
  64736. * @param worldMatrix defines the new world matrix
  64737. */
  64738. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64739. /**
  64740. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64741. * @param min defines the new minimum vector (in local space)
  64742. * @param max defines the new maximum vector (in local space)
  64743. * @param worldMatrix defines the new world matrix
  64744. */
  64745. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64746. /**
  64747. * min vector of the bounding box/sphere
  64748. */
  64749. readonly minimum: Vector3;
  64750. /**
  64751. * max vector of the bounding box/sphere
  64752. */
  64753. readonly maximum: Vector3;
  64754. /**
  64755. * If the info is locked and won't be updated to avoid perf overhead
  64756. */
  64757. isLocked: boolean;
  64758. /**
  64759. * Updates the bounding sphere and box
  64760. * @param world world matrix to be used to update
  64761. */
  64762. update(world: DeepImmutable<Matrix>): void;
  64763. /**
  64764. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64765. * @param center New center of the bounding info
  64766. * @param extend New extend of the bounding info
  64767. * @returns the current bounding info
  64768. */
  64769. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64770. /**
  64771. * Scale the current bounding info by applying a scale factor
  64772. * @param factor defines the scale factor to apply
  64773. * @returns the current bounding info
  64774. */
  64775. scale(factor: number): BoundingInfo;
  64776. /**
  64777. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64778. * @param frustumPlanes defines the frustum to test
  64779. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64780. * @returns true if the bounding info is in the frustum planes
  64781. */
  64782. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64783. /**
  64784. * Gets the world distance between the min and max points of the bounding box
  64785. */
  64786. readonly diagonalLength: number;
  64787. /**
  64788. * Checks if a cullable object (mesh...) is in the camera frustum
  64789. * Unlike isInFrustum this cheks the full bounding box
  64790. * @param frustumPlanes Camera near/planes
  64791. * @returns true if the object is in frustum otherwise false
  64792. */
  64793. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64794. /** @hidden */
  64795. _checkCollision(collider: Collider): boolean;
  64796. /**
  64797. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64798. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64799. * @param point the point to check intersection with
  64800. * @returns if the point intersects
  64801. */
  64802. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64803. /**
  64804. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64805. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64806. * @param boundingInfo the bounding info to check intersection with
  64807. * @param precise if the intersection should be done using OBB
  64808. * @returns if the bounding info intersects
  64809. */
  64810. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64811. }
  64812. }
  64813. declare module BABYLON {
  64814. /**
  64815. * Defines an array and its length.
  64816. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64817. */
  64818. export interface ISmartArrayLike<T> {
  64819. /**
  64820. * The data of the array.
  64821. */
  64822. data: Array<T>;
  64823. /**
  64824. * The active length of the array.
  64825. */
  64826. length: number;
  64827. }
  64828. /**
  64829. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64830. */
  64831. export class SmartArray<T> implements ISmartArrayLike<T> {
  64832. /**
  64833. * The full set of data from the array.
  64834. */
  64835. data: Array<T>;
  64836. /**
  64837. * The active length of the array.
  64838. */
  64839. length: number;
  64840. protected _id: number;
  64841. /**
  64842. * Instantiates a Smart Array.
  64843. * @param capacity defines the default capacity of the array.
  64844. */
  64845. constructor(capacity: number);
  64846. /**
  64847. * Pushes a value at the end of the active data.
  64848. * @param value defines the object to push in the array.
  64849. */
  64850. push(value: T): void;
  64851. /**
  64852. * Iterates over the active data and apply the lambda to them.
  64853. * @param func defines the action to apply on each value.
  64854. */
  64855. forEach(func: (content: T) => void): void;
  64856. /**
  64857. * Sorts the full sets of data.
  64858. * @param compareFn defines the comparison function to apply.
  64859. */
  64860. sort(compareFn: (a: T, b: T) => number): void;
  64861. /**
  64862. * Resets the active data to an empty array.
  64863. */
  64864. reset(): void;
  64865. /**
  64866. * Releases all the data from the array as well as the array.
  64867. */
  64868. dispose(): void;
  64869. /**
  64870. * Concats the active data with a given array.
  64871. * @param array defines the data to concatenate with.
  64872. */
  64873. concat(array: any): void;
  64874. /**
  64875. * Returns the position of a value in the active data.
  64876. * @param value defines the value to find the index for
  64877. * @returns the index if found in the active data otherwise -1
  64878. */
  64879. indexOf(value: T): number;
  64880. /**
  64881. * Returns whether an element is part of the active data.
  64882. * @param value defines the value to look for
  64883. * @returns true if found in the active data otherwise false
  64884. */
  64885. contains(value: T): boolean;
  64886. private static _GlobalId;
  64887. }
  64888. /**
  64889. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64890. * The data in this array can only be present once
  64891. */
  64892. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64893. private _duplicateId;
  64894. /**
  64895. * Pushes a value at the end of the active data.
  64896. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64897. * @param value defines the object to push in the array.
  64898. */
  64899. push(value: T): void;
  64900. /**
  64901. * Pushes a value at the end of the active data.
  64902. * If the data is already present, it won t be added again
  64903. * @param value defines the object to push in the array.
  64904. * @returns true if added false if it was already present
  64905. */
  64906. pushNoDuplicate(value: T): boolean;
  64907. /**
  64908. * Resets the active data to an empty array.
  64909. */
  64910. reset(): void;
  64911. /**
  64912. * Concats the active data with a given array.
  64913. * This ensures no dupplicate will be present in the result.
  64914. * @param array defines the data to concatenate with.
  64915. */
  64916. concatWithNoDuplicate(array: any): void;
  64917. }
  64918. }
  64919. declare module BABYLON {
  64920. /**
  64921. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64922. * separate meshes. This can be use to improve performances.
  64923. * @see http://doc.babylonjs.com/how_to/multi_materials
  64924. */
  64925. export class MultiMaterial extends Material {
  64926. private _subMaterials;
  64927. /**
  64928. * Gets or Sets the list of Materials used within the multi material.
  64929. * They need to be ordered according to the submeshes order in the associated mesh
  64930. */
  64931. subMaterials: Nullable<Material>[];
  64932. /**
  64933. * Function used to align with Node.getChildren()
  64934. * @returns the list of Materials used within the multi material
  64935. */
  64936. getChildren(): Nullable<Material>[];
  64937. /**
  64938. * Instantiates a new Multi Material
  64939. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64940. * separate meshes. This can be use to improve performances.
  64941. * @see http://doc.babylonjs.com/how_to/multi_materials
  64942. * @param name Define the name in the scene
  64943. * @param scene Define the scene the material belongs to
  64944. */
  64945. constructor(name: string, scene: Scene);
  64946. private _hookArray;
  64947. /**
  64948. * Get one of the submaterial by its index in the submaterials array
  64949. * @param index The index to look the sub material at
  64950. * @returns The Material if the index has been defined
  64951. */
  64952. getSubMaterial(index: number): Nullable<Material>;
  64953. /**
  64954. * Get the list of active textures for the whole sub materials list.
  64955. * @returns All the textures that will be used during the rendering
  64956. */
  64957. getActiveTextures(): BaseTexture[];
  64958. /**
  64959. * Gets the current class name of the material e.g. "MultiMaterial"
  64960. * Mainly use in serialization.
  64961. * @returns the class name
  64962. */
  64963. getClassName(): string;
  64964. /**
  64965. * Checks if the material is ready to render the requested sub mesh
  64966. * @param mesh Define the mesh the submesh belongs to
  64967. * @param subMesh Define the sub mesh to look readyness for
  64968. * @param useInstances Define whether or not the material is used with instances
  64969. * @returns true if ready, otherwise false
  64970. */
  64971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64972. /**
  64973. * Clones the current material and its related sub materials
  64974. * @param name Define the name of the newly cloned material
  64975. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64976. * @returns the cloned material
  64977. */
  64978. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64979. /**
  64980. * Serializes the materials into a JSON representation.
  64981. * @returns the JSON representation
  64982. */
  64983. serialize(): any;
  64984. /**
  64985. * Dispose the material and release its associated resources
  64986. * @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)
  64987. * @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)
  64988. * @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)
  64989. */
  64990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64991. /**
  64992. * Creates a MultiMaterial from parsed MultiMaterial data.
  64993. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64994. * @param scene defines the hosting scene
  64995. * @returns a new MultiMaterial
  64996. */
  64997. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64998. }
  64999. }
  65000. declare module BABYLON {
  65001. /**
  65002. * Class used to represent data loading progression
  65003. */
  65004. export class SceneLoaderFlags {
  65005. private static _ForceFullSceneLoadingForIncremental;
  65006. private static _ShowLoadingScreen;
  65007. private static _CleanBoneMatrixWeights;
  65008. private static _loggingLevel;
  65009. /**
  65010. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65011. */
  65012. static ForceFullSceneLoadingForIncremental: boolean;
  65013. /**
  65014. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65015. */
  65016. static ShowLoadingScreen: boolean;
  65017. /**
  65018. * Defines the current logging level (while loading the scene)
  65019. * @ignorenaming
  65020. */
  65021. static loggingLevel: number;
  65022. /**
  65023. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65024. */
  65025. static CleanBoneMatrixWeights: boolean;
  65026. }
  65027. }
  65028. declare module BABYLON {
  65029. /**
  65030. * 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.
  65031. * @see https://doc.babylonjs.com/how_to/transformnode
  65032. */
  65033. export class TransformNode extends Node {
  65034. /**
  65035. * Object will not rotate to face the camera
  65036. */
  65037. static BILLBOARDMODE_NONE: number;
  65038. /**
  65039. * Object will rotate to face the camera but only on the x axis
  65040. */
  65041. static BILLBOARDMODE_X: number;
  65042. /**
  65043. * Object will rotate to face the camera but only on the y axis
  65044. */
  65045. static BILLBOARDMODE_Y: number;
  65046. /**
  65047. * Object will rotate to face the camera but only on the z axis
  65048. */
  65049. static BILLBOARDMODE_Z: number;
  65050. /**
  65051. * Object will rotate to face the camera
  65052. */
  65053. static BILLBOARDMODE_ALL: number;
  65054. private _forward;
  65055. private _forwardInverted;
  65056. private _up;
  65057. private _right;
  65058. private _rightInverted;
  65059. private _position;
  65060. private _rotation;
  65061. private _rotationQuaternion;
  65062. protected _scaling: Vector3;
  65063. protected _isDirty: boolean;
  65064. private _transformToBoneReferal;
  65065. /**
  65066. * Set the billboard mode. Default is 0.
  65067. *
  65068. * | Value | Type | Description |
  65069. * | --- | --- | --- |
  65070. * | 0 | BILLBOARDMODE_NONE | |
  65071. * | 1 | BILLBOARDMODE_X | |
  65072. * | 2 | BILLBOARDMODE_Y | |
  65073. * | 4 | BILLBOARDMODE_Z | |
  65074. * | 7 | BILLBOARDMODE_ALL | |
  65075. *
  65076. */
  65077. billboardMode: number;
  65078. /**
  65079. * 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
  65080. */
  65081. scalingDeterminant: number;
  65082. /**
  65083. * Sets the distance of the object to max, often used by skybox
  65084. */
  65085. infiniteDistance: boolean;
  65086. /**
  65087. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65088. * By default the system will update normals to compensate
  65089. */
  65090. ignoreNonUniformScaling: boolean;
  65091. /** @hidden */
  65092. _poseMatrix: Matrix;
  65093. /** @hidden */
  65094. _localMatrix: Matrix;
  65095. private _absolutePosition;
  65096. private _pivotMatrix;
  65097. private _pivotMatrixInverse;
  65098. protected _postMultiplyPivotMatrix: boolean;
  65099. private _tempMatrix;
  65100. private _tempMatrix2;
  65101. protected _isWorldMatrixFrozen: boolean;
  65102. /** @hidden */
  65103. _indexInSceneTransformNodesArray: number;
  65104. /**
  65105. * An event triggered after the world matrix is updated
  65106. */
  65107. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65108. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65109. /**
  65110. * Gets a string identifying the name of the class
  65111. * @returns "TransformNode" string
  65112. */
  65113. getClassName(): string;
  65114. /**
  65115. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65116. */
  65117. position: Vector3;
  65118. /**
  65119. * 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)).
  65120. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65121. */
  65122. rotation: Vector3;
  65123. /**
  65124. * 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)).
  65125. */
  65126. scaling: Vector3;
  65127. /**
  65128. * 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).
  65129. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65130. */
  65131. rotationQuaternion: Nullable<Quaternion>;
  65132. /**
  65133. * The forward direction of that transform in world space.
  65134. */
  65135. readonly forward: Vector3;
  65136. /**
  65137. * The up direction of that transform in world space.
  65138. */
  65139. readonly up: Vector3;
  65140. /**
  65141. * The right direction of that transform in world space.
  65142. */
  65143. readonly right: Vector3;
  65144. /**
  65145. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65146. * @param matrix the matrix to copy the pose from
  65147. * @returns this TransformNode.
  65148. */
  65149. updatePoseMatrix(matrix: Matrix): TransformNode;
  65150. /**
  65151. * Returns the mesh Pose matrix.
  65152. * @returns the pose matrix
  65153. */
  65154. getPoseMatrix(): Matrix;
  65155. /** @hidden */
  65156. _isSynchronized(): boolean;
  65157. /** @hidden */
  65158. _initCache(): void;
  65159. /**
  65160. * Flag the transform node as dirty (Forcing it to update everything)
  65161. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65162. * @returns this transform node
  65163. */
  65164. markAsDirty(property: string): TransformNode;
  65165. /**
  65166. * Returns the current mesh absolute position.
  65167. * Returns a Vector3.
  65168. */
  65169. readonly absolutePosition: Vector3;
  65170. /**
  65171. * Sets a new matrix to apply before all other transformation
  65172. * @param matrix defines the transform matrix
  65173. * @returns the current TransformNode
  65174. */
  65175. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65176. /**
  65177. * Sets a new pivot matrix to the current node
  65178. * @param matrix defines the new pivot matrix to use
  65179. * @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
  65180. * @returns the current TransformNode
  65181. */
  65182. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65183. /**
  65184. * Returns the mesh pivot matrix.
  65185. * Default : Identity.
  65186. * @returns the matrix
  65187. */
  65188. getPivotMatrix(): Matrix;
  65189. /**
  65190. * Prevents the World matrix to be computed any longer.
  65191. * @returns the TransformNode.
  65192. */
  65193. freezeWorldMatrix(): TransformNode;
  65194. /**
  65195. * Allows back the World matrix computation.
  65196. * @returns the TransformNode.
  65197. */
  65198. unfreezeWorldMatrix(): this;
  65199. /**
  65200. * True if the World matrix has been frozen.
  65201. */
  65202. readonly isWorldMatrixFrozen: boolean;
  65203. /**
  65204. * Retuns the mesh absolute position in the World.
  65205. * @returns a Vector3.
  65206. */
  65207. getAbsolutePosition(): Vector3;
  65208. /**
  65209. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65210. * @param absolutePosition the absolute position to set
  65211. * @returns the TransformNode.
  65212. */
  65213. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65214. /**
  65215. * Sets the mesh position in its local space.
  65216. * @param vector3 the position to set in localspace
  65217. * @returns the TransformNode.
  65218. */
  65219. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65220. /**
  65221. * Returns the mesh position in the local space from the current World matrix values.
  65222. * @returns a new Vector3.
  65223. */
  65224. getPositionExpressedInLocalSpace(): Vector3;
  65225. /**
  65226. * Translates the mesh along the passed Vector3 in its local space.
  65227. * @param vector3 the distance to translate in localspace
  65228. * @returns the TransformNode.
  65229. */
  65230. locallyTranslate(vector3: Vector3): TransformNode;
  65231. private static _lookAtVectorCache;
  65232. /**
  65233. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65234. * @param targetPoint the position (must be in same space as current mesh) to look at
  65235. * @param yawCor optional yaw (y-axis) correction in radians
  65236. * @param pitchCor optional pitch (x-axis) correction in radians
  65237. * @param rollCor optional roll (z-axis) correction in radians
  65238. * @param space the choosen space of the target
  65239. * @returns the TransformNode.
  65240. */
  65241. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65242. /**
  65243. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65244. * This Vector3 is expressed in the World space.
  65245. * @param localAxis axis to rotate
  65246. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65247. */
  65248. getDirection(localAxis: Vector3): Vector3;
  65249. /**
  65250. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65251. * localAxis is expressed in the mesh local space.
  65252. * result is computed in the Wordl space from the mesh World matrix.
  65253. * @param localAxis axis to rotate
  65254. * @param result the resulting transformnode
  65255. * @returns this TransformNode.
  65256. */
  65257. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65258. /**
  65259. * Sets this transform node rotation to the given local axis.
  65260. * @param localAxis the axis in local space
  65261. * @param yawCor optional yaw (y-axis) correction in radians
  65262. * @param pitchCor optional pitch (x-axis) correction in radians
  65263. * @param rollCor optional roll (z-axis) correction in radians
  65264. * @returns this TransformNode
  65265. */
  65266. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65267. /**
  65268. * Sets a new pivot point to the current node
  65269. * @param point defines the new pivot point to use
  65270. * @param space defines if the point is in world or local space (local by default)
  65271. * @returns the current TransformNode
  65272. */
  65273. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65274. /**
  65275. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65276. * @returns the pivot point
  65277. */
  65278. getPivotPoint(): Vector3;
  65279. /**
  65280. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65281. * @param result the vector3 to store the result
  65282. * @returns this TransformNode.
  65283. */
  65284. getPivotPointToRef(result: Vector3): TransformNode;
  65285. /**
  65286. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65287. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65288. */
  65289. getAbsolutePivotPoint(): Vector3;
  65290. /**
  65291. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65292. * @param result vector3 to store the result
  65293. * @returns this TransformNode.
  65294. */
  65295. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65296. /**
  65297. * Defines the passed node as the parent of the current node.
  65298. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65299. * @param node the node ot set as the parent
  65300. * @returns this TransformNode.
  65301. */
  65302. setParent(node: Nullable<Node>): TransformNode;
  65303. private _nonUniformScaling;
  65304. /**
  65305. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65306. */
  65307. readonly nonUniformScaling: boolean;
  65308. /** @hidden */
  65309. _updateNonUniformScalingState(value: boolean): boolean;
  65310. /**
  65311. * Attach the current TransformNode to another TransformNode associated with a bone
  65312. * @param bone Bone affecting the TransformNode
  65313. * @param affectedTransformNode TransformNode associated with the bone
  65314. * @returns this object
  65315. */
  65316. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65317. /**
  65318. * Detach the transform node if its associated with a bone
  65319. * @returns this object
  65320. */
  65321. detachFromBone(): TransformNode;
  65322. private static _rotationAxisCache;
  65323. /**
  65324. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65325. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65326. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65327. * The passed axis is also normalized.
  65328. * @param axis the axis to rotate around
  65329. * @param amount the amount to rotate in radians
  65330. * @param space Space to rotate in (Default: local)
  65331. * @returns the TransformNode.
  65332. */
  65333. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65334. /**
  65335. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65336. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65337. * The passed axis is also normalized. .
  65338. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65339. * @param point the point to rotate around
  65340. * @param axis the axis to rotate around
  65341. * @param amount the amount to rotate in radians
  65342. * @returns the TransformNode
  65343. */
  65344. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65345. /**
  65346. * Translates the mesh along the axis vector for the passed distance in the given space.
  65347. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65348. * @param axis the axis to translate in
  65349. * @param distance the distance to translate
  65350. * @param space Space to rotate in (Default: local)
  65351. * @returns the TransformNode.
  65352. */
  65353. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65354. /**
  65355. * Adds a rotation step to the mesh current rotation.
  65356. * x, y, z are Euler angles expressed in radians.
  65357. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65358. * This means this rotation is made in the mesh local space only.
  65359. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65360. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65361. * ```javascript
  65362. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65363. * ```
  65364. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65365. * 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.
  65366. * @param x Rotation to add
  65367. * @param y Rotation to add
  65368. * @param z Rotation to add
  65369. * @returns the TransformNode.
  65370. */
  65371. addRotation(x: number, y: number, z: number): TransformNode;
  65372. /**
  65373. * Computes the world matrix of the node
  65374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65375. * @returns the world matrix
  65376. */
  65377. computeWorldMatrix(force?: boolean): Matrix;
  65378. protected _afterComputeWorldMatrix(): void;
  65379. /**
  65380. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65381. * @param func callback function to add
  65382. *
  65383. * @returns the TransformNode.
  65384. */
  65385. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65386. /**
  65387. * Removes a registered callback function.
  65388. * @param func callback function to remove
  65389. * @returns the TransformNode.
  65390. */
  65391. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65392. /**
  65393. * Gets the position of the current mesh in camera space
  65394. * @param camera defines the camera to use
  65395. * @returns a position
  65396. */
  65397. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65398. /**
  65399. * Returns the distance from the mesh to the active camera
  65400. * @param camera defines the camera to use
  65401. * @returns the distance
  65402. */
  65403. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65404. /**
  65405. * Clone the current transform node
  65406. * @param name Name of the new clone
  65407. * @param newParent New parent for the clone
  65408. * @param doNotCloneChildren Do not clone children hierarchy
  65409. * @returns the new transform node
  65410. */
  65411. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65412. /**
  65413. * Serializes the objects information.
  65414. * @param currentSerializationObject defines the object to serialize in
  65415. * @returns the serialized object
  65416. */
  65417. serialize(currentSerializationObject?: any): any;
  65418. /**
  65419. * Returns a new TransformNode object parsed from the source provided.
  65420. * @param parsedTransformNode is the source.
  65421. * @param scene the scne the object belongs to
  65422. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65423. * @returns a new TransformNode object parsed from the source provided.
  65424. */
  65425. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65426. /**
  65427. * Get all child-transformNodes of this node
  65428. * @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
  65429. * @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
  65430. * @returns an array of TransformNode
  65431. */
  65432. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65433. /**
  65434. * Releases resources associated with this transform node.
  65435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65437. */
  65438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65439. }
  65440. }
  65441. declare module BABYLON {
  65442. /**
  65443. * Class used to override all child animations of a given target
  65444. */
  65445. export class AnimationPropertiesOverride {
  65446. /**
  65447. * Gets or sets a value indicating if animation blending must be used
  65448. */
  65449. enableBlending: boolean;
  65450. /**
  65451. * Gets or sets the blending speed to use when enableBlending is true
  65452. */
  65453. blendingSpeed: number;
  65454. /**
  65455. * Gets or sets the default loop mode to use
  65456. */
  65457. loopMode: number;
  65458. }
  65459. }
  65460. declare module BABYLON {
  65461. /**
  65462. * Class used to store bone information
  65463. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65464. */
  65465. export class Bone extends Node {
  65466. /**
  65467. * defines the bone name
  65468. */
  65469. name: string;
  65470. private static _tmpVecs;
  65471. private static _tmpQuat;
  65472. private static _tmpMats;
  65473. /**
  65474. * Gets the list of child bones
  65475. */
  65476. children: Bone[];
  65477. /** Gets the animations associated with this bone */
  65478. animations: Animation[];
  65479. /**
  65480. * Gets or sets bone length
  65481. */
  65482. length: number;
  65483. /**
  65484. * @hidden Internal only
  65485. * Set this value to map this bone to a different index in the transform matrices
  65486. * Set this value to -1 to exclude the bone from the transform matrices
  65487. */
  65488. _index: Nullable<number>;
  65489. private _skeleton;
  65490. private _localMatrix;
  65491. private _restPose;
  65492. private _baseMatrix;
  65493. private _absoluteTransform;
  65494. private _invertedAbsoluteTransform;
  65495. private _parent;
  65496. private _scalingDeterminant;
  65497. private _worldTransform;
  65498. private _localScaling;
  65499. private _localRotation;
  65500. private _localPosition;
  65501. private _needToDecompose;
  65502. private _needToCompose;
  65503. /** @hidden */
  65504. _linkedTransformNode: Nullable<TransformNode>;
  65505. /** @hidden */
  65506. /** @hidden */
  65507. _matrix: Matrix;
  65508. /**
  65509. * Create a new bone
  65510. * @param name defines the bone name
  65511. * @param skeleton defines the parent skeleton
  65512. * @param parentBone defines the parent (can be null if the bone is the root)
  65513. * @param localMatrix defines the local matrix
  65514. * @param restPose defines the rest pose matrix
  65515. * @param baseMatrix defines the base matrix
  65516. * @param index defines index of the bone in the hiearchy
  65517. */
  65518. constructor(
  65519. /**
  65520. * defines the bone name
  65521. */
  65522. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65523. /**
  65524. * Gets the current object class name.
  65525. * @return the class name
  65526. */
  65527. getClassName(): string;
  65528. /**
  65529. * Gets the parent skeleton
  65530. * @returns a skeleton
  65531. */
  65532. getSkeleton(): Skeleton;
  65533. /**
  65534. * Gets parent bone
  65535. * @returns a bone or null if the bone is the root of the bone hierarchy
  65536. */
  65537. getParent(): Nullable<Bone>;
  65538. /**
  65539. * Returns an array containing the root bones
  65540. * @returns an array containing the root bones
  65541. */
  65542. getChildren(): Array<Bone>;
  65543. /**
  65544. * Sets the parent bone
  65545. * @param parent defines the parent (can be null if the bone is the root)
  65546. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65547. */
  65548. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65549. /**
  65550. * Gets the local matrix
  65551. * @returns a matrix
  65552. */
  65553. getLocalMatrix(): Matrix;
  65554. /**
  65555. * Gets the base matrix (initial matrix which remains unchanged)
  65556. * @returns a matrix
  65557. */
  65558. getBaseMatrix(): Matrix;
  65559. /**
  65560. * Gets the rest pose matrix
  65561. * @returns a matrix
  65562. */
  65563. getRestPose(): Matrix;
  65564. /**
  65565. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65566. */
  65567. getWorldMatrix(): Matrix;
  65568. /**
  65569. * Sets the local matrix to rest pose matrix
  65570. */
  65571. returnToRest(): void;
  65572. /**
  65573. * Gets the inverse of the absolute transform matrix.
  65574. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65575. * @returns a matrix
  65576. */
  65577. getInvertedAbsoluteTransform(): Matrix;
  65578. /**
  65579. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65580. * @returns a matrix
  65581. */
  65582. getAbsoluteTransform(): Matrix;
  65583. /**
  65584. * Links with the given transform node.
  65585. * The local matrix of this bone is copied from the transform node every frame.
  65586. * @param transformNode defines the transform node to link to
  65587. */
  65588. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65589. /** Gets or sets current position (in local space) */
  65590. position: Vector3;
  65591. /** Gets or sets current rotation (in local space) */
  65592. rotation: Vector3;
  65593. /** Gets or sets current rotation quaternion (in local space) */
  65594. rotationQuaternion: Quaternion;
  65595. /** Gets or sets current scaling (in local space) */
  65596. scaling: Vector3;
  65597. /**
  65598. * Gets the animation properties override
  65599. */
  65600. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65601. private _decompose;
  65602. private _compose;
  65603. /**
  65604. * Update the base and local matrices
  65605. * @param matrix defines the new base or local matrix
  65606. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65607. * @param updateLocalMatrix defines if the local matrix should be updated
  65608. */
  65609. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65610. /** @hidden */
  65611. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65612. /**
  65613. * Flag the bone as dirty (Forcing it to update everything)
  65614. */
  65615. markAsDirty(): void;
  65616. private _markAsDirtyAndCompose;
  65617. private _markAsDirtyAndDecompose;
  65618. /**
  65619. * Translate the bone in local or world space
  65620. * @param vec The amount to translate the bone
  65621. * @param space The space that the translation is in
  65622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65623. */
  65624. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65625. /**
  65626. * Set the postion of the bone in local or world space
  65627. * @param position The position to set the bone
  65628. * @param space The space that the position is in
  65629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65630. */
  65631. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65632. /**
  65633. * Set the absolute position of the bone (world space)
  65634. * @param position The position to set the bone
  65635. * @param mesh The mesh that this bone is attached to
  65636. */
  65637. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65638. /**
  65639. * Scale the bone on the x, y and z axes (in local space)
  65640. * @param x The amount to scale the bone on the x axis
  65641. * @param y The amount to scale the bone on the y axis
  65642. * @param z The amount to scale the bone on the z axis
  65643. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65644. */
  65645. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65646. /**
  65647. * Set the bone scaling in local space
  65648. * @param scale defines the scaling vector
  65649. */
  65650. setScale(scale: Vector3): void;
  65651. /**
  65652. * Gets the current scaling in local space
  65653. * @returns the current scaling vector
  65654. */
  65655. getScale(): Vector3;
  65656. /**
  65657. * Gets the current scaling in local space and stores it in a target vector
  65658. * @param result defines the target vector
  65659. */
  65660. getScaleToRef(result: Vector3): void;
  65661. /**
  65662. * Set the yaw, pitch, and roll of the bone in local or world space
  65663. * @param yaw The rotation of the bone on the y axis
  65664. * @param pitch The rotation of the bone on the x axis
  65665. * @param roll The rotation of the bone on the z axis
  65666. * @param space The space that the axes of rotation are in
  65667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65668. */
  65669. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65670. /**
  65671. * Add a rotation to the bone on an axis in local or world space
  65672. * @param axis The axis to rotate the bone on
  65673. * @param amount The amount to rotate the bone
  65674. * @param space The space that the axis is in
  65675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65676. */
  65677. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65678. /**
  65679. * Set the rotation of the bone to a particular axis angle in local or world space
  65680. * @param axis The axis to rotate the bone on
  65681. * @param angle The angle that the bone should be rotated to
  65682. * @param space The space that the axis is in
  65683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65684. */
  65685. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65686. /**
  65687. * Set the euler rotation of the bone in local of world space
  65688. * @param rotation The euler rotation that the bone should be set to
  65689. * @param space The space that the rotation is in
  65690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65691. */
  65692. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65693. /**
  65694. * Set the quaternion rotation of the bone in local of world space
  65695. * @param quat The quaternion rotation that the bone should be set to
  65696. * @param space The space that the rotation is in
  65697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65698. */
  65699. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65700. /**
  65701. * Set the rotation matrix of the bone in local of world space
  65702. * @param rotMat The rotation matrix that the bone should be set to
  65703. * @param space The space that the rotation is in
  65704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65705. */
  65706. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65707. private _rotateWithMatrix;
  65708. private _getNegativeRotationToRef;
  65709. /**
  65710. * Get the position of the bone in local or world space
  65711. * @param space The space that the returned position is in
  65712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65713. * @returns The position of the bone
  65714. */
  65715. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65716. /**
  65717. * Copy the position of the bone to a vector3 in local or world space
  65718. * @param space The space that the returned position is in
  65719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65720. * @param result The vector3 to copy the position to
  65721. */
  65722. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65723. /**
  65724. * Get the absolute position of the bone (world space)
  65725. * @param mesh The mesh that this bone is attached to
  65726. * @returns The absolute position of the bone
  65727. */
  65728. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65729. /**
  65730. * Copy the absolute position of the bone (world space) to the result param
  65731. * @param mesh The mesh that this bone is attached to
  65732. * @param result The vector3 to copy the absolute position to
  65733. */
  65734. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65735. /**
  65736. * Compute the absolute transforms of this bone and its children
  65737. */
  65738. computeAbsoluteTransforms(): void;
  65739. /**
  65740. * Get the world direction from an axis that is in the local space of the bone
  65741. * @param localAxis The local direction that is used to compute the world direction
  65742. * @param mesh The mesh that this bone is attached to
  65743. * @returns The world direction
  65744. */
  65745. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65746. /**
  65747. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65748. * @param localAxis The local direction that is used to compute the world direction
  65749. * @param mesh The mesh that this bone is attached to
  65750. * @param result The vector3 that the world direction will be copied to
  65751. */
  65752. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65753. /**
  65754. * Get the euler rotation of the bone in local or world space
  65755. * @param space The space that the rotation should be in
  65756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65757. * @returns The euler rotation
  65758. */
  65759. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65760. /**
  65761. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65762. * @param space The space that the rotation should be in
  65763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65764. * @param result The vector3 that the rotation should be copied to
  65765. */
  65766. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65767. /**
  65768. * Get the quaternion rotation of the bone in either local or world space
  65769. * @param space The space that the rotation should be in
  65770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65771. * @returns The quaternion rotation
  65772. */
  65773. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65774. /**
  65775. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65776. * @param space The space that the rotation should be in
  65777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65778. * @param result The quaternion that the rotation should be copied to
  65779. */
  65780. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65781. /**
  65782. * Get the rotation matrix of the bone in local or world space
  65783. * @param space The space that the rotation should be in
  65784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65785. * @returns The rotation matrix
  65786. */
  65787. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65788. /**
  65789. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65790. * @param space The space that the rotation should be in
  65791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65792. * @param result The quaternion that the rotation should be copied to
  65793. */
  65794. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65795. /**
  65796. * Get the world position of a point that is in the local space of the bone
  65797. * @param position The local position
  65798. * @param mesh The mesh that this bone is attached to
  65799. * @returns The world position
  65800. */
  65801. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65802. /**
  65803. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65804. * @param position The local position
  65805. * @param mesh The mesh that this bone is attached to
  65806. * @param result The vector3 that the world position should be copied to
  65807. */
  65808. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65809. /**
  65810. * Get the local position of a point that is in world space
  65811. * @param position The world position
  65812. * @param mesh The mesh that this bone is attached to
  65813. * @returns The local position
  65814. */
  65815. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65816. /**
  65817. * Get the local position of a point that is in world space and copy it to the result param
  65818. * @param position The world position
  65819. * @param mesh The mesh that this bone is attached to
  65820. * @param result The vector3 that the local position should be copied to
  65821. */
  65822. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65823. }
  65824. }
  65825. declare module BABYLON {
  65826. /**
  65827. * Class for creating a cube texture
  65828. */
  65829. export class CubeTexture extends BaseTexture {
  65830. private _delayedOnLoad;
  65831. /**
  65832. * The url of the texture
  65833. */
  65834. url: string;
  65835. /**
  65836. * Gets or sets the center of the bounding box associated with the cube texture.
  65837. * It must define where the camera used to render the texture was set
  65838. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65839. */
  65840. boundingBoxPosition: Vector3;
  65841. private _boundingBoxSize;
  65842. /**
  65843. * Gets or sets the size of the bounding box associated with the cube texture
  65844. * When defined, the cubemap will switch to local mode
  65845. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65846. * @example https://www.babylonjs-playground.com/#RNASML
  65847. */
  65848. /**
  65849. * Returns the bounding box size
  65850. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65851. */
  65852. boundingBoxSize: Vector3;
  65853. protected _rotationY: number;
  65854. /**
  65855. * Sets texture matrix rotation angle around Y axis in radians.
  65856. */
  65857. /**
  65858. * Gets texture matrix rotation angle around Y axis radians.
  65859. */
  65860. rotationY: number;
  65861. /**
  65862. * Are mip maps generated for this texture or not.
  65863. */
  65864. readonly noMipmap: boolean;
  65865. private _noMipmap;
  65866. private _files;
  65867. private _extensions;
  65868. private _textureMatrix;
  65869. private _format;
  65870. private _createPolynomials;
  65871. /** @hidden */
  65872. _prefiltered: boolean;
  65873. /**
  65874. * Creates a cube texture from an array of image urls
  65875. * @param files defines an array of image urls
  65876. * @param scene defines the hosting scene
  65877. * @param noMipmap specifies if mip maps are not used
  65878. * @returns a cube texture
  65879. */
  65880. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65881. /**
  65882. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65883. * @param url defines the url of the prefiltered texture
  65884. * @param scene defines the scene the texture is attached to
  65885. * @param forcedExtension defines the extension of the file if different from the url
  65886. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65887. * @return the prefiltered texture
  65888. */
  65889. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65890. /**
  65891. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65892. * as prefiltered data.
  65893. * @param rootUrl defines the url of the texture or the root name of the six images
  65894. * @param scene defines the scene the texture is attached to
  65895. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65896. * @param noMipmap defines if mipmaps should be created or not
  65897. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  65898. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65899. * @param onError defines a callback triggered in case of error during load
  65900. * @param format defines the internal format to use for the texture once loaded
  65901. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65902. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65903. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65904. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65905. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65906. * @return the cube texture
  65907. */
  65908. 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);
  65909. /**
  65910. * Get the current class name of the texture useful for serialization or dynamic coding.
  65911. * @returns "CubeTexture"
  65912. */
  65913. getClassName(): string;
  65914. /**
  65915. * Update the url (and optional buffer) of this texture if url was null during construction.
  65916. * @param url the url of the texture
  65917. * @param forcedExtension defines the extension to use
  65918. * @param onLoad callback called when the texture is loaded (defaults to null)
  65919. */
  65920. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65921. /**
  65922. * Delays loading of the cube texture
  65923. * @param forcedExtension defines the extension to use
  65924. */
  65925. delayLoad(forcedExtension?: string): void;
  65926. /**
  65927. * Returns the reflection texture matrix
  65928. * @returns the reflection texture matrix
  65929. */
  65930. getReflectionTextureMatrix(): Matrix;
  65931. /**
  65932. * Sets the reflection texture matrix
  65933. * @param value Reflection texture matrix
  65934. */
  65935. setReflectionTextureMatrix(value: Matrix): void;
  65936. /**
  65937. * Parses text to create a cube texture
  65938. * @param parsedTexture define the serialized text to read from
  65939. * @param scene defines the hosting scene
  65940. * @param rootUrl defines the root url of the cube texture
  65941. * @returns a cube texture
  65942. */
  65943. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65944. /**
  65945. * Makes a clone, or deep copy, of the cube texture
  65946. * @returns a new cube texture
  65947. */
  65948. clone(): CubeTexture;
  65949. }
  65950. }
  65951. declare module BABYLON {
  65952. /** @hidden */
  65953. export var postprocessVertexShader: {
  65954. name: string;
  65955. shader: string;
  65956. };
  65957. }
  65958. declare module BABYLON {
  65959. /**
  65960. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65961. * This is the base of the follow, arc rotate cameras and Free camera
  65962. * @see http://doc.babylonjs.com/features/cameras
  65963. */
  65964. export class TargetCamera extends Camera {
  65965. private static _RigCamTransformMatrix;
  65966. private static _TargetTransformMatrix;
  65967. private static _TargetFocalPoint;
  65968. /**
  65969. * Define the current direction the camera is moving to
  65970. */
  65971. cameraDirection: Vector3;
  65972. /**
  65973. * Define the current rotation the camera is rotating to
  65974. */
  65975. cameraRotation: Vector2;
  65976. /**
  65977. * When set, the up vector of the camera will be updated by the rotation of the camera
  65978. */
  65979. updateUpVectorFromRotation: boolean;
  65980. private _tmpQuaternion;
  65981. /**
  65982. * Define the current rotation of the camera
  65983. */
  65984. rotation: Vector3;
  65985. /**
  65986. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65987. */
  65988. rotationQuaternion: Quaternion;
  65989. /**
  65990. * Define the current speed of the camera
  65991. */
  65992. speed: number;
  65993. /**
  65994. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65995. * around all axis.
  65996. */
  65997. noRotationConstraint: boolean;
  65998. /**
  65999. * Define the current target of the camera as an object or a position.
  66000. */
  66001. lockedTarget: any;
  66002. /** @hidden */
  66003. _currentTarget: Vector3;
  66004. /** @hidden */
  66005. _initialFocalDistance: number;
  66006. /** @hidden */
  66007. _viewMatrix: Matrix;
  66008. /** @hidden */
  66009. _camMatrix: Matrix;
  66010. /** @hidden */
  66011. _cameraTransformMatrix: Matrix;
  66012. /** @hidden */
  66013. _cameraRotationMatrix: Matrix;
  66014. /** @hidden */
  66015. _referencePoint: Vector3;
  66016. /** @hidden */
  66017. _transformedReferencePoint: Vector3;
  66018. protected _globalCurrentTarget: Vector3;
  66019. protected _globalCurrentUpVector: Vector3;
  66020. /** @hidden */
  66021. _reset: () => void;
  66022. private _defaultUp;
  66023. /**
  66024. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66025. * This is the base of the follow, arc rotate cameras and Free camera
  66026. * @see http://doc.babylonjs.com/features/cameras
  66027. * @param name Defines the name of the camera in the scene
  66028. * @param position Defines the start position of the camera in the scene
  66029. * @param scene Defines the scene the camera belongs to
  66030. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66031. */
  66032. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66033. /**
  66034. * Gets the position in front of the camera at a given distance.
  66035. * @param distance The distance from the camera we want the position to be
  66036. * @returns the position
  66037. */
  66038. getFrontPosition(distance: number): Vector3;
  66039. /** @hidden */
  66040. _getLockedTargetPosition(): Nullable<Vector3>;
  66041. private _storedPosition;
  66042. private _storedRotation;
  66043. private _storedRotationQuaternion;
  66044. /**
  66045. * Store current camera state of the camera (fov, position, rotation, etc..)
  66046. * @returns the camera
  66047. */
  66048. storeState(): Camera;
  66049. /**
  66050. * Restored camera state. You must call storeState() first
  66051. * @returns whether it was successful or not
  66052. * @hidden
  66053. */
  66054. _restoreStateValues(): boolean;
  66055. /** @hidden */
  66056. _initCache(): void;
  66057. /** @hidden */
  66058. _updateCache(ignoreParentClass?: boolean): void;
  66059. /** @hidden */
  66060. _isSynchronizedViewMatrix(): boolean;
  66061. /** @hidden */
  66062. _computeLocalCameraSpeed(): number;
  66063. /**
  66064. * Defines the target the camera should look at.
  66065. * This will automatically adapt alpha beta and radius to fit within the new target.
  66066. * @param target Defines the new target as a Vector or a mesh
  66067. */
  66068. setTarget(target: Vector3): void;
  66069. /**
  66070. * Return the current target position of the camera. This value is expressed in local space.
  66071. * @returns the target position
  66072. */
  66073. getTarget(): Vector3;
  66074. /** @hidden */
  66075. _decideIfNeedsToMove(): boolean;
  66076. /** @hidden */
  66077. _updatePosition(): void;
  66078. /** @hidden */
  66079. _checkInputs(): void;
  66080. protected _updateCameraRotationMatrix(): void;
  66081. /**
  66082. * 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)
  66083. * @returns the current camera
  66084. */
  66085. private _rotateUpVectorWithCameraRotationMatrix;
  66086. private _cachedRotationZ;
  66087. private _cachedQuaternionRotationZ;
  66088. /** @hidden */
  66089. _getViewMatrix(): Matrix;
  66090. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66091. /**
  66092. * @hidden
  66093. */
  66094. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66095. /**
  66096. * @hidden
  66097. */
  66098. _updateRigCameras(): void;
  66099. private _getRigCamPositionAndTarget;
  66100. /**
  66101. * Gets the current object class name.
  66102. * @return the class name
  66103. */
  66104. getClassName(): string;
  66105. }
  66106. }
  66107. declare module BABYLON {
  66108. /**
  66109. * @ignore
  66110. * This is a list of all the different input types that are available in the application.
  66111. * Fo instance: ArcRotateCameraGamepadInput...
  66112. */
  66113. export var CameraInputTypes: {};
  66114. /**
  66115. * This is the contract to implement in order to create a new input class.
  66116. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66117. */
  66118. export interface ICameraInput<TCamera extends Camera> {
  66119. /**
  66120. * Defines the camera the input is attached to.
  66121. */
  66122. camera: Nullable<TCamera>;
  66123. /**
  66124. * Gets the class name of the current intput.
  66125. * @returns the class name
  66126. */
  66127. getClassName(): string;
  66128. /**
  66129. * Get the friendly name associated with the input class.
  66130. * @returns the input friendly name
  66131. */
  66132. getSimpleName(): string;
  66133. /**
  66134. * Attach the input controls to a specific dom element to get the input from.
  66135. * @param element Defines the element the controls should be listened from
  66136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66137. */
  66138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66139. /**
  66140. * Detach the current controls from the specified dom element.
  66141. * @param element Defines the element to stop listening the inputs from
  66142. */
  66143. detachControl(element: Nullable<HTMLElement>): void;
  66144. /**
  66145. * Update the current camera state depending on the inputs that have been used this frame.
  66146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66147. */
  66148. checkInputs?: () => void;
  66149. }
  66150. /**
  66151. * Represents a map of input types to input instance or input index to input instance.
  66152. */
  66153. export interface CameraInputsMap<TCamera extends Camera> {
  66154. /**
  66155. * Accessor to the input by input type.
  66156. */
  66157. [name: string]: ICameraInput<TCamera>;
  66158. /**
  66159. * Accessor to the input by input index.
  66160. */
  66161. [idx: number]: ICameraInput<TCamera>;
  66162. }
  66163. /**
  66164. * This represents the input manager used within a camera.
  66165. * It helps dealing with all the different kind of input attached to a camera.
  66166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66167. */
  66168. export class CameraInputsManager<TCamera extends Camera> {
  66169. /**
  66170. * Defines the list of inputs attahed to the camera.
  66171. */
  66172. attached: CameraInputsMap<TCamera>;
  66173. /**
  66174. * Defines the dom element the camera is collecting inputs from.
  66175. * This is null if the controls have not been attached.
  66176. */
  66177. attachedElement: Nullable<HTMLElement>;
  66178. /**
  66179. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66180. */
  66181. noPreventDefault: boolean;
  66182. /**
  66183. * Defined the camera the input manager belongs to.
  66184. */
  66185. camera: TCamera;
  66186. /**
  66187. * Update the current camera state depending on the inputs that have been used this frame.
  66188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66189. */
  66190. checkInputs: () => void;
  66191. /**
  66192. * Instantiate a new Camera Input Manager.
  66193. * @param camera Defines the camera the input manager blongs to
  66194. */
  66195. constructor(camera: TCamera);
  66196. /**
  66197. * Add an input method to a camera
  66198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66199. * @param input camera input method
  66200. */
  66201. add(input: ICameraInput<TCamera>): void;
  66202. /**
  66203. * Remove a specific input method from a camera
  66204. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66205. * @param inputToRemove camera input method
  66206. */
  66207. remove(inputToRemove: ICameraInput<TCamera>): void;
  66208. /**
  66209. * Remove a specific input type from a camera
  66210. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66211. * @param inputType the type of the input to remove
  66212. */
  66213. removeByType(inputType: string): void;
  66214. private _addCheckInputs;
  66215. /**
  66216. * Attach the input controls to the currently attached dom element to listen the events from.
  66217. * @param input Defines the input to attach
  66218. */
  66219. attachInput(input: ICameraInput<TCamera>): void;
  66220. /**
  66221. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66222. * @param element Defines the dom element to collect the events from
  66223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66224. */
  66225. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66226. /**
  66227. * Detach the current manager inputs controls from a specific dom element.
  66228. * @param element Defines the dom element to collect the events from
  66229. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66230. */
  66231. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66232. /**
  66233. * Rebuild the dynamic inputCheck function from the current list of
  66234. * defined inputs in the manager.
  66235. */
  66236. rebuildInputCheck(): void;
  66237. /**
  66238. * Remove all attached input methods from a camera
  66239. */
  66240. clear(): void;
  66241. /**
  66242. * Serialize the current input manager attached to a camera.
  66243. * This ensures than once parsed,
  66244. * the input associated to the camera will be identical to the current ones
  66245. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66246. */
  66247. serialize(serializedCamera: any): void;
  66248. /**
  66249. * Parses an input manager serialized JSON to restore the previous list of inputs
  66250. * and states associated to a camera.
  66251. * @param parsedCamera Defines the JSON to parse
  66252. */
  66253. parse(parsedCamera: any): void;
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /**
  66258. * Gather the list of keyboard event types as constants.
  66259. */
  66260. export class KeyboardEventTypes {
  66261. /**
  66262. * The keydown event is fired when a key becomes active (pressed).
  66263. */
  66264. static readonly KEYDOWN: number;
  66265. /**
  66266. * The keyup event is fired when a key has been released.
  66267. */
  66268. static readonly KEYUP: number;
  66269. }
  66270. /**
  66271. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66272. */
  66273. export class KeyboardInfo {
  66274. /**
  66275. * Defines the type of event (KeyboardEventTypes)
  66276. */
  66277. type: number;
  66278. /**
  66279. * Defines the related dom event
  66280. */
  66281. event: KeyboardEvent;
  66282. /**
  66283. * Instantiates a new keyboard info.
  66284. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66285. * @param type Defines the type of event (KeyboardEventTypes)
  66286. * @param event Defines the related dom event
  66287. */
  66288. constructor(
  66289. /**
  66290. * Defines the type of event (KeyboardEventTypes)
  66291. */
  66292. type: number,
  66293. /**
  66294. * Defines the related dom event
  66295. */
  66296. event: KeyboardEvent);
  66297. }
  66298. /**
  66299. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66300. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66301. */
  66302. export class KeyboardInfoPre extends KeyboardInfo {
  66303. /**
  66304. * Defines the type of event (KeyboardEventTypes)
  66305. */
  66306. type: number;
  66307. /**
  66308. * Defines the related dom event
  66309. */
  66310. event: KeyboardEvent;
  66311. /**
  66312. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66313. */
  66314. skipOnPointerObservable: boolean;
  66315. /**
  66316. * Instantiates a new keyboard pre info.
  66317. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66318. * @param type Defines the type of event (KeyboardEventTypes)
  66319. * @param event Defines the related dom event
  66320. */
  66321. constructor(
  66322. /**
  66323. * Defines the type of event (KeyboardEventTypes)
  66324. */
  66325. type: number,
  66326. /**
  66327. * Defines the related dom event
  66328. */
  66329. event: KeyboardEvent);
  66330. }
  66331. }
  66332. declare module BABYLON {
  66333. /**
  66334. * Manage the keyboard inputs to control the movement of a free camera.
  66335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66336. */
  66337. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66338. /**
  66339. * Defines the camera the input is attached to.
  66340. */
  66341. camera: FreeCamera;
  66342. /**
  66343. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66344. */
  66345. keysUp: number[];
  66346. /**
  66347. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66348. */
  66349. keysDown: number[];
  66350. /**
  66351. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66352. */
  66353. keysLeft: number[];
  66354. /**
  66355. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66356. */
  66357. keysRight: number[];
  66358. private _keys;
  66359. private _onCanvasBlurObserver;
  66360. private _onKeyboardObserver;
  66361. private _engine;
  66362. private _scene;
  66363. /**
  66364. * Attach the input controls to a specific dom element to get the input from.
  66365. * @param element Defines the element the controls should be listened from
  66366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66367. */
  66368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66369. /**
  66370. * Detach the current controls from the specified dom element.
  66371. * @param element Defines the element to stop listening the inputs from
  66372. */
  66373. detachControl(element: Nullable<HTMLElement>): void;
  66374. /**
  66375. * Update the current camera state depending on the inputs that have been used this frame.
  66376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66377. */
  66378. checkInputs(): void;
  66379. /**
  66380. * Gets the class name of the current intput.
  66381. * @returns the class name
  66382. */
  66383. getClassName(): string;
  66384. /** @hidden */
  66385. _onLostFocus(): void;
  66386. /**
  66387. * Get the friendly name associated with the input class.
  66388. * @returns the input friendly name
  66389. */
  66390. getSimpleName(): string;
  66391. }
  66392. }
  66393. declare module BABYLON {
  66394. /**
  66395. * Interface describing all the common properties and methods a shadow light needs to implement.
  66396. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66397. * as well as binding the different shadow properties to the effects.
  66398. */
  66399. export interface IShadowLight extends Light {
  66400. /**
  66401. * The light id in the scene (used in scene.findLighById for instance)
  66402. */
  66403. id: string;
  66404. /**
  66405. * The position the shdow will be casted from.
  66406. */
  66407. position: Vector3;
  66408. /**
  66409. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66410. */
  66411. direction: Vector3;
  66412. /**
  66413. * The transformed position. Position of the light in world space taking parenting in account.
  66414. */
  66415. transformedPosition: Vector3;
  66416. /**
  66417. * The transformed direction. Direction of the light in world space taking parenting in account.
  66418. */
  66419. transformedDirection: Vector3;
  66420. /**
  66421. * The friendly name of the light in the scene.
  66422. */
  66423. name: string;
  66424. /**
  66425. * Defines the shadow projection clipping minimum z value.
  66426. */
  66427. shadowMinZ: number;
  66428. /**
  66429. * Defines the shadow projection clipping maximum z value.
  66430. */
  66431. shadowMaxZ: number;
  66432. /**
  66433. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66434. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66435. */
  66436. computeTransformedInformation(): boolean;
  66437. /**
  66438. * Gets the scene the light belongs to.
  66439. * @returns The scene
  66440. */
  66441. getScene(): Scene;
  66442. /**
  66443. * Callback defining a custom Projection Matrix Builder.
  66444. * This can be used to override the default projection matrix computation.
  66445. */
  66446. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66447. /**
  66448. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66449. * @param matrix The materix to updated with the projection information
  66450. * @param viewMatrix The transform matrix of the light
  66451. * @param renderList The list of mesh to render in the map
  66452. * @returns The current light
  66453. */
  66454. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66455. /**
  66456. * Gets the current depth scale used in ESM.
  66457. * @returns The scale
  66458. */
  66459. getDepthScale(): number;
  66460. /**
  66461. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66462. * @returns true if a cube texture needs to be use
  66463. */
  66464. needCube(): boolean;
  66465. /**
  66466. * Detects if the projection matrix requires to be recomputed this frame.
  66467. * @returns true if it requires to be recomputed otherwise, false.
  66468. */
  66469. needProjectionMatrixCompute(): boolean;
  66470. /**
  66471. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66472. */
  66473. forceProjectionMatrixCompute(): void;
  66474. /**
  66475. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66476. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66477. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66478. */
  66479. getShadowDirection(faceIndex?: number): Vector3;
  66480. /**
  66481. * Gets the minZ used for shadow according to both the scene and the light.
  66482. * @param activeCamera The camera we are returning the min for
  66483. * @returns the depth min z
  66484. */
  66485. getDepthMinZ(activeCamera: Camera): number;
  66486. /**
  66487. * Gets the maxZ used for shadow according to both the scene and the light.
  66488. * @param activeCamera The camera we are returning the max for
  66489. * @returns the depth max z
  66490. */
  66491. getDepthMaxZ(activeCamera: Camera): number;
  66492. }
  66493. /**
  66494. * Base implementation IShadowLight
  66495. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66496. */
  66497. export abstract class ShadowLight extends Light implements IShadowLight {
  66498. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66499. protected _position: Vector3;
  66500. protected _setPosition(value: Vector3): void;
  66501. /**
  66502. * Sets the position the shadow will be casted from. Also use as the light position for both
  66503. * point and spot lights.
  66504. */
  66505. /**
  66506. * Sets the position the shadow will be casted from. Also use as the light position for both
  66507. * point and spot lights.
  66508. */
  66509. position: Vector3;
  66510. protected _direction: Vector3;
  66511. protected _setDirection(value: Vector3): void;
  66512. /**
  66513. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66514. * Also use as the light direction on spot and directional lights.
  66515. */
  66516. /**
  66517. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66518. * Also use as the light direction on spot and directional lights.
  66519. */
  66520. direction: Vector3;
  66521. private _shadowMinZ;
  66522. /**
  66523. * Gets the shadow projection clipping minimum z value.
  66524. */
  66525. /**
  66526. * Sets the shadow projection clipping minimum z value.
  66527. */
  66528. shadowMinZ: number;
  66529. private _shadowMaxZ;
  66530. /**
  66531. * Sets the shadow projection clipping maximum z value.
  66532. */
  66533. /**
  66534. * Gets the shadow projection clipping maximum z value.
  66535. */
  66536. shadowMaxZ: number;
  66537. /**
  66538. * Callback defining a custom Projection Matrix Builder.
  66539. * This can be used to override the default projection matrix computation.
  66540. */
  66541. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66542. /**
  66543. * The transformed position. Position of the light in world space taking parenting in account.
  66544. */
  66545. transformedPosition: Vector3;
  66546. /**
  66547. * The transformed direction. Direction of the light in world space taking parenting in account.
  66548. */
  66549. transformedDirection: Vector3;
  66550. private _needProjectionMatrixCompute;
  66551. /**
  66552. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66553. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66554. */
  66555. computeTransformedInformation(): boolean;
  66556. /**
  66557. * Return the depth scale used for the shadow map.
  66558. * @returns the depth scale.
  66559. */
  66560. getDepthScale(): number;
  66561. /**
  66562. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66563. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66564. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66565. */
  66566. getShadowDirection(faceIndex?: number): Vector3;
  66567. /**
  66568. * Returns the ShadowLight absolute position in the World.
  66569. * @returns the position vector in world space
  66570. */
  66571. getAbsolutePosition(): Vector3;
  66572. /**
  66573. * Sets the ShadowLight direction toward the passed target.
  66574. * @param target The point to target in local space
  66575. * @returns the updated ShadowLight direction
  66576. */
  66577. setDirectionToTarget(target: Vector3): Vector3;
  66578. /**
  66579. * Returns the light rotation in euler definition.
  66580. * @returns the x y z rotation in local space.
  66581. */
  66582. getRotation(): Vector3;
  66583. /**
  66584. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66585. * @returns true if a cube texture needs to be use
  66586. */
  66587. needCube(): boolean;
  66588. /**
  66589. * Detects if the projection matrix requires to be recomputed this frame.
  66590. * @returns true if it requires to be recomputed otherwise, false.
  66591. */
  66592. needProjectionMatrixCompute(): boolean;
  66593. /**
  66594. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66595. */
  66596. forceProjectionMatrixCompute(): void;
  66597. /** @hidden */
  66598. _initCache(): void;
  66599. /** @hidden */
  66600. _isSynchronized(): boolean;
  66601. /**
  66602. * Computes the world matrix of the node
  66603. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66604. * @returns the world matrix
  66605. */
  66606. computeWorldMatrix(force?: boolean): Matrix;
  66607. /**
  66608. * Gets the minZ used for shadow according to both the scene and the light.
  66609. * @param activeCamera The camera we are returning the min for
  66610. * @returns the depth min z
  66611. */
  66612. getDepthMinZ(activeCamera: Camera): number;
  66613. /**
  66614. * Gets the maxZ used for shadow according to both the scene and the light.
  66615. * @param activeCamera The camera we are returning the max for
  66616. * @returns the depth max z
  66617. */
  66618. getDepthMaxZ(activeCamera: Camera): number;
  66619. /**
  66620. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66621. * @param matrix The materix to updated with the projection information
  66622. * @param viewMatrix The transform matrix of the light
  66623. * @param renderList The list of mesh to render in the map
  66624. * @returns The current light
  66625. */
  66626. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66627. }
  66628. }
  66629. declare module BABYLON {
  66630. /**
  66631. * "Static Class" containing the most commonly used helper while dealing with material for
  66632. * rendering purpose.
  66633. *
  66634. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66635. *
  66636. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66637. */
  66638. export class MaterialHelper {
  66639. /**
  66640. * Bind the current view position to an effect.
  66641. * @param effect The effect to be bound
  66642. * @param scene The scene the eyes position is used from
  66643. */
  66644. static BindEyePosition(effect: Effect, scene: Scene): void;
  66645. /**
  66646. * Helps preparing the defines values about the UVs in used in the effect.
  66647. * UVs are shared as much as we can accross channels in the shaders.
  66648. * @param texture The texture we are preparing the UVs for
  66649. * @param defines The defines to update
  66650. * @param key The channel key "diffuse", "specular"... used in the shader
  66651. */
  66652. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66653. /**
  66654. * Binds a texture matrix value to its corrsponding uniform
  66655. * @param texture The texture to bind the matrix for
  66656. * @param uniformBuffer The uniform buffer receivin the data
  66657. * @param key The channel key "diffuse", "specular"... used in the shader
  66658. */
  66659. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66660. /**
  66661. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66662. * @param mesh defines the current mesh
  66663. * @param scene defines the current scene
  66664. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66665. * @param pointsCloud defines if point cloud rendering has to be turned on
  66666. * @param fogEnabled defines if fog has to be turned on
  66667. * @param alphaTest defines if alpha testing has to be turned on
  66668. * @param defines defines the current list of defines
  66669. */
  66670. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66671. /**
  66672. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66673. * @param scene defines the current scene
  66674. * @param engine defines the current engine
  66675. * @param defines specifies the list of active defines
  66676. * @param useInstances defines if instances have to be turned on
  66677. * @param useClipPlane defines if clip plane have to be turned on
  66678. */
  66679. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66680. /**
  66681. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66682. * @param mesh The mesh containing the geometry data we will draw
  66683. * @param defines The defines to update
  66684. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66685. * @param useBones Precise whether bones should be used or not (override mesh info)
  66686. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66687. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66688. * @returns false if defines are considered not dirty and have not been checked
  66689. */
  66690. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66691. /**
  66692. * Prepares the defines related to the light information passed in parameter
  66693. * @param scene The scene we are intending to draw
  66694. * @param mesh The mesh the effect is compiling for
  66695. * @param defines The defines to update
  66696. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66697. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66698. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66699. * @returns true if normals will be required for the rest of the effect
  66700. */
  66701. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66702. /**
  66703. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66704. * that won t be acctive due to defines being turned off.
  66705. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66706. * @param samplersList The samplers list
  66707. * @param defines The defines helping in the list generation
  66708. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66709. */
  66710. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66711. /**
  66712. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66713. * @param defines The defines to update while falling back
  66714. * @param fallbacks The authorized effect fallbacks
  66715. * @param maxSimultaneousLights The maximum number of lights allowed
  66716. * @param rank the current rank of the Effect
  66717. * @returns The newly affected rank
  66718. */
  66719. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66720. /**
  66721. * Prepares the list of attributes required for morph targets according to the effect defines.
  66722. * @param attribs The current list of supported attribs
  66723. * @param mesh The mesh to prepare the morph targets attributes for
  66724. * @param defines The current Defines of the effect
  66725. */
  66726. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66727. /**
  66728. * Prepares the list of attributes required for bones according to the effect defines.
  66729. * @param attribs The current list of supported attribs
  66730. * @param mesh The mesh to prepare the bones attributes for
  66731. * @param defines The current Defines of the effect
  66732. * @param fallbacks The current efffect fallback strategy
  66733. */
  66734. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66735. /**
  66736. * Prepares the list of attributes required for instances according to the effect defines.
  66737. * @param attribs The current list of supported attribs
  66738. * @param defines The current Defines of the effect
  66739. */
  66740. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66741. /**
  66742. * Binds the light shadow information to the effect for the given mesh.
  66743. * @param light The light containing the generator
  66744. * @param scene The scene the lights belongs to
  66745. * @param mesh The mesh we are binding the information to render
  66746. * @param lightIndex The light index in the effect used to render the mesh
  66747. * @param effect The effect we are binding the data to
  66748. */
  66749. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66750. /**
  66751. * Binds the light information to the effect.
  66752. * @param light The light containing the generator
  66753. * @param effect The effect we are binding the data to
  66754. * @param lightIndex The light index in the effect used to render
  66755. */
  66756. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66757. /**
  66758. * Binds the lights information from the scene to the effect for the given mesh.
  66759. * @param scene The scene the lights belongs to
  66760. * @param mesh The mesh we are binding the information to render
  66761. * @param effect The effect we are binding the data to
  66762. * @param defines The generated defines for the effect
  66763. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66764. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66765. */
  66766. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66767. private static _tempFogColor;
  66768. /**
  66769. * Binds the fog information from the scene to the effect for the given mesh.
  66770. * @param scene The scene the lights belongs to
  66771. * @param mesh The mesh we are binding the information to render
  66772. * @param effect The effect we are binding the data to
  66773. * @param linearSpace Defines if the fog effect is applied in linear space
  66774. */
  66775. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66776. /**
  66777. * Binds the bones information from the mesh to the effect.
  66778. * @param mesh The mesh we are binding the information to render
  66779. * @param effect The effect we are binding the data to
  66780. */
  66781. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66782. /**
  66783. * Binds the morph targets information from the mesh to the effect.
  66784. * @param abstractMesh The mesh we are binding the information to render
  66785. * @param effect The effect we are binding the data to
  66786. */
  66787. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66788. /**
  66789. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66790. * @param defines The generated defines used in the effect
  66791. * @param effect The effect we are binding the data to
  66792. * @param scene The scene we are willing to render with logarithmic scale for
  66793. */
  66794. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66795. /**
  66796. * Binds the clip plane information from the scene to the effect.
  66797. * @param scene The scene the clip plane information are extracted from
  66798. * @param effect The effect we are binding the data to
  66799. */
  66800. static BindClipPlane(effect: Effect, scene: Scene): void;
  66801. }
  66802. }
  66803. declare module BABYLON {
  66804. /** @hidden */
  66805. export var kernelBlurVaryingDeclaration: {
  66806. name: string;
  66807. shader: string;
  66808. };
  66809. }
  66810. declare module BABYLON {
  66811. /** @hidden */
  66812. export var kernelBlurFragment: {
  66813. name: string;
  66814. shader: string;
  66815. };
  66816. }
  66817. declare module BABYLON {
  66818. /** @hidden */
  66819. export var kernelBlurFragment2: {
  66820. name: string;
  66821. shader: string;
  66822. };
  66823. }
  66824. declare module BABYLON {
  66825. /** @hidden */
  66826. export var kernelBlurPixelShader: {
  66827. name: string;
  66828. shader: string;
  66829. };
  66830. }
  66831. declare module BABYLON {
  66832. /** @hidden */
  66833. export var kernelBlurVertex: {
  66834. name: string;
  66835. shader: string;
  66836. };
  66837. }
  66838. declare module BABYLON {
  66839. /** @hidden */
  66840. export var kernelBlurVertexShader: {
  66841. name: string;
  66842. shader: string;
  66843. };
  66844. }
  66845. declare module BABYLON {
  66846. /**
  66847. * The Blur Post Process which blurs an image based on a kernel and direction.
  66848. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66849. */
  66850. export class BlurPostProcess extends PostProcess {
  66851. /** The direction in which to blur the image. */
  66852. direction: Vector2;
  66853. private blockCompilation;
  66854. protected _kernel: number;
  66855. protected _idealKernel: number;
  66856. protected _packedFloat: boolean;
  66857. private _staticDefines;
  66858. /**
  66859. * Sets the length in pixels of the blur sample region
  66860. */
  66861. /**
  66862. * Gets the length in pixels of the blur sample region
  66863. */
  66864. kernel: number;
  66865. /**
  66866. * Sets wether or not the blur needs to unpack/repack floats
  66867. */
  66868. /**
  66869. * Gets wether or not the blur is unpacking/repacking floats
  66870. */
  66871. packedFloat: boolean;
  66872. /**
  66873. * Creates a new instance BlurPostProcess
  66874. * @param name The name of the effect.
  66875. * @param direction The direction in which to blur the image.
  66876. * @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.
  66877. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66878. * @param camera The camera to apply the render pass to.
  66879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66880. * @param engine The engine which the post process will be applied. (default: current engine)
  66881. * @param reusable If the post process can be reused on the same frame. (default: false)
  66882. * @param textureType Type of textures used when performing the post process. (default: 0)
  66883. * @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)
  66884. */
  66885. constructor(name: string,
  66886. /** The direction in which to blur the image. */
  66887. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66888. /**
  66889. * Updates the effect with the current post process compile time values and recompiles the shader.
  66890. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66891. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66892. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66893. * @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
  66894. * @param onCompiled Called when the shader has been compiled.
  66895. * @param onError Called if there is an error when compiling a shader.
  66896. */
  66897. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66898. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66899. /**
  66900. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66901. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66902. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66903. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66904. * The gaps between physical kernels are compensated for in the weighting of the samples
  66905. * @param idealKernel Ideal blur kernel.
  66906. * @return Nearest best kernel.
  66907. */
  66908. protected _nearestBestKernel(idealKernel: number): number;
  66909. /**
  66910. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66911. * @param x The point on the Gaussian distribution to sample.
  66912. * @return the value of the Gaussian function at x.
  66913. */
  66914. protected _gaussianWeight(x: number): number;
  66915. /**
  66916. * Generates a string that can be used as a floating point number in GLSL.
  66917. * @param x Value to print.
  66918. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66919. * @return GLSL float string.
  66920. */
  66921. protected _glslFloat(x: number, decimalFigures?: number): string;
  66922. }
  66923. }
  66924. declare module BABYLON {
  66925. /** @hidden */
  66926. export var shadowMapPixelShader: {
  66927. name: string;
  66928. shader: string;
  66929. };
  66930. }
  66931. declare module BABYLON {
  66932. /** @hidden */
  66933. export var bonesDeclaration: {
  66934. name: string;
  66935. shader: string;
  66936. };
  66937. }
  66938. declare module BABYLON {
  66939. /** @hidden */
  66940. export var morphTargetsVertexGlobalDeclaration: {
  66941. name: string;
  66942. shader: string;
  66943. };
  66944. }
  66945. declare module BABYLON {
  66946. /** @hidden */
  66947. export var morphTargetsVertexDeclaration: {
  66948. name: string;
  66949. shader: string;
  66950. };
  66951. }
  66952. declare module BABYLON {
  66953. /** @hidden */
  66954. export var instancesDeclaration: {
  66955. name: string;
  66956. shader: string;
  66957. };
  66958. }
  66959. declare module BABYLON {
  66960. /** @hidden */
  66961. export var helperFunctions: {
  66962. name: string;
  66963. shader: string;
  66964. };
  66965. }
  66966. declare module BABYLON {
  66967. /** @hidden */
  66968. export var morphTargetsVertex: {
  66969. name: string;
  66970. shader: string;
  66971. };
  66972. }
  66973. declare module BABYLON {
  66974. /** @hidden */
  66975. export var instancesVertex: {
  66976. name: string;
  66977. shader: string;
  66978. };
  66979. }
  66980. declare module BABYLON {
  66981. /** @hidden */
  66982. export var bonesVertex: {
  66983. name: string;
  66984. shader: string;
  66985. };
  66986. }
  66987. declare module BABYLON {
  66988. /** @hidden */
  66989. export var shadowMapVertexShader: {
  66990. name: string;
  66991. shader: string;
  66992. };
  66993. }
  66994. declare module BABYLON {
  66995. /** @hidden */
  66996. export var depthBoxBlurPixelShader: {
  66997. name: string;
  66998. shader: string;
  66999. };
  67000. }
  67001. declare module BABYLON {
  67002. /**
  67003. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67004. */
  67005. export interface ICustomShaderOptions {
  67006. /**
  67007. * Gets or sets the custom shader name to use
  67008. */
  67009. shaderName: string;
  67010. /**
  67011. * The list of attribute names used in the shader
  67012. */
  67013. attributes?: string[];
  67014. /**
  67015. * The list of unifrom names used in the shader
  67016. */
  67017. uniforms?: string[];
  67018. /**
  67019. * The list of sampler names used in the shader
  67020. */
  67021. samplers?: string[];
  67022. /**
  67023. * The list of defines used in the shader
  67024. */
  67025. defines?: string[];
  67026. }
  67027. /**
  67028. * Interface to implement to create a shadow generator compatible with BJS.
  67029. */
  67030. export interface IShadowGenerator {
  67031. /**
  67032. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67033. * @returns The render target texture if present otherwise, null
  67034. */
  67035. getShadowMap(): Nullable<RenderTargetTexture>;
  67036. /**
  67037. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67038. * @returns The render target texture if the shadow map is present otherwise, null
  67039. */
  67040. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67041. /**
  67042. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67043. * @param subMesh The submesh we want to render in the shadow map
  67044. * @param useInstances Defines wether will draw in the map using instances
  67045. * @returns true if ready otherwise, false
  67046. */
  67047. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67048. /**
  67049. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67050. * @param defines Defines of the material we want to update
  67051. * @param lightIndex Index of the light in the enabled light list of the material
  67052. */
  67053. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67054. /**
  67055. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67056. * defined in the generator but impacting the effect).
  67057. * It implies the unifroms available on the materials are the standard BJS ones.
  67058. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67059. * @param effect The effect we are binfing the information for
  67060. */
  67061. bindShadowLight(lightIndex: string, effect: Effect): void;
  67062. /**
  67063. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67064. * (eq to shadow prjection matrix * light transform matrix)
  67065. * @returns The transform matrix used to create the shadow map
  67066. */
  67067. getTransformMatrix(): Matrix;
  67068. /**
  67069. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67070. * Cube and 2D textures for instance.
  67071. */
  67072. recreateShadowMap(): void;
  67073. /**
  67074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67075. * @param onCompiled Callback triggered at the and of the effects compilation
  67076. * @param options Sets of optional options forcing the compilation with different modes
  67077. */
  67078. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67079. useInstances: boolean;
  67080. }>): void;
  67081. /**
  67082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67083. * @param options Sets of optional options forcing the compilation with different modes
  67084. * @returns A promise that resolves when the compilation completes
  67085. */
  67086. forceCompilationAsync(options?: Partial<{
  67087. useInstances: boolean;
  67088. }>): Promise<void>;
  67089. /**
  67090. * Serializes the shadow generator setup to a json object.
  67091. * @returns The serialized JSON object
  67092. */
  67093. serialize(): any;
  67094. /**
  67095. * Disposes the Shadow map and related Textures and effects.
  67096. */
  67097. dispose(): void;
  67098. }
  67099. /**
  67100. * Default implementation IShadowGenerator.
  67101. * This is the main object responsible of generating shadows in the framework.
  67102. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67103. */
  67104. export class ShadowGenerator implements IShadowGenerator {
  67105. /**
  67106. * Shadow generator mode None: no filtering applied.
  67107. */
  67108. static readonly FILTER_NONE: number;
  67109. /**
  67110. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67111. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67112. */
  67113. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67114. /**
  67115. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67116. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67117. */
  67118. static readonly FILTER_POISSONSAMPLING: number;
  67119. /**
  67120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67122. */
  67123. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67124. /**
  67125. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67126. * edge artifacts on steep falloff.
  67127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67128. */
  67129. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67130. /**
  67131. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67132. * edge artifacts on steep falloff.
  67133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67134. */
  67135. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67136. /**
  67137. * Shadow generator mode PCF: Percentage Closer Filtering
  67138. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67139. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67140. */
  67141. static readonly FILTER_PCF: number;
  67142. /**
  67143. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67144. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67145. * Contact Hardening
  67146. */
  67147. static readonly FILTER_PCSS: number;
  67148. /**
  67149. * Reserved for PCF and PCSS
  67150. * Highest Quality.
  67151. *
  67152. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67153. *
  67154. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67155. */
  67156. static readonly QUALITY_HIGH: number;
  67157. /**
  67158. * Reserved for PCF and PCSS
  67159. * Good tradeoff for quality/perf cross devices
  67160. *
  67161. * Execute PCF on a 3*3 kernel.
  67162. *
  67163. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67164. */
  67165. static readonly QUALITY_MEDIUM: number;
  67166. /**
  67167. * Reserved for PCF and PCSS
  67168. * The lowest quality but the fastest.
  67169. *
  67170. * Execute PCF on a 1*1 kernel.
  67171. *
  67172. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67173. */
  67174. static readonly QUALITY_LOW: number;
  67175. /** Gets or sets the custom shader name to use */
  67176. customShaderOptions: ICustomShaderOptions;
  67177. /**
  67178. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67179. */
  67180. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67181. /**
  67182. * Observable triggered before a mesh is rendered in the shadow map.
  67183. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67184. */
  67185. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67186. private _bias;
  67187. /**
  67188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67189. */
  67190. /**
  67191. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67192. */
  67193. bias: number;
  67194. private _normalBias;
  67195. /**
  67196. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67197. */
  67198. /**
  67199. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67200. */
  67201. normalBias: number;
  67202. private _blurBoxOffset;
  67203. /**
  67204. * Gets the blur box offset: offset applied during the blur pass.
  67205. * Only useful if useKernelBlur = false
  67206. */
  67207. /**
  67208. * Sets the blur box offset: offset applied during the blur pass.
  67209. * Only useful if useKernelBlur = false
  67210. */
  67211. blurBoxOffset: number;
  67212. private _blurScale;
  67213. /**
  67214. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67215. * 2 means half of the size.
  67216. */
  67217. /**
  67218. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67219. * 2 means half of the size.
  67220. */
  67221. blurScale: number;
  67222. private _blurKernel;
  67223. /**
  67224. * Gets the blur kernel: kernel size of the blur pass.
  67225. * Only useful if useKernelBlur = true
  67226. */
  67227. /**
  67228. * Sets the blur kernel: kernel size of the blur pass.
  67229. * Only useful if useKernelBlur = true
  67230. */
  67231. blurKernel: number;
  67232. private _useKernelBlur;
  67233. /**
  67234. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67235. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67236. */
  67237. /**
  67238. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67239. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67240. */
  67241. useKernelBlur: boolean;
  67242. private _depthScale;
  67243. /**
  67244. * Gets the depth scale used in ESM mode.
  67245. */
  67246. /**
  67247. * Sets the depth scale used in ESM mode.
  67248. * This can override the scale stored on the light.
  67249. */
  67250. depthScale: number;
  67251. private _filter;
  67252. /**
  67253. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67254. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67255. */
  67256. /**
  67257. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67258. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67259. */
  67260. filter: number;
  67261. /**
  67262. * Gets if the current filter is set to Poisson Sampling.
  67263. */
  67264. /**
  67265. * Sets the current filter to Poisson Sampling.
  67266. */
  67267. usePoissonSampling: boolean;
  67268. /**
  67269. * Gets if the current filter is set to ESM.
  67270. */
  67271. /**
  67272. * Sets the current filter is to ESM.
  67273. */
  67274. useExponentialShadowMap: boolean;
  67275. /**
  67276. * Gets if the current filter is set to filtered ESM.
  67277. */
  67278. /**
  67279. * Gets if the current filter is set to filtered ESM.
  67280. */
  67281. useBlurExponentialShadowMap: boolean;
  67282. /**
  67283. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67284. * exponential to prevent steep falloff artifacts).
  67285. */
  67286. /**
  67287. * Sets the current filter to "close ESM" (using the inverse of the
  67288. * exponential to prevent steep falloff artifacts).
  67289. */
  67290. useCloseExponentialShadowMap: boolean;
  67291. /**
  67292. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67293. * exponential to prevent steep falloff artifacts).
  67294. */
  67295. /**
  67296. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67297. * exponential to prevent steep falloff artifacts).
  67298. */
  67299. useBlurCloseExponentialShadowMap: boolean;
  67300. /**
  67301. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67302. */
  67303. /**
  67304. * Sets the current filter to "PCF" (percentage closer filtering).
  67305. */
  67306. usePercentageCloserFiltering: boolean;
  67307. private _filteringQuality;
  67308. /**
  67309. * Gets the PCF or PCSS Quality.
  67310. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67311. */
  67312. /**
  67313. * Sets the PCF or PCSS Quality.
  67314. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67315. */
  67316. filteringQuality: number;
  67317. /**
  67318. * Gets if the current filter is set to "PCSS" (contact hardening).
  67319. */
  67320. /**
  67321. * Sets the current filter to "PCSS" (contact hardening).
  67322. */
  67323. useContactHardeningShadow: boolean;
  67324. private _contactHardeningLightSizeUVRatio;
  67325. /**
  67326. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67327. * Using a ratio helps keeping shape stability independently of the map size.
  67328. *
  67329. * It does not account for the light projection as it was having too much
  67330. * instability during the light setup or during light position changes.
  67331. *
  67332. * Only valid if useContactHardeningShadow is true.
  67333. */
  67334. /**
  67335. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67336. * Using a ratio helps keeping shape stability independently of the map size.
  67337. *
  67338. * It does not account for the light projection as it was having too much
  67339. * instability during the light setup or during light position changes.
  67340. *
  67341. * Only valid if useContactHardeningShadow is true.
  67342. */
  67343. contactHardeningLightSizeUVRatio: number;
  67344. private _darkness;
  67345. /**
  67346. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67347. * 0 means strongest and 1 would means no shadow.
  67348. * @returns the darkness.
  67349. */
  67350. getDarkness(): number;
  67351. /**
  67352. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67353. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67354. * @returns the shadow generator allowing fluent coding.
  67355. */
  67356. setDarkness(darkness: number): ShadowGenerator;
  67357. private _transparencyShadow;
  67358. /**
  67359. * Sets the ability to have transparent shadow (boolean).
  67360. * @param transparent True if transparent else False
  67361. * @returns the shadow generator allowing fluent coding
  67362. */
  67363. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67364. private _shadowMap;
  67365. private _shadowMap2;
  67366. /**
  67367. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67368. * @returns The render target texture if present otherwise, null
  67369. */
  67370. getShadowMap(): Nullable<RenderTargetTexture>;
  67371. /**
  67372. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67373. * @returns The render target texture if the shadow map is present otherwise, null
  67374. */
  67375. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67376. /**
  67377. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67378. * @param mesh Mesh to add
  67379. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67380. * @returns the Shadow Generator itself
  67381. */
  67382. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67383. /**
  67384. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67385. * @param mesh Mesh to remove
  67386. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67387. * @returns the Shadow Generator itself
  67388. */
  67389. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67390. /**
  67391. * Controls the extent to which the shadows fade out at the edge of the frustum
  67392. * Used only by directionals and spots
  67393. */
  67394. frustumEdgeFalloff: number;
  67395. private _light;
  67396. /**
  67397. * Returns the associated light object.
  67398. * @returns the light generating the shadow
  67399. */
  67400. getLight(): IShadowLight;
  67401. /**
  67402. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67403. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67404. * It might on the other hand introduce peter panning.
  67405. */
  67406. forceBackFacesOnly: boolean;
  67407. private _scene;
  67408. private _lightDirection;
  67409. private _effect;
  67410. private _viewMatrix;
  67411. private _projectionMatrix;
  67412. private _transformMatrix;
  67413. private _cachedPosition;
  67414. private _cachedDirection;
  67415. private _cachedDefines;
  67416. private _currentRenderID;
  67417. private _boxBlurPostprocess;
  67418. private _kernelBlurXPostprocess;
  67419. private _kernelBlurYPostprocess;
  67420. private _blurPostProcesses;
  67421. private _mapSize;
  67422. private _currentFaceIndex;
  67423. private _currentFaceIndexCache;
  67424. private _textureType;
  67425. private _defaultTextureMatrix;
  67426. /** @hidden */
  67427. static _SceneComponentInitialization: (scene: Scene) => void;
  67428. /**
  67429. * Creates a ShadowGenerator object.
  67430. * A ShadowGenerator is the required tool to use the shadows.
  67431. * Each light casting shadows needs to use its own ShadowGenerator.
  67432. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67433. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67434. * @param light The light object generating the shadows.
  67435. * @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.
  67436. */
  67437. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67438. private _initializeGenerator;
  67439. private _initializeShadowMap;
  67440. private _initializeBlurRTTAndPostProcesses;
  67441. private _renderForShadowMap;
  67442. private _renderSubMeshForShadowMap;
  67443. private _applyFilterValues;
  67444. /**
  67445. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67446. * @param onCompiled Callback triggered at the and of the effects compilation
  67447. * @param options Sets of optional options forcing the compilation with different modes
  67448. */
  67449. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67450. useInstances: boolean;
  67451. }>): void;
  67452. /**
  67453. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67454. * @param options Sets of optional options forcing the compilation with different modes
  67455. * @returns A promise that resolves when the compilation completes
  67456. */
  67457. forceCompilationAsync(options?: Partial<{
  67458. useInstances: boolean;
  67459. }>): Promise<void>;
  67460. /**
  67461. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67462. * @param subMesh The submesh we want to render in the shadow map
  67463. * @param useInstances Defines wether will draw in the map using instances
  67464. * @returns true if ready otherwise, false
  67465. */
  67466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67467. /**
  67468. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67469. * @param defines Defines of the material we want to update
  67470. * @param lightIndex Index of the light in the enabled light list of the material
  67471. */
  67472. prepareDefines(defines: any, lightIndex: number): void;
  67473. /**
  67474. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67475. * defined in the generator but impacting the effect).
  67476. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67477. * @param effect The effect we are binfing the information for
  67478. */
  67479. bindShadowLight(lightIndex: string, effect: Effect): void;
  67480. /**
  67481. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67482. * (eq to shadow prjection matrix * light transform matrix)
  67483. * @returns The transform matrix used to create the shadow map
  67484. */
  67485. getTransformMatrix(): Matrix;
  67486. /**
  67487. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67488. * Cube and 2D textures for instance.
  67489. */
  67490. recreateShadowMap(): void;
  67491. private _disposeBlurPostProcesses;
  67492. private _disposeRTTandPostProcesses;
  67493. /**
  67494. * Disposes the ShadowGenerator.
  67495. * Returns nothing.
  67496. */
  67497. dispose(): void;
  67498. /**
  67499. * Serializes the shadow generator setup to a json object.
  67500. * @returns The serialized JSON object
  67501. */
  67502. serialize(): any;
  67503. /**
  67504. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67505. * @param parsedShadowGenerator The JSON object to parse
  67506. * @param scene The scene to create the shadow map for
  67507. * @returns The parsed shadow generator
  67508. */
  67509. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67510. }
  67511. }
  67512. declare module BABYLON {
  67513. /**
  67514. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67515. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67516. * 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.
  67517. */
  67518. export abstract class Light extends Node {
  67519. /**
  67520. * Falloff Default: light is falling off following the material specification:
  67521. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67522. */
  67523. static readonly FALLOFF_DEFAULT: number;
  67524. /**
  67525. * Falloff Physical: light is falling off following the inverse squared distance law.
  67526. */
  67527. static readonly FALLOFF_PHYSICAL: number;
  67528. /**
  67529. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67530. * to enhance interoperability with other engines.
  67531. */
  67532. static readonly FALLOFF_GLTF: number;
  67533. /**
  67534. * Falloff Standard: light is falling off like in the standard material
  67535. * to enhance interoperability with other materials.
  67536. */
  67537. static readonly FALLOFF_STANDARD: number;
  67538. /**
  67539. * If every light affecting the material is in this lightmapMode,
  67540. * material.lightmapTexture adds or multiplies
  67541. * (depends on material.useLightmapAsShadowmap)
  67542. * after every other light calculations.
  67543. */
  67544. static readonly LIGHTMAP_DEFAULT: number;
  67545. /**
  67546. * material.lightmapTexture as only diffuse lighting from this light
  67547. * adds only specular lighting from this light
  67548. * adds dynamic shadows
  67549. */
  67550. static readonly LIGHTMAP_SPECULAR: number;
  67551. /**
  67552. * material.lightmapTexture as only lighting
  67553. * no light calculation from this light
  67554. * only adds dynamic shadows from this light
  67555. */
  67556. static readonly LIGHTMAP_SHADOWSONLY: number;
  67557. /**
  67558. * Each light type uses the default quantity according to its type:
  67559. * point/spot lights use luminous intensity
  67560. * directional lights use illuminance
  67561. */
  67562. static readonly INTENSITYMODE_AUTOMATIC: number;
  67563. /**
  67564. * lumen (lm)
  67565. */
  67566. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67567. /**
  67568. * candela (lm/sr)
  67569. */
  67570. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67571. /**
  67572. * lux (lm/m^2)
  67573. */
  67574. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67575. /**
  67576. * nit (cd/m^2)
  67577. */
  67578. static readonly INTENSITYMODE_LUMINANCE: number;
  67579. /**
  67580. * Light type const id of the point light.
  67581. */
  67582. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67583. /**
  67584. * Light type const id of the directional light.
  67585. */
  67586. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67587. /**
  67588. * Light type const id of the spot light.
  67589. */
  67590. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67591. /**
  67592. * Light type const id of the hemispheric light.
  67593. */
  67594. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67595. /**
  67596. * Diffuse gives the basic color to an object.
  67597. */
  67598. diffuse: Color3;
  67599. /**
  67600. * Specular produces a highlight color on an object.
  67601. * Note: This is note affecting PBR materials.
  67602. */
  67603. specular: Color3;
  67604. /**
  67605. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67606. * falling off base on range or angle.
  67607. * This can be set to any values in Light.FALLOFF_x.
  67608. *
  67609. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67610. * other types of materials.
  67611. */
  67612. falloffType: number;
  67613. /**
  67614. * Strength of the light.
  67615. * Note: By default it is define in the framework own unit.
  67616. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67617. */
  67618. intensity: number;
  67619. private _range;
  67620. protected _inverseSquaredRange: number;
  67621. /**
  67622. * Defines how far from the source the light is impacting in scene units.
  67623. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67624. */
  67625. /**
  67626. * Defines how far from the source the light is impacting in scene units.
  67627. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67628. */
  67629. range: number;
  67630. /**
  67631. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67632. * of light.
  67633. */
  67634. private _photometricScale;
  67635. private _intensityMode;
  67636. /**
  67637. * Gets the photometric scale used to interpret the intensity.
  67638. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67639. */
  67640. /**
  67641. * Sets the photometric scale used to interpret the intensity.
  67642. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67643. */
  67644. intensityMode: number;
  67645. private _radius;
  67646. /**
  67647. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67648. */
  67649. /**
  67650. * sets the light radius used by PBR Materials to simulate soft area lights.
  67651. */
  67652. radius: number;
  67653. private _renderPriority;
  67654. /**
  67655. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67656. * exceeding the number allowed of the materials.
  67657. */
  67658. renderPriority: number;
  67659. private _shadowEnabled;
  67660. /**
  67661. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67662. * the current shadow generator.
  67663. */
  67664. /**
  67665. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67666. * the current shadow generator.
  67667. */
  67668. shadowEnabled: boolean;
  67669. private _includedOnlyMeshes;
  67670. /**
  67671. * Gets the only meshes impacted by this light.
  67672. */
  67673. /**
  67674. * Sets the only meshes impacted by this light.
  67675. */
  67676. includedOnlyMeshes: AbstractMesh[];
  67677. private _excludedMeshes;
  67678. /**
  67679. * Gets the meshes not impacted by this light.
  67680. */
  67681. /**
  67682. * Sets the meshes not impacted by this light.
  67683. */
  67684. excludedMeshes: AbstractMesh[];
  67685. private _excludeWithLayerMask;
  67686. /**
  67687. * Gets the layer id use to find what meshes are not impacted by the light.
  67688. * Inactive if 0
  67689. */
  67690. /**
  67691. * Sets the layer id use to find what meshes are not impacted by the light.
  67692. * Inactive if 0
  67693. */
  67694. excludeWithLayerMask: number;
  67695. private _includeOnlyWithLayerMask;
  67696. /**
  67697. * Gets the layer id use to find what meshes are impacted by the light.
  67698. * Inactive if 0
  67699. */
  67700. /**
  67701. * Sets the layer id use to find what meshes are impacted by the light.
  67702. * Inactive if 0
  67703. */
  67704. includeOnlyWithLayerMask: number;
  67705. private _lightmapMode;
  67706. /**
  67707. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67708. */
  67709. /**
  67710. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67711. */
  67712. lightmapMode: number;
  67713. /**
  67714. * Shadow generator associted to the light.
  67715. * @hidden Internal use only.
  67716. */
  67717. _shadowGenerator: Nullable<IShadowGenerator>;
  67718. /**
  67719. * @hidden Internal use only.
  67720. */
  67721. _excludedMeshesIds: string[];
  67722. /**
  67723. * @hidden Internal use only.
  67724. */
  67725. _includedOnlyMeshesIds: string[];
  67726. /**
  67727. * The current light unifom buffer.
  67728. * @hidden Internal use only.
  67729. */
  67730. _uniformBuffer: UniformBuffer;
  67731. /**
  67732. * Creates a Light object in the scene.
  67733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67734. * @param name The firendly name of the light
  67735. * @param scene The scene the light belongs too
  67736. */
  67737. constructor(name: string, scene: Scene);
  67738. protected abstract _buildUniformLayout(): void;
  67739. /**
  67740. * Sets the passed Effect "effect" with the Light information.
  67741. * @param effect The effect to update
  67742. * @param lightIndex The index of the light in the effect to update
  67743. * @returns The light
  67744. */
  67745. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67746. /**
  67747. * Returns the string "Light".
  67748. * @returns the class name
  67749. */
  67750. getClassName(): string;
  67751. /** @hidden */
  67752. readonly _isLight: boolean;
  67753. /**
  67754. * Converts the light information to a readable string for debug purpose.
  67755. * @param fullDetails Supports for multiple levels of logging within scene loading
  67756. * @returns the human readable light info
  67757. */
  67758. toString(fullDetails?: boolean): string;
  67759. /** @hidden */
  67760. protected _syncParentEnabledState(): void;
  67761. /**
  67762. * Set the enabled state of this node.
  67763. * @param value - the new enabled state
  67764. */
  67765. setEnabled(value: boolean): void;
  67766. /**
  67767. * Returns the Light associated shadow generator if any.
  67768. * @return the associated shadow generator.
  67769. */
  67770. getShadowGenerator(): Nullable<IShadowGenerator>;
  67771. /**
  67772. * Returns a Vector3, the absolute light position in the World.
  67773. * @returns the world space position of the light
  67774. */
  67775. getAbsolutePosition(): Vector3;
  67776. /**
  67777. * Specifies if the light will affect the passed mesh.
  67778. * @param mesh The mesh to test against the light
  67779. * @return true the mesh is affected otherwise, false.
  67780. */
  67781. canAffectMesh(mesh: AbstractMesh): boolean;
  67782. /**
  67783. * Sort function to order lights for rendering.
  67784. * @param a First Light object to compare to second.
  67785. * @param b Second Light object to compare first.
  67786. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67787. */
  67788. static CompareLightsPriority(a: Light, b: Light): number;
  67789. /**
  67790. * Releases resources associated with this node.
  67791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67793. */
  67794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67795. /**
  67796. * Returns the light type ID (integer).
  67797. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67798. */
  67799. getTypeID(): number;
  67800. /**
  67801. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67802. * @returns the scaled intensity in intensity mode unit
  67803. */
  67804. getScaledIntensity(): number;
  67805. /**
  67806. * Returns a new Light object, named "name", from the current one.
  67807. * @param name The name of the cloned light
  67808. * @returns the new created light
  67809. */
  67810. clone(name: string): Nullable<Light>;
  67811. /**
  67812. * Serializes the current light into a Serialization object.
  67813. * @returns the serialized object.
  67814. */
  67815. serialize(): any;
  67816. /**
  67817. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67818. * This new light is named "name" and added to the passed scene.
  67819. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67820. * @param name The friendly name of the light
  67821. * @param scene The scene the new light will belong to
  67822. * @returns the constructor function
  67823. */
  67824. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67825. /**
  67826. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67827. * @param parsedLight The JSON representation of the light
  67828. * @param scene The scene to create the parsed light in
  67829. * @returns the created light after parsing
  67830. */
  67831. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67832. private _hookArrayForExcluded;
  67833. private _hookArrayForIncludedOnly;
  67834. private _resyncMeshes;
  67835. /**
  67836. * Forces the meshes to update their light related information in their rendering used effects
  67837. * @hidden Internal Use Only
  67838. */
  67839. _markMeshesAsLightDirty(): void;
  67840. /**
  67841. * Recomputes the cached photometric scale if needed.
  67842. */
  67843. private _computePhotometricScale;
  67844. /**
  67845. * Returns the Photometric Scale according to the light type and intensity mode.
  67846. */
  67847. private _getPhotometricScale;
  67848. /**
  67849. * Reorder the light in the scene according to their defined priority.
  67850. * @hidden Internal Use Only
  67851. */
  67852. _reorderLightsInScene(): void;
  67853. /**
  67854. * Prepares the list of defines specific to the light type.
  67855. * @param defines the list of defines
  67856. * @param lightIndex defines the index of the light for the effect
  67857. */
  67858. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Interface used to define Action
  67864. */
  67865. export interface IAction {
  67866. /**
  67867. * Trigger for the action
  67868. */
  67869. trigger: number;
  67870. /** Options of the trigger */
  67871. triggerOptions: any;
  67872. /**
  67873. * Gets the trigger parameters
  67874. * @returns the trigger parameters
  67875. */
  67876. getTriggerParameter(): any;
  67877. /**
  67878. * Internal only - executes current action event
  67879. * @hidden
  67880. */
  67881. _executeCurrent(evt?: ActionEvent): void;
  67882. /**
  67883. * Serialize placeholder for child classes
  67884. * @param parent of child
  67885. * @returns the serialized object
  67886. */
  67887. serialize(parent: any): any;
  67888. /**
  67889. * Internal only
  67890. * @hidden
  67891. */
  67892. _prepare(): void;
  67893. /**
  67894. * Internal only - manager for action
  67895. * @hidden
  67896. */
  67897. _actionManager: AbstractActionManager;
  67898. }
  67899. /**
  67900. * The action to be carried out following a trigger
  67901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67902. */
  67903. export class Action implements IAction {
  67904. /** the trigger, with or without parameters, for the action */
  67905. triggerOptions: any;
  67906. /**
  67907. * Trigger for the action
  67908. */
  67909. trigger: number;
  67910. /**
  67911. * Internal only - manager for action
  67912. * @hidden
  67913. */
  67914. _actionManager: ActionManager;
  67915. private _nextActiveAction;
  67916. private _child;
  67917. private _condition?;
  67918. private _triggerParameter;
  67919. /**
  67920. * An event triggered prior to action being executed.
  67921. */
  67922. onBeforeExecuteObservable: Observable<Action>;
  67923. /**
  67924. * Creates a new Action
  67925. * @param triggerOptions the trigger, with or without parameters, for the action
  67926. * @param condition an optional determinant of action
  67927. */
  67928. constructor(
  67929. /** the trigger, with or without parameters, for the action */
  67930. triggerOptions: any, condition?: Condition);
  67931. /**
  67932. * Internal only
  67933. * @hidden
  67934. */
  67935. _prepare(): void;
  67936. /**
  67937. * Gets the trigger parameters
  67938. * @returns the trigger parameters
  67939. */
  67940. getTriggerParameter(): any;
  67941. /**
  67942. * Internal only - executes current action event
  67943. * @hidden
  67944. */
  67945. _executeCurrent(evt?: ActionEvent): void;
  67946. /**
  67947. * Execute placeholder for child classes
  67948. * @param evt optional action event
  67949. */
  67950. execute(evt?: ActionEvent): void;
  67951. /**
  67952. * Skips to next active action
  67953. */
  67954. skipToNextActiveAction(): void;
  67955. /**
  67956. * Adds action to chain of actions, may be a DoNothingAction
  67957. * @param action defines the next action to execute
  67958. * @returns The action passed in
  67959. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67960. */
  67961. then(action: Action): Action;
  67962. /**
  67963. * Internal only
  67964. * @hidden
  67965. */
  67966. _getProperty(propertyPath: string): string;
  67967. /**
  67968. * Internal only
  67969. * @hidden
  67970. */
  67971. _getEffectiveTarget(target: any, propertyPath: string): any;
  67972. /**
  67973. * Serialize placeholder for child classes
  67974. * @param parent of child
  67975. * @returns the serialized object
  67976. */
  67977. serialize(parent: any): any;
  67978. /**
  67979. * Internal only called by serialize
  67980. * @hidden
  67981. */
  67982. protected _serialize(serializedAction: any, parent?: any): any;
  67983. /**
  67984. * Internal only
  67985. * @hidden
  67986. */
  67987. static _SerializeValueAsString: (value: any) => string;
  67988. /**
  67989. * Internal only
  67990. * @hidden
  67991. */
  67992. static _GetTargetProperty: (target: Scene | Node) => {
  67993. name: string;
  67994. targetType: string;
  67995. value: string;
  67996. };
  67997. }
  67998. }
  67999. declare module BABYLON {
  68000. /**
  68001. * A Condition applied to an Action
  68002. */
  68003. export class Condition {
  68004. /**
  68005. * Internal only - manager for action
  68006. * @hidden
  68007. */
  68008. _actionManager: ActionManager;
  68009. /**
  68010. * Internal only
  68011. * @hidden
  68012. */
  68013. _evaluationId: number;
  68014. /**
  68015. * Internal only
  68016. * @hidden
  68017. */
  68018. _currentResult: boolean;
  68019. /**
  68020. * Creates a new Condition
  68021. * @param actionManager the manager of the action the condition is applied to
  68022. */
  68023. constructor(actionManager: ActionManager);
  68024. /**
  68025. * Check if the current condition is valid
  68026. * @returns a boolean
  68027. */
  68028. isValid(): boolean;
  68029. /**
  68030. * Internal only
  68031. * @hidden
  68032. */
  68033. _getProperty(propertyPath: string): string;
  68034. /**
  68035. * Internal only
  68036. * @hidden
  68037. */
  68038. _getEffectiveTarget(target: any, propertyPath: string): any;
  68039. /**
  68040. * Serialize placeholder for child classes
  68041. * @returns the serialized object
  68042. */
  68043. serialize(): any;
  68044. /**
  68045. * Internal only
  68046. * @hidden
  68047. */
  68048. protected _serialize(serializedCondition: any): any;
  68049. }
  68050. /**
  68051. * Defines specific conditional operators as extensions of Condition
  68052. */
  68053. export class ValueCondition extends Condition {
  68054. /** path to specify the property of the target the conditional operator uses */
  68055. propertyPath: string;
  68056. /** the value compared by the conditional operator against the current value of the property */
  68057. value: any;
  68058. /** the conditional operator, default ValueCondition.IsEqual */
  68059. operator: number;
  68060. /**
  68061. * Internal only
  68062. * @hidden
  68063. */
  68064. private static _IsEqual;
  68065. /**
  68066. * Internal only
  68067. * @hidden
  68068. */
  68069. private static _IsDifferent;
  68070. /**
  68071. * Internal only
  68072. * @hidden
  68073. */
  68074. private static _IsGreater;
  68075. /**
  68076. * Internal only
  68077. * @hidden
  68078. */
  68079. private static _IsLesser;
  68080. /**
  68081. * returns the number for IsEqual
  68082. */
  68083. static readonly IsEqual: number;
  68084. /**
  68085. * Returns the number for IsDifferent
  68086. */
  68087. static readonly IsDifferent: number;
  68088. /**
  68089. * Returns the number for IsGreater
  68090. */
  68091. static readonly IsGreater: number;
  68092. /**
  68093. * Returns the number for IsLesser
  68094. */
  68095. static readonly IsLesser: number;
  68096. /**
  68097. * Internal only The action manager for the condition
  68098. * @hidden
  68099. */
  68100. _actionManager: ActionManager;
  68101. /**
  68102. * Internal only
  68103. * @hidden
  68104. */
  68105. private _target;
  68106. /**
  68107. * Internal only
  68108. * @hidden
  68109. */
  68110. private _effectiveTarget;
  68111. /**
  68112. * Internal only
  68113. * @hidden
  68114. */
  68115. private _property;
  68116. /**
  68117. * Creates a new ValueCondition
  68118. * @param actionManager manager for the action the condition applies to
  68119. * @param target for the action
  68120. * @param propertyPath path to specify the property of the target the conditional operator uses
  68121. * @param value the value compared by the conditional operator against the current value of the property
  68122. * @param operator the conditional operator, default ValueCondition.IsEqual
  68123. */
  68124. constructor(actionManager: ActionManager, target: any,
  68125. /** path to specify the property of the target the conditional operator uses */
  68126. propertyPath: string,
  68127. /** the value compared by the conditional operator against the current value of the property */
  68128. value: any,
  68129. /** the conditional operator, default ValueCondition.IsEqual */
  68130. operator?: number);
  68131. /**
  68132. * Compares the given value with the property value for the specified conditional operator
  68133. * @returns the result of the comparison
  68134. */
  68135. isValid(): boolean;
  68136. /**
  68137. * Serialize the ValueCondition into a JSON compatible object
  68138. * @returns serialization object
  68139. */
  68140. serialize(): any;
  68141. /**
  68142. * Gets the name of the conditional operator for the ValueCondition
  68143. * @param operator the conditional operator
  68144. * @returns the name
  68145. */
  68146. static GetOperatorName(operator: number): string;
  68147. }
  68148. /**
  68149. * Defines a predicate condition as an extension of Condition
  68150. */
  68151. export class PredicateCondition extends Condition {
  68152. /** defines the predicate function used to validate the condition */
  68153. predicate: () => boolean;
  68154. /**
  68155. * Internal only - manager for action
  68156. * @hidden
  68157. */
  68158. _actionManager: ActionManager;
  68159. /**
  68160. * Creates a new PredicateCondition
  68161. * @param actionManager manager for the action the condition applies to
  68162. * @param predicate defines the predicate function used to validate the condition
  68163. */
  68164. constructor(actionManager: ActionManager,
  68165. /** defines the predicate function used to validate the condition */
  68166. predicate: () => boolean);
  68167. /**
  68168. * @returns the validity of the predicate condition
  68169. */
  68170. isValid(): boolean;
  68171. }
  68172. /**
  68173. * Defines a state condition as an extension of Condition
  68174. */
  68175. export class StateCondition extends Condition {
  68176. /** Value to compare with target state */
  68177. value: string;
  68178. /**
  68179. * Internal only - manager for action
  68180. * @hidden
  68181. */
  68182. _actionManager: ActionManager;
  68183. /**
  68184. * Internal only
  68185. * @hidden
  68186. */
  68187. private _target;
  68188. /**
  68189. * Creates a new StateCondition
  68190. * @param actionManager manager for the action the condition applies to
  68191. * @param target of the condition
  68192. * @param value to compare with target state
  68193. */
  68194. constructor(actionManager: ActionManager, target: any,
  68195. /** Value to compare with target state */
  68196. value: string);
  68197. /**
  68198. * Gets a boolean indicating if the current condition is met
  68199. * @returns the validity of the state
  68200. */
  68201. isValid(): boolean;
  68202. /**
  68203. * Serialize the StateCondition into a JSON compatible object
  68204. * @returns serialization object
  68205. */
  68206. serialize(): any;
  68207. }
  68208. }
  68209. declare module BABYLON {
  68210. /**
  68211. * This defines an action responsible to toggle a boolean once triggered.
  68212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68213. */
  68214. export class SwitchBooleanAction extends Action {
  68215. /**
  68216. * The path to the boolean property in the target object
  68217. */
  68218. propertyPath: string;
  68219. private _target;
  68220. private _effectiveTarget;
  68221. private _property;
  68222. /**
  68223. * Instantiate the action
  68224. * @param triggerOptions defines the trigger options
  68225. * @param target defines the object containing the boolean
  68226. * @param propertyPath defines the path to the boolean property in the target object
  68227. * @param condition defines the trigger related conditions
  68228. */
  68229. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68230. /** @hidden */
  68231. _prepare(): void;
  68232. /**
  68233. * Execute the action toggle the boolean value.
  68234. */
  68235. execute(): void;
  68236. /**
  68237. * Serializes the actions and its related information.
  68238. * @param parent defines the object to serialize in
  68239. * @returns the serialized object
  68240. */
  68241. serialize(parent: any): any;
  68242. }
  68243. /**
  68244. * This defines an action responsible to set a the state field of the target
  68245. * to a desired value once triggered.
  68246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68247. */
  68248. export class SetStateAction extends Action {
  68249. /**
  68250. * The value to store in the state field.
  68251. */
  68252. value: string;
  68253. private _target;
  68254. /**
  68255. * Instantiate the action
  68256. * @param triggerOptions defines the trigger options
  68257. * @param target defines the object containing the state property
  68258. * @param value defines the value to store in the state field
  68259. * @param condition defines the trigger related conditions
  68260. */
  68261. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68262. /**
  68263. * Execute the action and store the value on the target state property.
  68264. */
  68265. execute(): void;
  68266. /**
  68267. * Serializes the actions and its related information.
  68268. * @param parent defines the object to serialize in
  68269. * @returns the serialized object
  68270. */
  68271. serialize(parent: any): any;
  68272. }
  68273. /**
  68274. * This defines an action responsible to set a property of the target
  68275. * to a desired value once triggered.
  68276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68277. */
  68278. export class SetValueAction extends Action {
  68279. /**
  68280. * The path of the property to set in the target.
  68281. */
  68282. propertyPath: string;
  68283. /**
  68284. * The value to set in the property
  68285. */
  68286. value: any;
  68287. private _target;
  68288. private _effectiveTarget;
  68289. private _property;
  68290. /**
  68291. * Instantiate the action
  68292. * @param triggerOptions defines the trigger options
  68293. * @param target defines the object containing the property
  68294. * @param propertyPath defines the path of the property to set in the target
  68295. * @param value defines the value to set in the property
  68296. * @param condition defines the trigger related conditions
  68297. */
  68298. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68299. /** @hidden */
  68300. _prepare(): void;
  68301. /**
  68302. * Execute the action and set the targetted property to the desired value.
  68303. */
  68304. execute(): void;
  68305. /**
  68306. * Serializes the actions and its related information.
  68307. * @param parent defines the object to serialize in
  68308. * @returns the serialized object
  68309. */
  68310. serialize(parent: any): any;
  68311. }
  68312. /**
  68313. * This defines an action responsible to increment the target value
  68314. * to a desired value once triggered.
  68315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68316. */
  68317. export class IncrementValueAction extends Action {
  68318. /**
  68319. * The path of the property to increment in the target.
  68320. */
  68321. propertyPath: string;
  68322. /**
  68323. * The value we should increment the property by.
  68324. */
  68325. value: any;
  68326. private _target;
  68327. private _effectiveTarget;
  68328. private _property;
  68329. /**
  68330. * Instantiate the action
  68331. * @param triggerOptions defines the trigger options
  68332. * @param target defines the object containing the property
  68333. * @param propertyPath defines the path of the property to increment in the target
  68334. * @param value defines the value value we should increment the property by
  68335. * @param condition defines the trigger related conditions
  68336. */
  68337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68338. /** @hidden */
  68339. _prepare(): void;
  68340. /**
  68341. * Execute the action and increment the target of the value amount.
  68342. */
  68343. execute(): void;
  68344. /**
  68345. * Serializes the actions and its related information.
  68346. * @param parent defines the object to serialize in
  68347. * @returns the serialized object
  68348. */
  68349. serialize(parent: any): any;
  68350. }
  68351. /**
  68352. * This defines an action responsible to start an animation once triggered.
  68353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68354. */
  68355. export class PlayAnimationAction extends Action {
  68356. /**
  68357. * Where the animation should start (animation frame)
  68358. */
  68359. from: number;
  68360. /**
  68361. * Where the animation should stop (animation frame)
  68362. */
  68363. to: number;
  68364. /**
  68365. * Define if the animation should loop or stop after the first play.
  68366. */
  68367. loop?: boolean;
  68368. private _target;
  68369. /**
  68370. * Instantiate the action
  68371. * @param triggerOptions defines the trigger options
  68372. * @param target defines the target animation or animation name
  68373. * @param from defines from where the animation should start (animation frame)
  68374. * @param end defines where the animation should stop (animation frame)
  68375. * @param loop defines if the animation should loop or stop after the first play
  68376. * @param condition defines the trigger related conditions
  68377. */
  68378. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68379. /** @hidden */
  68380. _prepare(): void;
  68381. /**
  68382. * Execute the action and play the animation.
  68383. */
  68384. execute(): void;
  68385. /**
  68386. * Serializes the actions and its related information.
  68387. * @param parent defines the object to serialize in
  68388. * @returns the serialized object
  68389. */
  68390. serialize(parent: any): any;
  68391. }
  68392. /**
  68393. * This defines an action responsible to stop an animation once triggered.
  68394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68395. */
  68396. export class StopAnimationAction extends Action {
  68397. private _target;
  68398. /**
  68399. * Instantiate the action
  68400. * @param triggerOptions defines the trigger options
  68401. * @param target defines the target animation or animation name
  68402. * @param condition defines the trigger related conditions
  68403. */
  68404. constructor(triggerOptions: any, target: any, condition?: Condition);
  68405. /** @hidden */
  68406. _prepare(): void;
  68407. /**
  68408. * Execute the action and stop the animation.
  68409. */
  68410. execute(): void;
  68411. /**
  68412. * Serializes the actions and its related information.
  68413. * @param parent defines the object to serialize in
  68414. * @returns the serialized object
  68415. */
  68416. serialize(parent: any): any;
  68417. }
  68418. /**
  68419. * This defines an action responsible that does nothing once triggered.
  68420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68421. */
  68422. export class DoNothingAction extends Action {
  68423. /**
  68424. * Instantiate the action
  68425. * @param triggerOptions defines the trigger options
  68426. * @param condition defines the trigger related conditions
  68427. */
  68428. constructor(triggerOptions?: any, condition?: Condition);
  68429. /**
  68430. * Execute the action and do nothing.
  68431. */
  68432. execute(): void;
  68433. /**
  68434. * Serializes the actions and its related information.
  68435. * @param parent defines the object to serialize in
  68436. * @returns the serialized object
  68437. */
  68438. serialize(parent: any): any;
  68439. }
  68440. /**
  68441. * This defines an action responsible to trigger several actions once triggered.
  68442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68443. */
  68444. export class CombineAction extends Action {
  68445. /**
  68446. * The list of aggregated animations to run.
  68447. */
  68448. children: Action[];
  68449. /**
  68450. * Instantiate the action
  68451. * @param triggerOptions defines the trigger options
  68452. * @param children defines the list of aggregated animations to run
  68453. * @param condition defines the trigger related conditions
  68454. */
  68455. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68456. /** @hidden */
  68457. _prepare(): void;
  68458. /**
  68459. * Execute the action and executes all the aggregated actions.
  68460. */
  68461. execute(evt: ActionEvent): void;
  68462. /**
  68463. * Serializes the actions and its related information.
  68464. * @param parent defines the object to serialize in
  68465. * @returns the serialized object
  68466. */
  68467. serialize(parent: any): any;
  68468. }
  68469. /**
  68470. * This defines an action responsible to run code (external event) once triggered.
  68471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68472. */
  68473. export class ExecuteCodeAction extends Action {
  68474. /**
  68475. * The callback function to run.
  68476. */
  68477. func: (evt: ActionEvent) => void;
  68478. /**
  68479. * Instantiate the action
  68480. * @param triggerOptions defines the trigger options
  68481. * @param func defines the callback function to run
  68482. * @param condition defines the trigger related conditions
  68483. */
  68484. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68485. /**
  68486. * Execute the action and run the attached code.
  68487. */
  68488. execute(evt: ActionEvent): void;
  68489. }
  68490. /**
  68491. * This defines an action responsible to set the parent property of the target once triggered.
  68492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68493. */
  68494. export class SetParentAction extends Action {
  68495. private _parent;
  68496. private _target;
  68497. /**
  68498. * Instantiate the action
  68499. * @param triggerOptions defines the trigger options
  68500. * @param target defines the target containing the parent property
  68501. * @param parent defines from where the animation should start (animation frame)
  68502. * @param condition defines the trigger related conditions
  68503. */
  68504. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68505. /** @hidden */
  68506. _prepare(): void;
  68507. /**
  68508. * Execute the action and set the parent property.
  68509. */
  68510. execute(): void;
  68511. /**
  68512. * Serializes the actions and its related information.
  68513. * @param parent defines the object to serialize in
  68514. * @returns the serialized object
  68515. */
  68516. serialize(parent: any): any;
  68517. }
  68518. }
  68519. declare module BABYLON {
  68520. /**
  68521. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68522. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68524. */
  68525. export class ActionManager extends AbstractActionManager {
  68526. /**
  68527. * Nothing
  68528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68529. */
  68530. static readonly NothingTrigger: number;
  68531. /**
  68532. * On pick
  68533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68534. */
  68535. static readonly OnPickTrigger: number;
  68536. /**
  68537. * On left pick
  68538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68539. */
  68540. static readonly OnLeftPickTrigger: number;
  68541. /**
  68542. * On right pick
  68543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68544. */
  68545. static readonly OnRightPickTrigger: number;
  68546. /**
  68547. * On center pick
  68548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68549. */
  68550. static readonly OnCenterPickTrigger: number;
  68551. /**
  68552. * On pick down
  68553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68554. */
  68555. static readonly OnPickDownTrigger: number;
  68556. /**
  68557. * On double pick
  68558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68559. */
  68560. static readonly OnDoublePickTrigger: number;
  68561. /**
  68562. * On pick up
  68563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68564. */
  68565. static readonly OnPickUpTrigger: number;
  68566. /**
  68567. * On pick out.
  68568. * This trigger will only be raised if you also declared a OnPickDown
  68569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68570. */
  68571. static readonly OnPickOutTrigger: number;
  68572. /**
  68573. * On long press
  68574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68575. */
  68576. static readonly OnLongPressTrigger: number;
  68577. /**
  68578. * On pointer over
  68579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68580. */
  68581. static readonly OnPointerOverTrigger: number;
  68582. /**
  68583. * On pointer out
  68584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68585. */
  68586. static readonly OnPointerOutTrigger: number;
  68587. /**
  68588. * On every frame
  68589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68590. */
  68591. static readonly OnEveryFrameTrigger: number;
  68592. /**
  68593. * On intersection enter
  68594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68595. */
  68596. static readonly OnIntersectionEnterTrigger: number;
  68597. /**
  68598. * On intersection exit
  68599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68600. */
  68601. static readonly OnIntersectionExitTrigger: number;
  68602. /**
  68603. * On key down
  68604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68605. */
  68606. static readonly OnKeyDownTrigger: number;
  68607. /**
  68608. * On key up
  68609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68610. */
  68611. static readonly OnKeyUpTrigger: number;
  68612. private _scene;
  68613. /**
  68614. * Creates a new action manager
  68615. * @param scene defines the hosting scene
  68616. */
  68617. constructor(scene: Scene);
  68618. /**
  68619. * Releases all associated resources
  68620. */
  68621. dispose(): void;
  68622. /**
  68623. * Gets hosting scene
  68624. * @returns the hosting scene
  68625. */
  68626. getScene(): Scene;
  68627. /**
  68628. * Does this action manager handles actions of any of the given triggers
  68629. * @param triggers defines the triggers to be tested
  68630. * @return a boolean indicating whether one (or more) of the triggers is handled
  68631. */
  68632. hasSpecificTriggers(triggers: number[]): boolean;
  68633. /**
  68634. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68635. * speed.
  68636. * @param triggerA defines the trigger to be tested
  68637. * @param triggerB defines the trigger to be tested
  68638. * @return a boolean indicating whether one (or more) of the triggers is handled
  68639. */
  68640. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68641. /**
  68642. * Does this action manager handles actions of a given trigger
  68643. * @param trigger defines the trigger to be tested
  68644. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68645. * @return whether the trigger is handled
  68646. */
  68647. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68648. /**
  68649. * Does this action manager has pointer triggers
  68650. */
  68651. readonly hasPointerTriggers: boolean;
  68652. /**
  68653. * Does this action manager has pick triggers
  68654. */
  68655. readonly hasPickTriggers: boolean;
  68656. /**
  68657. * Registers an action to this action manager
  68658. * @param action defines the action to be registered
  68659. * @return the action amended (prepared) after registration
  68660. */
  68661. registerAction(action: IAction): Nullable<IAction>;
  68662. /**
  68663. * Unregisters an action to this action manager
  68664. * @param action defines the action to be unregistered
  68665. * @return a boolean indicating whether the action has been unregistered
  68666. */
  68667. unregisterAction(action: IAction): Boolean;
  68668. /**
  68669. * Process a specific trigger
  68670. * @param trigger defines the trigger to process
  68671. * @param evt defines the event details to be processed
  68672. */
  68673. processTrigger(trigger: number, evt?: IActionEvent): void;
  68674. /** @hidden */
  68675. _getEffectiveTarget(target: any, propertyPath: string): any;
  68676. /** @hidden */
  68677. _getProperty(propertyPath: string): string;
  68678. /**
  68679. * Serialize this manager to a JSON object
  68680. * @param name defines the property name to store this manager
  68681. * @returns a JSON representation of this manager
  68682. */
  68683. serialize(name: string): any;
  68684. /**
  68685. * Creates a new ActionManager from a JSON data
  68686. * @param parsedActions defines the JSON data to read from
  68687. * @param object defines the hosting mesh
  68688. * @param scene defines the hosting scene
  68689. */
  68690. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68691. /**
  68692. * Get a trigger name by index
  68693. * @param trigger defines the trigger index
  68694. * @returns a trigger name
  68695. */
  68696. static GetTriggerName(trigger: number): string;
  68697. }
  68698. }
  68699. declare module BABYLON {
  68700. /**
  68701. * Class representing a ray with position and direction
  68702. */
  68703. export class Ray {
  68704. /** origin point */
  68705. origin: Vector3;
  68706. /** direction */
  68707. direction: Vector3;
  68708. /** length of the ray */
  68709. length: number;
  68710. private static readonly TmpVector3;
  68711. private _tmpRay;
  68712. /**
  68713. * Creates a new ray
  68714. * @param origin origin point
  68715. * @param direction direction
  68716. * @param length length of the ray
  68717. */
  68718. constructor(
  68719. /** origin point */
  68720. origin: Vector3,
  68721. /** direction */
  68722. direction: Vector3,
  68723. /** length of the ray */
  68724. length?: number);
  68725. /**
  68726. * Checks if the ray intersects a box
  68727. * @param minimum bound of the box
  68728. * @param maximum bound of the box
  68729. * @param intersectionTreshold extra extend to be added to the box in all direction
  68730. * @returns if the box was hit
  68731. */
  68732. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68733. /**
  68734. * Checks if the ray intersects a box
  68735. * @param box the bounding box to check
  68736. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68737. * @returns if the box was hit
  68738. */
  68739. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68740. /**
  68741. * If the ray hits a sphere
  68742. * @param sphere the bounding sphere to check
  68743. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68744. * @returns true if it hits the sphere
  68745. */
  68746. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68747. /**
  68748. * If the ray hits a triange
  68749. * @param vertex0 triangle vertex
  68750. * @param vertex1 triangle vertex
  68751. * @param vertex2 triangle vertex
  68752. * @returns intersection information if hit
  68753. */
  68754. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68755. /**
  68756. * Checks if ray intersects a plane
  68757. * @param plane the plane to check
  68758. * @returns the distance away it was hit
  68759. */
  68760. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68761. /**
  68762. * Checks if ray intersects a mesh
  68763. * @param mesh the mesh to check
  68764. * @param fastCheck if only the bounding box should checked
  68765. * @returns picking info of the intersecton
  68766. */
  68767. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68768. /**
  68769. * Checks if ray intersects a mesh
  68770. * @param meshes the meshes to check
  68771. * @param fastCheck if only the bounding box should checked
  68772. * @param results array to store result in
  68773. * @returns Array of picking infos
  68774. */
  68775. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68776. private _comparePickingInfo;
  68777. private static smallnum;
  68778. private static rayl;
  68779. /**
  68780. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68781. * @param sega the first point of the segment to test the intersection against
  68782. * @param segb the second point of the segment to test the intersection against
  68783. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68784. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68785. */
  68786. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68787. /**
  68788. * Update the ray from viewport position
  68789. * @param x position
  68790. * @param y y position
  68791. * @param viewportWidth viewport width
  68792. * @param viewportHeight viewport height
  68793. * @param world world matrix
  68794. * @param view view matrix
  68795. * @param projection projection matrix
  68796. * @returns this ray updated
  68797. */
  68798. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68799. /**
  68800. * Creates a ray with origin and direction of 0,0,0
  68801. * @returns the new ray
  68802. */
  68803. static Zero(): Ray;
  68804. /**
  68805. * Creates a new ray from screen space and viewport
  68806. * @param x position
  68807. * @param y y position
  68808. * @param viewportWidth viewport width
  68809. * @param viewportHeight viewport height
  68810. * @param world world matrix
  68811. * @param view view matrix
  68812. * @param projection projection matrix
  68813. * @returns new ray
  68814. */
  68815. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68816. /**
  68817. * 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
  68818. * transformed to the given world matrix.
  68819. * @param origin The origin point
  68820. * @param end The end point
  68821. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68822. * @returns the new ray
  68823. */
  68824. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68825. /**
  68826. * Transforms a ray by a matrix
  68827. * @param ray ray to transform
  68828. * @param matrix matrix to apply
  68829. * @returns the resulting new ray
  68830. */
  68831. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68832. /**
  68833. * Transforms a ray by a matrix
  68834. * @param ray ray to transform
  68835. * @param matrix matrix to apply
  68836. * @param result ray to store result in
  68837. */
  68838. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68839. /**
  68840. * Unproject a ray from screen space to object space
  68841. * @param sourceX defines the screen space x coordinate to use
  68842. * @param sourceY defines the screen space y coordinate to use
  68843. * @param viewportWidth defines the current width of the viewport
  68844. * @param viewportHeight defines the current height of the viewport
  68845. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68846. * @param view defines the view matrix to use
  68847. * @param projection defines the projection matrix to use
  68848. */
  68849. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68850. }
  68851. /**
  68852. * Type used to define predicate used to select faces when a mesh intersection is detected
  68853. */
  68854. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68855. interface Scene {
  68856. /** @hidden */
  68857. _tempPickingRay: Nullable<Ray>;
  68858. /** @hidden */
  68859. _cachedRayForTransform: Ray;
  68860. /** @hidden */
  68861. _pickWithRayInverseMatrix: Matrix;
  68862. /** @hidden */
  68863. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68864. /** @hidden */
  68865. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68866. }
  68867. }
  68868. declare module BABYLON {
  68869. /**
  68870. * Groups all the scene component constants in one place to ease maintenance.
  68871. * @hidden
  68872. */
  68873. export class SceneComponentConstants {
  68874. static readonly NAME_EFFECTLAYER: string;
  68875. static readonly NAME_LAYER: string;
  68876. static readonly NAME_LENSFLARESYSTEM: string;
  68877. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68878. static readonly NAME_PARTICLESYSTEM: string;
  68879. static readonly NAME_GAMEPAD: string;
  68880. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68881. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68882. static readonly NAME_DEPTHRENDERER: string;
  68883. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68884. static readonly NAME_SPRITE: string;
  68885. static readonly NAME_OUTLINERENDERER: string;
  68886. static readonly NAME_PROCEDURALTEXTURE: string;
  68887. static readonly NAME_SHADOWGENERATOR: string;
  68888. static readonly NAME_OCTREE: string;
  68889. static readonly NAME_PHYSICSENGINE: string;
  68890. static readonly NAME_AUDIO: string;
  68891. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68892. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68893. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68894. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68895. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68896. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68897. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68898. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68899. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68900. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68901. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68902. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68903. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68904. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68905. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68906. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68907. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68908. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68909. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68910. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68911. static readonly STEP_AFTERRENDER_AUDIO: number;
  68912. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68913. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68914. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68915. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68916. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68917. static readonly STEP_POINTERMOVE_SPRITE: number;
  68918. static readonly STEP_POINTERDOWN_SPRITE: number;
  68919. static readonly STEP_POINTERUP_SPRITE: number;
  68920. }
  68921. /**
  68922. * This represents a scene component.
  68923. *
  68924. * This is used to decouple the dependency the scene is having on the different workloads like
  68925. * layers, post processes...
  68926. */
  68927. export interface ISceneComponent {
  68928. /**
  68929. * The name of the component. Each component must have a unique name.
  68930. */
  68931. name: string;
  68932. /**
  68933. * The scene the component belongs to.
  68934. */
  68935. scene: Scene;
  68936. /**
  68937. * Register the component to one instance of a scene.
  68938. */
  68939. register(): void;
  68940. /**
  68941. * Rebuilds the elements related to this component in case of
  68942. * context lost for instance.
  68943. */
  68944. rebuild(): void;
  68945. /**
  68946. * Disposes the component and the associated ressources.
  68947. */
  68948. dispose(): void;
  68949. }
  68950. /**
  68951. * This represents a SERIALIZABLE scene component.
  68952. *
  68953. * This extends Scene Component to add Serialization methods on top.
  68954. */
  68955. export interface ISceneSerializableComponent extends ISceneComponent {
  68956. /**
  68957. * Adds all the element from the container to the scene
  68958. * @param container the container holding the elements
  68959. */
  68960. addFromContainer(container: AbstractScene): void;
  68961. /**
  68962. * Removes all the elements in the container from the scene
  68963. * @param container contains the elements to remove
  68964. */
  68965. removeFromContainer(container: AbstractScene): void;
  68966. /**
  68967. * Serializes the component data to the specified json object
  68968. * @param serializationObject The object to serialize to
  68969. */
  68970. serialize(serializationObject: any): void;
  68971. }
  68972. /**
  68973. * Strong typing of a Mesh related stage step action
  68974. */
  68975. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68976. /**
  68977. * Strong typing of a Evaluate Sub Mesh related stage step action
  68978. */
  68979. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68980. /**
  68981. * Strong typing of a Active Mesh related stage step action
  68982. */
  68983. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68984. /**
  68985. * Strong typing of a Camera related stage step action
  68986. */
  68987. export type CameraStageAction = (camera: Camera) => void;
  68988. /**
  68989. * Strong typing of a Render Target related stage step action
  68990. */
  68991. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68992. /**
  68993. * Strong typing of a RenderingGroup related stage step action
  68994. */
  68995. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68996. /**
  68997. * Strong typing of a Mesh Render related stage step action
  68998. */
  68999. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69000. /**
  69001. * Strong typing of a simple stage step action
  69002. */
  69003. export type SimpleStageAction = () => void;
  69004. /**
  69005. * Strong typing of a render target action.
  69006. */
  69007. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69008. /**
  69009. * Strong typing of a pointer move action.
  69010. */
  69011. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69012. /**
  69013. * Strong typing of a pointer up/down action.
  69014. */
  69015. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69016. /**
  69017. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69018. * @hidden
  69019. */
  69020. export class Stage<T extends Function> extends Array<{
  69021. index: number;
  69022. component: ISceneComponent;
  69023. action: T;
  69024. }> {
  69025. /**
  69026. * Hide ctor from the rest of the world.
  69027. * @param items The items to add.
  69028. */
  69029. private constructor();
  69030. /**
  69031. * Creates a new Stage.
  69032. * @returns A new instance of a Stage
  69033. */
  69034. static Create<T extends Function>(): Stage<T>;
  69035. /**
  69036. * Registers a step in an ordered way in the targeted stage.
  69037. * @param index Defines the position to register the step in
  69038. * @param component Defines the component attached to the step
  69039. * @param action Defines the action to launch during the step
  69040. */
  69041. registerStep(index: number, component: ISceneComponent, action: T): void;
  69042. /**
  69043. * Clears all the steps from the stage.
  69044. */
  69045. clear(): void;
  69046. }
  69047. }
  69048. declare module BABYLON {
  69049. interface Scene {
  69050. /** @hidden */
  69051. _pointerOverSprite: Nullable<Sprite>;
  69052. /** @hidden */
  69053. _pickedDownSprite: Nullable<Sprite>;
  69054. /** @hidden */
  69055. _tempSpritePickingRay: Nullable<Ray>;
  69056. /**
  69057. * All of the sprite managers added to this scene
  69058. * @see http://doc.babylonjs.com/babylon101/sprites
  69059. */
  69060. spriteManagers: Array<ISpriteManager>;
  69061. /**
  69062. * An event triggered when sprites rendering is about to start
  69063. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69064. */
  69065. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69066. /**
  69067. * An event triggered when sprites rendering is done
  69068. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69069. */
  69070. onAfterSpritesRenderingObservable: Observable<Scene>;
  69071. /** @hidden */
  69072. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69073. /** Launch a ray to try to pick a sprite in the scene
  69074. * @param x position on screen
  69075. * @param y position on screen
  69076. * @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
  69077. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69078. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69079. * @returns a PickingInfo
  69080. */
  69081. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69082. /** Use the given ray to pick a sprite in the scene
  69083. * @param ray The ray (in world space) to use to pick meshes
  69084. * @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
  69085. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69086. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69087. * @returns a PickingInfo
  69088. */
  69089. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69090. /**
  69091. * Force the sprite under the pointer
  69092. * @param sprite defines the sprite to use
  69093. */
  69094. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69095. /**
  69096. * Gets the sprite under the pointer
  69097. * @returns a Sprite or null if no sprite is under the pointer
  69098. */
  69099. getPointerOverSprite(): Nullable<Sprite>;
  69100. }
  69101. /**
  69102. * Defines the sprite scene component responsible to manage sprites
  69103. * in a given scene.
  69104. */
  69105. export class SpriteSceneComponent implements ISceneComponent {
  69106. /**
  69107. * The component name helpfull to identify the component in the list of scene components.
  69108. */
  69109. readonly name: string;
  69110. /**
  69111. * The scene the component belongs to.
  69112. */
  69113. scene: Scene;
  69114. /** @hidden */
  69115. private _spritePredicate;
  69116. /**
  69117. * Creates a new instance of the component for the given scene
  69118. * @param scene Defines the scene to register the component in
  69119. */
  69120. constructor(scene: Scene);
  69121. /**
  69122. * Registers the component in a given scene
  69123. */
  69124. register(): void;
  69125. /**
  69126. * Rebuilds the elements related to this component in case of
  69127. * context lost for instance.
  69128. */
  69129. rebuild(): void;
  69130. /**
  69131. * Disposes the component and the associated ressources.
  69132. */
  69133. dispose(): void;
  69134. private _pickSpriteButKeepRay;
  69135. private _pointerMove;
  69136. private _pointerDown;
  69137. private _pointerUp;
  69138. }
  69139. }
  69140. declare module BABYLON {
  69141. /** @hidden */
  69142. export var fogFragmentDeclaration: {
  69143. name: string;
  69144. shader: string;
  69145. };
  69146. }
  69147. declare module BABYLON {
  69148. /** @hidden */
  69149. export var fogFragment: {
  69150. name: string;
  69151. shader: string;
  69152. };
  69153. }
  69154. declare module BABYLON {
  69155. /** @hidden */
  69156. export var spritesPixelShader: {
  69157. name: string;
  69158. shader: string;
  69159. };
  69160. }
  69161. declare module BABYLON {
  69162. /** @hidden */
  69163. export var fogVertexDeclaration: {
  69164. name: string;
  69165. shader: string;
  69166. };
  69167. }
  69168. declare module BABYLON {
  69169. /** @hidden */
  69170. export var spritesVertexShader: {
  69171. name: string;
  69172. shader: string;
  69173. };
  69174. }
  69175. declare module BABYLON {
  69176. /**
  69177. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69178. */
  69179. export interface ISpriteManager extends IDisposable {
  69180. /**
  69181. * Restricts the camera to viewing objects with the same layerMask.
  69182. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69183. */
  69184. layerMask: number;
  69185. /**
  69186. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69187. */
  69188. isPickable: boolean;
  69189. /**
  69190. * Specifies the rendering group id for this mesh (0 by default)
  69191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69192. */
  69193. renderingGroupId: number;
  69194. /**
  69195. * Defines the list of sprites managed by the manager.
  69196. */
  69197. sprites: Array<Sprite>;
  69198. /**
  69199. * Tests the intersection of a sprite with a specific ray.
  69200. * @param ray The ray we are sending to test the collision
  69201. * @param camera The camera space we are sending rays in
  69202. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69203. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69204. * @returns picking info or null.
  69205. */
  69206. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69207. /**
  69208. * Renders the list of sprites on screen.
  69209. */
  69210. render(): void;
  69211. }
  69212. /**
  69213. * Class used to manage multiple sprites on the same spritesheet
  69214. * @see http://doc.babylonjs.com/babylon101/sprites
  69215. */
  69216. export class SpriteManager implements ISpriteManager {
  69217. /** defines the manager's name */
  69218. name: string;
  69219. /** Gets the list of sprites */
  69220. sprites: Sprite[];
  69221. /** Gets or sets the rendering group id (0 by default) */
  69222. renderingGroupId: number;
  69223. /** Gets or sets camera layer mask */
  69224. layerMask: number;
  69225. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69226. fogEnabled: boolean;
  69227. /** Gets or sets a boolean indicating if the sprites are pickable */
  69228. isPickable: boolean;
  69229. /** Defines the default width of a cell in the spritesheet */
  69230. cellWidth: number;
  69231. /** Defines the default height of a cell in the spritesheet */
  69232. cellHeight: number;
  69233. /**
  69234. * An event triggered when the manager is disposed.
  69235. */
  69236. onDisposeObservable: Observable<SpriteManager>;
  69237. private _onDisposeObserver;
  69238. /**
  69239. * Callback called when the manager is disposed
  69240. */
  69241. onDispose: () => void;
  69242. private _capacity;
  69243. private _spriteTexture;
  69244. private _epsilon;
  69245. private _scene;
  69246. private _vertexData;
  69247. private _buffer;
  69248. private _vertexBuffers;
  69249. private _indexBuffer;
  69250. private _effectBase;
  69251. private _effectFog;
  69252. /**
  69253. * Gets or sets the spritesheet texture
  69254. */
  69255. texture: Texture;
  69256. /**
  69257. * Creates a new sprite manager
  69258. * @param name defines the manager's name
  69259. * @param imgUrl defines the sprite sheet url
  69260. * @param capacity defines the maximum allowed number of sprites
  69261. * @param cellSize defines the size of a sprite cell
  69262. * @param scene defines the hosting scene
  69263. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69264. * @param samplingMode defines the smapling mode to use with spritesheet
  69265. */
  69266. constructor(
  69267. /** defines the manager's name */
  69268. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69269. private _appendSpriteVertex;
  69270. /**
  69271. * Intersects the sprites with a ray
  69272. * @param ray defines the ray to intersect with
  69273. * @param camera defines the current active camera
  69274. * @param predicate defines a predicate used to select candidate sprites
  69275. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69276. * @returns null if no hit or a PickingInfo
  69277. */
  69278. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69279. /**
  69280. * Render all child sprites
  69281. */
  69282. render(): void;
  69283. /**
  69284. * Release associated resources
  69285. */
  69286. dispose(): void;
  69287. }
  69288. }
  69289. declare module BABYLON {
  69290. /**
  69291. * Class used to represent a sprite
  69292. * @see http://doc.babylonjs.com/babylon101/sprites
  69293. */
  69294. export class Sprite {
  69295. /** defines the name */
  69296. name: string;
  69297. /** Gets or sets the current world position */
  69298. position: Vector3;
  69299. /** Gets or sets the main color */
  69300. color: Color4;
  69301. /** Gets or sets the width */
  69302. width: number;
  69303. /** Gets or sets the height */
  69304. height: number;
  69305. /** Gets or sets rotation angle */
  69306. angle: number;
  69307. /** Gets or sets the cell index in the sprite sheet */
  69308. cellIndex: number;
  69309. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69310. invertU: number;
  69311. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69312. invertV: number;
  69313. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69314. disposeWhenFinishedAnimating: boolean;
  69315. /** Gets the list of attached animations */
  69316. animations: Animation[];
  69317. /** Gets or sets a boolean indicating if the sprite can be picked */
  69318. isPickable: boolean;
  69319. /**
  69320. * Gets or sets the associated action manager
  69321. */
  69322. actionManager: Nullable<ActionManager>;
  69323. private _animationStarted;
  69324. private _loopAnimation;
  69325. private _fromIndex;
  69326. private _toIndex;
  69327. private _delay;
  69328. private _direction;
  69329. private _manager;
  69330. private _time;
  69331. private _onAnimationEnd;
  69332. /**
  69333. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69334. */
  69335. isVisible: boolean;
  69336. /**
  69337. * Gets or sets the sprite size
  69338. */
  69339. size: number;
  69340. /**
  69341. * Creates a new Sprite
  69342. * @param name defines the name
  69343. * @param manager defines the manager
  69344. */
  69345. constructor(
  69346. /** defines the name */
  69347. name: string, manager: ISpriteManager);
  69348. /**
  69349. * Starts an animation
  69350. * @param from defines the initial key
  69351. * @param to defines the end key
  69352. * @param loop defines if the animation must loop
  69353. * @param delay defines the start delay (in ms)
  69354. * @param onAnimationEnd defines a callback to call when animation ends
  69355. */
  69356. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69357. /** Stops current animation (if any) */
  69358. stopAnimation(): void;
  69359. /** @hidden */
  69360. _animate(deltaTime: number): void;
  69361. /** Release associated resources */
  69362. dispose(): void;
  69363. }
  69364. }
  69365. declare module BABYLON {
  69366. /**
  69367. * Information about the result of picking within a scene
  69368. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69369. */
  69370. export class PickingInfo {
  69371. /** @hidden */
  69372. _pickingUnavailable: boolean;
  69373. /**
  69374. * If the pick collided with an object
  69375. */
  69376. hit: boolean;
  69377. /**
  69378. * Distance away where the pick collided
  69379. */
  69380. distance: number;
  69381. /**
  69382. * The location of pick collision
  69383. */
  69384. pickedPoint: Nullable<Vector3>;
  69385. /**
  69386. * The mesh corresponding the the pick collision
  69387. */
  69388. pickedMesh: Nullable<AbstractMesh>;
  69389. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69390. bu: number;
  69391. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69392. bv: number;
  69393. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69394. faceId: number;
  69395. /** Id of the the submesh that was picked */
  69396. subMeshId: number;
  69397. /** If a sprite was picked, this will be the sprite the pick collided with */
  69398. pickedSprite: Nullable<Sprite>;
  69399. /**
  69400. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69401. */
  69402. originMesh: Nullable<AbstractMesh>;
  69403. /**
  69404. * The ray that was used to perform the picking.
  69405. */
  69406. ray: Nullable<Ray>;
  69407. /**
  69408. * Gets the normal correspodning to the face the pick collided with
  69409. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69410. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69411. * @returns The normal correspodning to the face the pick collided with
  69412. */
  69413. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69414. /**
  69415. * Gets the texture coordinates of where the pick occured
  69416. * @returns the vector containing the coordnates of the texture
  69417. */
  69418. getTextureCoordinates(): Nullable<Vector2>;
  69419. }
  69420. }
  69421. declare module BABYLON {
  69422. /**
  69423. * Gather the list of pointer event types as constants.
  69424. */
  69425. export class PointerEventTypes {
  69426. /**
  69427. * 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.
  69428. */
  69429. static readonly POINTERDOWN: number;
  69430. /**
  69431. * The pointerup event is fired when a pointer is no longer active.
  69432. */
  69433. static readonly POINTERUP: number;
  69434. /**
  69435. * The pointermove event is fired when a pointer changes coordinates.
  69436. */
  69437. static readonly POINTERMOVE: number;
  69438. /**
  69439. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69440. */
  69441. static readonly POINTERWHEEL: number;
  69442. /**
  69443. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69444. */
  69445. static readonly POINTERPICK: number;
  69446. /**
  69447. * The pointertap event is fired when a the object has been touched and released without drag.
  69448. */
  69449. static readonly POINTERTAP: number;
  69450. /**
  69451. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69452. */
  69453. static readonly POINTERDOUBLETAP: number;
  69454. }
  69455. /**
  69456. * Base class of pointer info types.
  69457. */
  69458. export class PointerInfoBase {
  69459. /**
  69460. * Defines the type of event (PointerEventTypes)
  69461. */
  69462. type: number;
  69463. /**
  69464. * Defines the related dom event
  69465. */
  69466. event: PointerEvent | MouseWheelEvent;
  69467. /**
  69468. * Instantiates the base class of pointers info.
  69469. * @param type Defines the type of event (PointerEventTypes)
  69470. * @param event Defines the related dom event
  69471. */
  69472. constructor(
  69473. /**
  69474. * Defines the type of event (PointerEventTypes)
  69475. */
  69476. type: number,
  69477. /**
  69478. * Defines the related dom event
  69479. */
  69480. event: PointerEvent | MouseWheelEvent);
  69481. }
  69482. /**
  69483. * This class is used to store pointer related info for the onPrePointerObservable event.
  69484. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69485. */
  69486. export class PointerInfoPre extends PointerInfoBase {
  69487. /**
  69488. * Ray from a pointer if availible (eg. 6dof controller)
  69489. */
  69490. ray: Nullable<Ray>;
  69491. /**
  69492. * Defines the local position of the pointer on the canvas.
  69493. */
  69494. localPosition: Vector2;
  69495. /**
  69496. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69497. */
  69498. skipOnPointerObservable: boolean;
  69499. /**
  69500. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69501. * @param type Defines the type of event (PointerEventTypes)
  69502. * @param event Defines the related dom event
  69503. * @param localX Defines the local x coordinates of the pointer when the event occured
  69504. * @param localY Defines the local y coordinates of the pointer when the event occured
  69505. */
  69506. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69507. }
  69508. /**
  69509. * This type contains all the data related to a pointer event in Babylon.js.
  69510. * 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.
  69511. */
  69512. export class PointerInfo extends PointerInfoBase {
  69513. /**
  69514. * Defines the picking info associated to the info (if any)\
  69515. */
  69516. pickInfo: Nullable<PickingInfo>;
  69517. /**
  69518. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69519. * @param type Defines the type of event (PointerEventTypes)
  69520. * @param event Defines the related dom event
  69521. * @param pickInfo Defines the picking info associated to the info (if any)\
  69522. */
  69523. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69524. /**
  69525. * Defines the picking info associated to the info (if any)\
  69526. */
  69527. pickInfo: Nullable<PickingInfo>);
  69528. }
  69529. /**
  69530. * Data relating to a touch event on the screen.
  69531. */
  69532. export interface PointerTouch {
  69533. /**
  69534. * X coordinate of touch.
  69535. */
  69536. x: number;
  69537. /**
  69538. * Y coordinate of touch.
  69539. */
  69540. y: number;
  69541. /**
  69542. * Id of touch. Unique for each finger.
  69543. */
  69544. pointerId: number;
  69545. /**
  69546. * Event type passed from DOM.
  69547. */
  69548. type: any;
  69549. }
  69550. }
  69551. declare module BABYLON {
  69552. /**
  69553. * Manage the mouse inputs to control the movement of a free camera.
  69554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69555. */
  69556. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69557. /**
  69558. * Define if touch is enabled in the mouse input
  69559. */
  69560. touchEnabled: boolean;
  69561. /**
  69562. * Defines the camera the input is attached to.
  69563. */
  69564. camera: FreeCamera;
  69565. /**
  69566. * Defines the buttons associated with the input to handle camera move.
  69567. */
  69568. buttons: number[];
  69569. /**
  69570. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69571. */
  69572. angularSensibility: number;
  69573. private _pointerInput;
  69574. private _onMouseMove;
  69575. private _observer;
  69576. private previousPosition;
  69577. /**
  69578. * Manage the mouse inputs to control the movement of a free camera.
  69579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69580. * @param touchEnabled Defines if touch is enabled or not
  69581. */
  69582. constructor(
  69583. /**
  69584. * Define if touch is enabled in the mouse input
  69585. */
  69586. touchEnabled?: boolean);
  69587. /**
  69588. * Attach the input controls to a specific dom element to get the input from.
  69589. * @param element Defines the element the controls should be listened from
  69590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69591. */
  69592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69593. /**
  69594. * Called on JS contextmenu event.
  69595. * Override this method to provide functionality.
  69596. */
  69597. protected onContextMenu(evt: PointerEvent): void;
  69598. /**
  69599. * Detach the current controls from the specified dom element.
  69600. * @param element Defines the element to stop listening the inputs from
  69601. */
  69602. detachControl(element: Nullable<HTMLElement>): void;
  69603. /**
  69604. * Gets the class name of the current intput.
  69605. * @returns the class name
  69606. */
  69607. getClassName(): string;
  69608. /**
  69609. * Get the friendly name associated with the input class.
  69610. * @returns the input friendly name
  69611. */
  69612. getSimpleName(): string;
  69613. }
  69614. }
  69615. declare module BABYLON {
  69616. /**
  69617. * Manage the touch inputs to control the movement of a free camera.
  69618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69619. */
  69620. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69621. /**
  69622. * Defines the camera the input is attached to.
  69623. */
  69624. camera: FreeCamera;
  69625. /**
  69626. * Defines the touch sensibility for rotation.
  69627. * The higher the faster.
  69628. */
  69629. touchAngularSensibility: number;
  69630. /**
  69631. * Defines the touch sensibility for move.
  69632. * The higher the faster.
  69633. */
  69634. touchMoveSensibility: number;
  69635. private _offsetX;
  69636. private _offsetY;
  69637. private _pointerPressed;
  69638. private _pointerInput;
  69639. private _observer;
  69640. private _onLostFocus;
  69641. /**
  69642. * Attach the input controls to a specific dom element to get the input from.
  69643. * @param element Defines the element the controls should be listened from
  69644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69645. */
  69646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69647. /**
  69648. * Detach the current controls from the specified dom element.
  69649. * @param element Defines the element to stop listening the inputs from
  69650. */
  69651. detachControl(element: Nullable<HTMLElement>): void;
  69652. /**
  69653. * Update the current camera state depending on the inputs that have been used this frame.
  69654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69655. */
  69656. checkInputs(): void;
  69657. /**
  69658. * Gets the class name of the current intput.
  69659. * @returns the class name
  69660. */
  69661. getClassName(): string;
  69662. /**
  69663. * Get the friendly name associated with the input class.
  69664. * @returns the input friendly name
  69665. */
  69666. getSimpleName(): string;
  69667. }
  69668. }
  69669. declare module BABYLON {
  69670. /**
  69671. * Default Inputs manager for the FreeCamera.
  69672. * It groups all the default supported inputs for ease of use.
  69673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69674. */
  69675. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69676. /**
  69677. * Instantiates a new FreeCameraInputsManager.
  69678. * @param camera Defines the camera the inputs belong to
  69679. */
  69680. constructor(camera: FreeCamera);
  69681. /**
  69682. * Add keyboard input support to the input manager.
  69683. * @returns the current input manager
  69684. */
  69685. addKeyboard(): FreeCameraInputsManager;
  69686. /**
  69687. * Add mouse input support to the input manager.
  69688. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69689. * @returns the current input manager
  69690. */
  69691. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69692. /**
  69693. * Add touch input support to the input manager.
  69694. * @returns the current input manager
  69695. */
  69696. addTouch(): FreeCameraInputsManager;
  69697. }
  69698. }
  69699. declare module BABYLON {
  69700. /**
  69701. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69702. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69703. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69704. */
  69705. export class FreeCamera extends TargetCamera {
  69706. /**
  69707. * Define the collision ellipsoid of the camera.
  69708. * This is helpful to simulate a camera body like the player body around the camera
  69709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69710. */
  69711. ellipsoid: Vector3;
  69712. /**
  69713. * Define an offset for the position of the ellipsoid around the camera.
  69714. * This can be helpful to determine the center of the body near the gravity center of the body
  69715. * instead of its head.
  69716. */
  69717. ellipsoidOffset: Vector3;
  69718. /**
  69719. * Enable or disable collisions of the camera with the rest of the scene objects.
  69720. */
  69721. checkCollisions: boolean;
  69722. /**
  69723. * Enable or disable gravity on the camera.
  69724. */
  69725. applyGravity: boolean;
  69726. /**
  69727. * Define the input manager associated to the camera.
  69728. */
  69729. inputs: FreeCameraInputsManager;
  69730. /**
  69731. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69732. * Higher values reduce sensitivity.
  69733. */
  69734. /**
  69735. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69736. * Higher values reduce sensitivity.
  69737. */
  69738. angularSensibility: number;
  69739. /**
  69740. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69741. */
  69742. keysUp: number[];
  69743. /**
  69744. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69745. */
  69746. keysDown: number[];
  69747. /**
  69748. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69749. */
  69750. keysLeft: number[];
  69751. /**
  69752. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69753. */
  69754. keysRight: number[];
  69755. /**
  69756. * Event raised when the camera collide with a mesh in the scene.
  69757. */
  69758. onCollide: (collidedMesh: AbstractMesh) => void;
  69759. private _collider;
  69760. private _needMoveForGravity;
  69761. private _oldPosition;
  69762. private _diffPosition;
  69763. private _newPosition;
  69764. /** @hidden */
  69765. _localDirection: Vector3;
  69766. /** @hidden */
  69767. _transformedDirection: Vector3;
  69768. /**
  69769. * Instantiates a Free Camera.
  69770. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69771. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69773. * @param name Define the name of the camera in the scene
  69774. * @param position Define the start position of the camera in the scene
  69775. * @param scene Define the scene the camera belongs to
  69776. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69777. */
  69778. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69779. /**
  69780. * Attached controls to the current camera.
  69781. * @param element Defines the element the controls should be listened from
  69782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69783. */
  69784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69785. /**
  69786. * Detach the current controls from the camera.
  69787. * The camera will stop reacting to inputs.
  69788. * @param element Defines the element to stop listening the inputs from
  69789. */
  69790. detachControl(element: HTMLElement): void;
  69791. private _collisionMask;
  69792. /**
  69793. * Define a collision mask to limit the list of object the camera can collide with
  69794. */
  69795. collisionMask: number;
  69796. /** @hidden */
  69797. _collideWithWorld(displacement: Vector3): void;
  69798. private _onCollisionPositionChange;
  69799. /** @hidden */
  69800. _checkInputs(): void;
  69801. /** @hidden */
  69802. _decideIfNeedsToMove(): boolean;
  69803. /** @hidden */
  69804. _updatePosition(): void;
  69805. /**
  69806. * Destroy the camera and release the current resources hold by it.
  69807. */
  69808. dispose(): void;
  69809. /**
  69810. * Gets the current object class name.
  69811. * @return the class name
  69812. */
  69813. getClassName(): string;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /**
  69818. * Represents a gamepad control stick position
  69819. */
  69820. export class StickValues {
  69821. /**
  69822. * The x component of the control stick
  69823. */
  69824. x: number;
  69825. /**
  69826. * The y component of the control stick
  69827. */
  69828. y: number;
  69829. /**
  69830. * Initializes the gamepad x and y control stick values
  69831. * @param x The x component of the gamepad control stick value
  69832. * @param y The y component of the gamepad control stick value
  69833. */
  69834. constructor(
  69835. /**
  69836. * The x component of the control stick
  69837. */
  69838. x: number,
  69839. /**
  69840. * The y component of the control stick
  69841. */
  69842. y: number);
  69843. }
  69844. /**
  69845. * An interface which manages callbacks for gamepad button changes
  69846. */
  69847. export interface GamepadButtonChanges {
  69848. /**
  69849. * Called when a gamepad has been changed
  69850. */
  69851. changed: boolean;
  69852. /**
  69853. * Called when a gamepad press event has been triggered
  69854. */
  69855. pressChanged: boolean;
  69856. /**
  69857. * Called when a touch event has been triggered
  69858. */
  69859. touchChanged: boolean;
  69860. /**
  69861. * Called when a value has changed
  69862. */
  69863. valueChanged: boolean;
  69864. }
  69865. /**
  69866. * Represents a gamepad
  69867. */
  69868. export class Gamepad {
  69869. /**
  69870. * The id of the gamepad
  69871. */
  69872. id: string;
  69873. /**
  69874. * The index of the gamepad
  69875. */
  69876. index: number;
  69877. /**
  69878. * The browser gamepad
  69879. */
  69880. browserGamepad: any;
  69881. /**
  69882. * Specifies what type of gamepad this represents
  69883. */
  69884. type: number;
  69885. private _leftStick;
  69886. private _rightStick;
  69887. /** @hidden */
  69888. _isConnected: boolean;
  69889. private _leftStickAxisX;
  69890. private _leftStickAxisY;
  69891. private _rightStickAxisX;
  69892. private _rightStickAxisY;
  69893. /**
  69894. * Triggered when the left control stick has been changed
  69895. */
  69896. private _onleftstickchanged;
  69897. /**
  69898. * Triggered when the right control stick has been changed
  69899. */
  69900. private _onrightstickchanged;
  69901. /**
  69902. * Represents a gamepad controller
  69903. */
  69904. static GAMEPAD: number;
  69905. /**
  69906. * Represents a generic controller
  69907. */
  69908. static GENERIC: number;
  69909. /**
  69910. * Represents an XBox controller
  69911. */
  69912. static XBOX: number;
  69913. /**
  69914. * Represents a pose-enabled controller
  69915. */
  69916. static POSE_ENABLED: number;
  69917. /**
  69918. * Specifies whether the left control stick should be Y-inverted
  69919. */
  69920. protected _invertLeftStickY: boolean;
  69921. /**
  69922. * Specifies if the gamepad has been connected
  69923. */
  69924. readonly isConnected: boolean;
  69925. /**
  69926. * Initializes the gamepad
  69927. * @param id The id of the gamepad
  69928. * @param index The index of the gamepad
  69929. * @param browserGamepad The browser gamepad
  69930. * @param leftStickX The x component of the left joystick
  69931. * @param leftStickY The y component of the left joystick
  69932. * @param rightStickX The x component of the right joystick
  69933. * @param rightStickY The y component of the right joystick
  69934. */
  69935. constructor(
  69936. /**
  69937. * The id of the gamepad
  69938. */
  69939. id: string,
  69940. /**
  69941. * The index of the gamepad
  69942. */
  69943. index: number,
  69944. /**
  69945. * The browser gamepad
  69946. */
  69947. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69948. /**
  69949. * Callback triggered when the left joystick has changed
  69950. * @param callback
  69951. */
  69952. onleftstickchanged(callback: (values: StickValues) => void): void;
  69953. /**
  69954. * Callback triggered when the right joystick has changed
  69955. * @param callback
  69956. */
  69957. onrightstickchanged(callback: (values: StickValues) => void): void;
  69958. /**
  69959. * Gets the left joystick
  69960. */
  69961. /**
  69962. * Sets the left joystick values
  69963. */
  69964. leftStick: StickValues;
  69965. /**
  69966. * Gets the right joystick
  69967. */
  69968. /**
  69969. * Sets the right joystick value
  69970. */
  69971. rightStick: StickValues;
  69972. /**
  69973. * Updates the gamepad joystick positions
  69974. */
  69975. update(): void;
  69976. /**
  69977. * Disposes the gamepad
  69978. */
  69979. dispose(): void;
  69980. }
  69981. /**
  69982. * Represents a generic gamepad
  69983. */
  69984. export class GenericPad extends Gamepad {
  69985. private _buttons;
  69986. private _onbuttondown;
  69987. private _onbuttonup;
  69988. /**
  69989. * Observable triggered when a button has been pressed
  69990. */
  69991. onButtonDownObservable: Observable<number>;
  69992. /**
  69993. * Observable triggered when a button has been released
  69994. */
  69995. onButtonUpObservable: Observable<number>;
  69996. /**
  69997. * Callback triggered when a button has been pressed
  69998. * @param callback Called when a button has been pressed
  69999. */
  70000. onbuttondown(callback: (buttonPressed: number) => void): void;
  70001. /**
  70002. * Callback triggered when a button has been released
  70003. * @param callback Called when a button has been released
  70004. */
  70005. onbuttonup(callback: (buttonReleased: number) => void): void;
  70006. /**
  70007. * Initializes the generic gamepad
  70008. * @param id The id of the generic gamepad
  70009. * @param index The index of the generic gamepad
  70010. * @param browserGamepad The browser gamepad
  70011. */
  70012. constructor(id: string, index: number, browserGamepad: any);
  70013. private _setButtonValue;
  70014. /**
  70015. * Updates the generic gamepad
  70016. */
  70017. update(): void;
  70018. /**
  70019. * Disposes the generic gamepad
  70020. */
  70021. dispose(): void;
  70022. }
  70023. }
  70024. declare module BABYLON {
  70025. /**
  70026. * Defines the types of pose enabled controllers that are supported
  70027. */
  70028. export enum PoseEnabledControllerType {
  70029. /**
  70030. * HTC Vive
  70031. */
  70032. VIVE = 0,
  70033. /**
  70034. * Oculus Rift
  70035. */
  70036. OCULUS = 1,
  70037. /**
  70038. * Windows mixed reality
  70039. */
  70040. WINDOWS = 2,
  70041. /**
  70042. * Samsung gear VR
  70043. */
  70044. GEAR_VR = 3,
  70045. /**
  70046. * Google Daydream
  70047. */
  70048. DAYDREAM = 4,
  70049. /**
  70050. * Generic
  70051. */
  70052. GENERIC = 5
  70053. }
  70054. /**
  70055. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70056. */
  70057. export interface MutableGamepadButton {
  70058. /**
  70059. * Value of the button/trigger
  70060. */
  70061. value: number;
  70062. /**
  70063. * If the button/trigger is currently touched
  70064. */
  70065. touched: boolean;
  70066. /**
  70067. * If the button/trigger is currently pressed
  70068. */
  70069. pressed: boolean;
  70070. }
  70071. /**
  70072. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70073. * @hidden
  70074. */
  70075. export interface ExtendedGamepadButton extends GamepadButton {
  70076. /**
  70077. * If the button/trigger is currently pressed
  70078. */
  70079. readonly pressed: boolean;
  70080. /**
  70081. * If the button/trigger is currently touched
  70082. */
  70083. readonly touched: boolean;
  70084. /**
  70085. * Value of the button/trigger
  70086. */
  70087. readonly value: number;
  70088. }
  70089. /** @hidden */
  70090. export interface _GamePadFactory {
  70091. /**
  70092. * Returns wether or not the current gamepad can be created for this type of controller.
  70093. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70094. * @returns true if it can be created, otherwise false
  70095. */
  70096. canCreate(gamepadInfo: any): boolean;
  70097. /**
  70098. * Creates a new instance of the Gamepad.
  70099. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70100. * @returns the new gamepad instance
  70101. */
  70102. create(gamepadInfo: any): Gamepad;
  70103. }
  70104. /**
  70105. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70106. */
  70107. export class PoseEnabledControllerHelper {
  70108. /** @hidden */
  70109. static _ControllerFactories: _GamePadFactory[];
  70110. /** @hidden */
  70111. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70112. /**
  70113. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70114. * @param vrGamepad the gamepad to initialized
  70115. * @returns a vr controller of the type the gamepad identified as
  70116. */
  70117. static InitiateController(vrGamepad: any): Gamepad;
  70118. }
  70119. /**
  70120. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70121. */
  70122. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70123. private _deviceRoomPosition;
  70124. private _deviceRoomRotationQuaternion;
  70125. /**
  70126. * The device position in babylon space
  70127. */
  70128. devicePosition: Vector3;
  70129. /**
  70130. * The device rotation in babylon space
  70131. */
  70132. deviceRotationQuaternion: Quaternion;
  70133. /**
  70134. * The scale factor of the device in babylon space
  70135. */
  70136. deviceScaleFactor: number;
  70137. /**
  70138. * (Likely devicePosition should be used instead) The device position in its room space
  70139. */
  70140. position: Vector3;
  70141. /**
  70142. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70143. */
  70144. rotationQuaternion: Quaternion;
  70145. /**
  70146. * The type of controller (Eg. Windows mixed reality)
  70147. */
  70148. controllerType: PoseEnabledControllerType;
  70149. protected _calculatedPosition: Vector3;
  70150. private _calculatedRotation;
  70151. /**
  70152. * The raw pose from the device
  70153. */
  70154. rawPose: DevicePose;
  70155. private _trackPosition;
  70156. private _maxRotationDistFromHeadset;
  70157. private _draggedRoomRotation;
  70158. /**
  70159. * @hidden
  70160. */
  70161. _disableTrackPosition(fixedPosition: Vector3): void;
  70162. /**
  70163. * Internal, the mesh attached to the controller
  70164. * @hidden
  70165. */
  70166. _mesh: Nullable<AbstractMesh>;
  70167. private _poseControlledCamera;
  70168. private _leftHandSystemQuaternion;
  70169. /**
  70170. * Internal, matrix used to convert room space to babylon space
  70171. * @hidden
  70172. */
  70173. _deviceToWorld: Matrix;
  70174. /**
  70175. * Node to be used when casting a ray from the controller
  70176. * @hidden
  70177. */
  70178. _pointingPoseNode: Nullable<TransformNode>;
  70179. /**
  70180. * Name of the child mesh that can be used to cast a ray from the controller
  70181. */
  70182. static readonly POINTING_POSE: string;
  70183. /**
  70184. * Creates a new PoseEnabledController from a gamepad
  70185. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70186. */
  70187. constructor(browserGamepad: any);
  70188. private _workingMatrix;
  70189. /**
  70190. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70191. */
  70192. update(): void;
  70193. /**
  70194. * Updates only the pose device and mesh without doing any button event checking
  70195. */
  70196. protected _updatePoseAndMesh(): void;
  70197. /**
  70198. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70199. * @param poseData raw pose fromthe device
  70200. */
  70201. updateFromDevice(poseData: DevicePose): void;
  70202. /**
  70203. * @hidden
  70204. */
  70205. _meshAttachedObservable: Observable<AbstractMesh>;
  70206. /**
  70207. * Attaches a mesh to the controller
  70208. * @param mesh the mesh to be attached
  70209. */
  70210. attachToMesh(mesh: AbstractMesh): void;
  70211. /**
  70212. * Attaches the controllers mesh to a camera
  70213. * @param camera the camera the mesh should be attached to
  70214. */
  70215. attachToPoseControlledCamera(camera: TargetCamera): void;
  70216. /**
  70217. * Disposes of the controller
  70218. */
  70219. dispose(): void;
  70220. /**
  70221. * The mesh that is attached to the controller
  70222. */
  70223. readonly mesh: Nullable<AbstractMesh>;
  70224. /**
  70225. * Gets the ray of the controller in the direction the controller is pointing
  70226. * @param length the length the resulting ray should be
  70227. * @returns a ray in the direction the controller is pointing
  70228. */
  70229. getForwardRay(length?: number): Ray;
  70230. }
  70231. }
  70232. declare module BABYLON {
  70233. /**
  70234. * Defines the WebVRController object that represents controllers tracked in 3D space
  70235. */
  70236. export abstract class WebVRController extends PoseEnabledController {
  70237. /**
  70238. * Internal, the default controller model for the controller
  70239. */
  70240. protected _defaultModel: AbstractMesh;
  70241. /**
  70242. * Fired when the trigger state has changed
  70243. */
  70244. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70245. /**
  70246. * Fired when the main button state has changed
  70247. */
  70248. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70249. /**
  70250. * Fired when the secondary button state has changed
  70251. */
  70252. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70253. /**
  70254. * Fired when the pad state has changed
  70255. */
  70256. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70257. /**
  70258. * Fired when controllers stick values have changed
  70259. */
  70260. onPadValuesChangedObservable: Observable<StickValues>;
  70261. /**
  70262. * Array of button availible on the controller
  70263. */
  70264. protected _buttons: Array<MutableGamepadButton>;
  70265. private _onButtonStateChange;
  70266. /**
  70267. * Fired when a controller button's state has changed
  70268. * @param callback the callback containing the button that was modified
  70269. */
  70270. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70271. /**
  70272. * X and Y axis corrisponding to the controllers joystick
  70273. */
  70274. pad: StickValues;
  70275. /**
  70276. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70277. */
  70278. hand: string;
  70279. /**
  70280. * The default controller model for the controller
  70281. */
  70282. readonly defaultModel: AbstractMesh;
  70283. /**
  70284. * Creates a new WebVRController from a gamepad
  70285. * @param vrGamepad the gamepad that the WebVRController should be created from
  70286. */
  70287. constructor(vrGamepad: any);
  70288. /**
  70289. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70290. */
  70291. update(): void;
  70292. /**
  70293. * Function to be called when a button is modified
  70294. */
  70295. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70296. /**
  70297. * Loads a mesh and attaches it to the controller
  70298. * @param scene the scene the mesh should be added to
  70299. * @param meshLoaded callback for when the mesh has been loaded
  70300. */
  70301. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70302. private _setButtonValue;
  70303. private _changes;
  70304. private _checkChanges;
  70305. /**
  70306. * Disposes of th webVRCOntroller
  70307. */
  70308. dispose(): void;
  70309. }
  70310. }
  70311. declare module BABYLON {
  70312. /**
  70313. * The HemisphericLight simulates the ambient environment light,
  70314. * so the passed direction is the light reflection direction, not the incoming direction.
  70315. */
  70316. export class HemisphericLight extends Light {
  70317. /**
  70318. * The groundColor is the light in the opposite direction to the one specified during creation.
  70319. * 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.
  70320. */
  70321. groundColor: Color3;
  70322. /**
  70323. * The light reflection direction, not the incoming direction.
  70324. */
  70325. direction: Vector3;
  70326. /**
  70327. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70328. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70329. * The HemisphericLight can't cast shadows.
  70330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70331. * @param name The friendly name of the light
  70332. * @param direction The direction of the light reflection
  70333. * @param scene The scene the light belongs to
  70334. */
  70335. constructor(name: string, direction: Vector3, scene: Scene);
  70336. protected _buildUniformLayout(): void;
  70337. /**
  70338. * Returns the string "HemisphericLight".
  70339. * @return The class name
  70340. */
  70341. getClassName(): string;
  70342. /**
  70343. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70344. * Returns the updated direction.
  70345. * @param target The target the direction should point to
  70346. * @return The computed direction
  70347. */
  70348. setDirectionToTarget(target: Vector3): Vector3;
  70349. /**
  70350. * Returns the shadow generator associated to the light.
  70351. * @returns Always null for hemispheric lights because it does not support shadows.
  70352. */
  70353. getShadowGenerator(): Nullable<IShadowGenerator>;
  70354. /**
  70355. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70356. * @param effect The effect to update
  70357. * @param lightIndex The index of the light in the effect to update
  70358. * @returns The hemispheric light
  70359. */
  70360. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70361. /**
  70362. * Computes the world matrix of the node
  70363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70364. * @param useWasUpdatedFlag defines a reserved property
  70365. * @returns the world matrix
  70366. */
  70367. computeWorldMatrix(): Matrix;
  70368. /**
  70369. * Returns the integer 3.
  70370. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70371. */
  70372. getTypeID(): number;
  70373. /**
  70374. * Prepares the list of defines specific to the light type.
  70375. * @param defines the list of defines
  70376. * @param lightIndex defines the index of the light for the effect
  70377. */
  70378. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70379. }
  70380. }
  70381. declare module BABYLON {
  70382. /**
  70383. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70384. * IMPORTANT!! The data is right-hand data.
  70385. * @export
  70386. * @interface DevicePose
  70387. */
  70388. export interface DevicePose {
  70389. /**
  70390. * The position of the device, values in array are [x,y,z].
  70391. */
  70392. readonly position: Nullable<Float32Array>;
  70393. /**
  70394. * The linearVelocity of the device, values in array are [x,y,z].
  70395. */
  70396. readonly linearVelocity: Nullable<Float32Array>;
  70397. /**
  70398. * The linearAcceleration of the device, values in array are [x,y,z].
  70399. */
  70400. readonly linearAcceleration: Nullable<Float32Array>;
  70401. /**
  70402. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70403. */
  70404. readonly orientation: Nullable<Float32Array>;
  70405. /**
  70406. * The angularVelocity of the device, values in array are [x,y,z].
  70407. */
  70408. readonly angularVelocity: Nullable<Float32Array>;
  70409. /**
  70410. * The angularAcceleration of the device, values in array are [x,y,z].
  70411. */
  70412. readonly angularAcceleration: Nullable<Float32Array>;
  70413. }
  70414. /**
  70415. * Interface representing a pose controlled object in Babylon.
  70416. * A pose controlled object has both regular pose values as well as pose values
  70417. * from an external device such as a VR head mounted display
  70418. */
  70419. export interface PoseControlled {
  70420. /**
  70421. * The position of the object in babylon space.
  70422. */
  70423. position: Vector3;
  70424. /**
  70425. * The rotation quaternion of the object in babylon space.
  70426. */
  70427. rotationQuaternion: Quaternion;
  70428. /**
  70429. * The position of the device in babylon space.
  70430. */
  70431. devicePosition?: Vector3;
  70432. /**
  70433. * The rotation quaternion of the device in babylon space.
  70434. */
  70435. deviceRotationQuaternion: Quaternion;
  70436. /**
  70437. * The raw pose coming from the device.
  70438. */
  70439. rawPose: Nullable<DevicePose>;
  70440. /**
  70441. * The scale of the device to be used when translating from device space to babylon space.
  70442. */
  70443. deviceScaleFactor: number;
  70444. /**
  70445. * Updates the poseControlled values based on the input device pose.
  70446. * @param poseData the pose data to update the object with
  70447. */
  70448. updateFromDevice(poseData: DevicePose): void;
  70449. }
  70450. /**
  70451. * Set of options to customize the webVRCamera
  70452. */
  70453. export interface WebVROptions {
  70454. /**
  70455. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70456. */
  70457. trackPosition?: boolean;
  70458. /**
  70459. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70460. */
  70461. positionScale?: number;
  70462. /**
  70463. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70464. */
  70465. displayName?: string;
  70466. /**
  70467. * Should the native controller meshes be initialized. (default: true)
  70468. */
  70469. controllerMeshes?: boolean;
  70470. /**
  70471. * Creating a default HemiLight only on controllers. (default: true)
  70472. */
  70473. defaultLightingOnControllers?: boolean;
  70474. /**
  70475. * If you don't want to use the default VR button of the helper. (default: false)
  70476. */
  70477. useCustomVRButton?: boolean;
  70478. /**
  70479. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70480. */
  70481. customVRButton?: HTMLButtonElement;
  70482. /**
  70483. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70484. */
  70485. rayLength?: number;
  70486. /**
  70487. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70488. */
  70489. defaultHeight?: number;
  70490. }
  70491. /**
  70492. * This represents a WebVR camera.
  70493. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70494. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70495. */
  70496. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70497. private webVROptions;
  70498. /**
  70499. * @hidden
  70500. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70501. */
  70502. _vrDevice: any;
  70503. /**
  70504. * The rawPose of the vrDevice.
  70505. */
  70506. rawPose: Nullable<DevicePose>;
  70507. private _onVREnabled;
  70508. private _specsVersion;
  70509. private _attached;
  70510. private _frameData;
  70511. protected _descendants: Array<Node>;
  70512. private _deviceRoomPosition;
  70513. /** @hidden */
  70514. _deviceRoomRotationQuaternion: Quaternion;
  70515. private _standingMatrix;
  70516. /**
  70517. * Represents device position in babylon space.
  70518. */
  70519. devicePosition: Vector3;
  70520. /**
  70521. * Represents device rotation in babylon space.
  70522. */
  70523. deviceRotationQuaternion: Quaternion;
  70524. /**
  70525. * The scale of the device to be used when translating from device space to babylon space.
  70526. */
  70527. deviceScaleFactor: number;
  70528. private _deviceToWorld;
  70529. private _worldToDevice;
  70530. /**
  70531. * References to the webVR controllers for the vrDevice.
  70532. */
  70533. controllers: Array<WebVRController>;
  70534. /**
  70535. * Emits an event when a controller is attached.
  70536. */
  70537. onControllersAttachedObservable: Observable<WebVRController[]>;
  70538. /**
  70539. * Emits an event when a controller's mesh has been loaded;
  70540. */
  70541. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70542. /**
  70543. * Emits an event when the HMD's pose has been updated.
  70544. */
  70545. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70546. private _poseSet;
  70547. /**
  70548. * If the rig cameras be used as parent instead of this camera.
  70549. */
  70550. rigParenting: boolean;
  70551. private _lightOnControllers;
  70552. private _defaultHeight?;
  70553. /**
  70554. * Instantiates a WebVRFreeCamera.
  70555. * @param name The name of the WebVRFreeCamera
  70556. * @param position The starting anchor position for the camera
  70557. * @param scene The scene the camera belongs to
  70558. * @param webVROptions a set of customizable options for the webVRCamera
  70559. */
  70560. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70561. /**
  70562. * Gets the device distance from the ground in meters.
  70563. * @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.
  70564. */
  70565. deviceDistanceToRoomGround(): number;
  70566. /**
  70567. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70568. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70569. */
  70570. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70571. /**
  70572. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70573. * @returns A promise with a boolean set to if the standing matrix is supported.
  70574. */
  70575. useStandingMatrixAsync(): Promise<boolean>;
  70576. /**
  70577. * Disposes the camera
  70578. */
  70579. dispose(): void;
  70580. /**
  70581. * Gets a vrController by name.
  70582. * @param name The name of the controller to retreive
  70583. * @returns the controller matching the name specified or null if not found
  70584. */
  70585. getControllerByName(name: string): Nullable<WebVRController>;
  70586. private _leftController;
  70587. /**
  70588. * The controller corrisponding to the users left hand.
  70589. */
  70590. readonly leftController: Nullable<WebVRController>;
  70591. private _rightController;
  70592. /**
  70593. * The controller corrisponding to the users right hand.
  70594. */
  70595. readonly rightController: Nullable<WebVRController>;
  70596. /**
  70597. * Casts a ray forward from the vrCamera's gaze.
  70598. * @param length Length of the ray (default: 100)
  70599. * @returns the ray corrisponding to the gaze
  70600. */
  70601. getForwardRay(length?: number): Ray;
  70602. /**
  70603. * @hidden
  70604. * Updates the camera based on device's frame data
  70605. */
  70606. _checkInputs(): void;
  70607. /**
  70608. * Updates the poseControlled values based on the input device pose.
  70609. * @param poseData Pose coming from the device
  70610. */
  70611. updateFromDevice(poseData: DevicePose): void;
  70612. private _htmlElementAttached;
  70613. private _detachIfAttached;
  70614. /**
  70615. * WebVR's attach control will start broadcasting frames to the device.
  70616. * Note that in certain browsers (chrome for example) this function must be called
  70617. * within a user-interaction callback. Example:
  70618. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70619. *
  70620. * @param element html element to attach the vrDevice to
  70621. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70622. */
  70623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70624. /**
  70625. * Detaches the camera from the html element and disables VR
  70626. *
  70627. * @param element html element to detach from
  70628. */
  70629. detachControl(element: HTMLElement): void;
  70630. /**
  70631. * @returns the name of this class
  70632. */
  70633. getClassName(): string;
  70634. /**
  70635. * Calls resetPose on the vrDisplay
  70636. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70637. */
  70638. resetToCurrentRotation(): void;
  70639. /**
  70640. * @hidden
  70641. * Updates the rig cameras (left and right eye)
  70642. */
  70643. _updateRigCameras(): void;
  70644. private _workingVector;
  70645. private _oneVector;
  70646. private _workingMatrix;
  70647. private updateCacheCalled;
  70648. private _correctPositionIfNotTrackPosition;
  70649. /**
  70650. * @hidden
  70651. * Updates the cached values of the camera
  70652. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70653. */
  70654. _updateCache(ignoreParentClass?: boolean): void;
  70655. /**
  70656. * @hidden
  70657. * Get current device position in babylon world
  70658. */
  70659. _computeDevicePosition(): void;
  70660. /**
  70661. * Updates the current device position and rotation in the babylon world
  70662. */
  70663. update(): void;
  70664. /**
  70665. * @hidden
  70666. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70667. * @returns an identity matrix
  70668. */
  70669. _getViewMatrix(): Matrix;
  70670. private _tmpMatrix;
  70671. /**
  70672. * This function is called by the two RIG cameras.
  70673. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70674. * @hidden
  70675. */
  70676. _getWebVRViewMatrix(): Matrix;
  70677. /** @hidden */
  70678. _getWebVRProjectionMatrix(): Matrix;
  70679. private _onGamepadConnectedObserver;
  70680. private _onGamepadDisconnectedObserver;
  70681. private _updateCacheWhenTrackingDisabledObserver;
  70682. /**
  70683. * Initializes the controllers and their meshes
  70684. */
  70685. initControllers(): void;
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /**
  70690. * Size options for a post process
  70691. */
  70692. export type PostProcessOptions = {
  70693. width: number;
  70694. height: number;
  70695. };
  70696. /**
  70697. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70698. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70699. */
  70700. export class PostProcess {
  70701. /** Name of the PostProcess. */
  70702. name: string;
  70703. /**
  70704. * Gets or sets the unique id of the post process
  70705. */
  70706. uniqueId: number;
  70707. /**
  70708. * Width of the texture to apply the post process on
  70709. */
  70710. width: number;
  70711. /**
  70712. * Height of the texture to apply the post process on
  70713. */
  70714. height: number;
  70715. /**
  70716. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70717. * @hidden
  70718. */
  70719. _outputTexture: Nullable<InternalTexture>;
  70720. /**
  70721. * Sampling mode used by the shader
  70722. * See https://doc.babylonjs.com/classes/3.1/texture
  70723. */
  70724. renderTargetSamplingMode: number;
  70725. /**
  70726. * Clear color to use when screen clearing
  70727. */
  70728. clearColor: Color4;
  70729. /**
  70730. * If the buffer needs to be cleared before applying the post process. (default: true)
  70731. * Should be set to false if shader will overwrite all previous pixels.
  70732. */
  70733. autoClear: boolean;
  70734. /**
  70735. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70736. */
  70737. alphaMode: number;
  70738. /**
  70739. * Sets the setAlphaBlendConstants of the babylon engine
  70740. */
  70741. alphaConstants: Color4;
  70742. /**
  70743. * Animations to be used for the post processing
  70744. */
  70745. animations: Animation[];
  70746. /**
  70747. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70748. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70749. */
  70750. enablePixelPerfectMode: boolean;
  70751. /**
  70752. * Force the postprocess to be applied without taking in account viewport
  70753. */
  70754. forceFullscreenViewport: boolean;
  70755. /**
  70756. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70757. *
  70758. * | Value | Type | Description |
  70759. * | ----- | ----------------------------------- | ----------- |
  70760. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70761. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70762. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70763. *
  70764. */
  70765. scaleMode: number;
  70766. /**
  70767. * Force textures to be a power of two (default: false)
  70768. */
  70769. alwaysForcePOT: boolean;
  70770. private _samples;
  70771. /**
  70772. * Number of sample textures (default: 1)
  70773. */
  70774. samples: number;
  70775. /**
  70776. * Modify the scale of the post process to be the same as the viewport (default: false)
  70777. */
  70778. adaptScaleToCurrentViewport: boolean;
  70779. private _camera;
  70780. private _scene;
  70781. private _engine;
  70782. private _options;
  70783. private _reusable;
  70784. private _textureType;
  70785. /**
  70786. * Smart array of input and output textures for the post process.
  70787. * @hidden
  70788. */
  70789. _textures: SmartArray<InternalTexture>;
  70790. /**
  70791. * The index in _textures that corresponds to the output texture.
  70792. * @hidden
  70793. */
  70794. _currentRenderTextureInd: number;
  70795. private _effect;
  70796. private _samplers;
  70797. private _fragmentUrl;
  70798. private _vertexUrl;
  70799. private _parameters;
  70800. private _scaleRatio;
  70801. protected _indexParameters: any;
  70802. private _shareOutputWithPostProcess;
  70803. private _texelSize;
  70804. private _forcedOutputTexture;
  70805. /**
  70806. * Returns the fragment url or shader name used in the post process.
  70807. * @returns the fragment url or name in the shader store.
  70808. */
  70809. getEffectName(): string;
  70810. /**
  70811. * An event triggered when the postprocess is activated.
  70812. */
  70813. onActivateObservable: Observable<Camera>;
  70814. private _onActivateObserver;
  70815. /**
  70816. * A function that is added to the onActivateObservable
  70817. */
  70818. onActivate: Nullable<(camera: Camera) => void>;
  70819. /**
  70820. * An event triggered when the postprocess changes its size.
  70821. */
  70822. onSizeChangedObservable: Observable<PostProcess>;
  70823. private _onSizeChangedObserver;
  70824. /**
  70825. * A function that is added to the onSizeChangedObservable
  70826. */
  70827. onSizeChanged: (postProcess: PostProcess) => void;
  70828. /**
  70829. * An event triggered when the postprocess applies its effect.
  70830. */
  70831. onApplyObservable: Observable<Effect>;
  70832. private _onApplyObserver;
  70833. /**
  70834. * A function that is added to the onApplyObservable
  70835. */
  70836. onApply: (effect: Effect) => void;
  70837. /**
  70838. * An event triggered before rendering the postprocess
  70839. */
  70840. onBeforeRenderObservable: Observable<Effect>;
  70841. private _onBeforeRenderObserver;
  70842. /**
  70843. * A function that is added to the onBeforeRenderObservable
  70844. */
  70845. onBeforeRender: (effect: Effect) => void;
  70846. /**
  70847. * An event triggered after rendering the postprocess
  70848. */
  70849. onAfterRenderObservable: Observable<Effect>;
  70850. private _onAfterRenderObserver;
  70851. /**
  70852. * A function that is added to the onAfterRenderObservable
  70853. */
  70854. onAfterRender: (efect: Effect) => void;
  70855. /**
  70856. * 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
  70857. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70858. */
  70859. inputTexture: InternalTexture;
  70860. /**
  70861. * Gets the camera which post process is applied to.
  70862. * @returns The camera the post process is applied to.
  70863. */
  70864. getCamera(): Camera;
  70865. /**
  70866. * Gets the texel size of the postprocess.
  70867. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70868. */
  70869. readonly texelSize: Vector2;
  70870. /**
  70871. * Creates a new instance PostProcess
  70872. * @param name The name of the PostProcess.
  70873. * @param fragmentUrl The url of the fragment shader to be used.
  70874. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70875. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70876. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70877. * @param camera The camera to apply the render pass to.
  70878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70879. * @param engine The engine which the post process will be applied. (default: current engine)
  70880. * @param reusable If the post process can be reused on the same frame. (default: false)
  70881. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70882. * @param textureType Type of textures used when performing the post process. (default: 0)
  70883. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70884. * @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
  70885. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70886. */
  70887. constructor(
  70888. /** Name of the PostProcess. */
  70889. 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);
  70890. /**
  70891. * Gets a string idenfifying the name of the class
  70892. * @returns "PostProcess" string
  70893. */
  70894. getClassName(): string;
  70895. /**
  70896. * Gets the engine which this post process belongs to.
  70897. * @returns The engine the post process was enabled with.
  70898. */
  70899. getEngine(): Engine;
  70900. /**
  70901. * The effect that is created when initializing the post process.
  70902. * @returns The created effect corrisponding the the postprocess.
  70903. */
  70904. getEffect(): Effect;
  70905. /**
  70906. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70907. * @param postProcess The post process to share the output with.
  70908. * @returns This post process.
  70909. */
  70910. shareOutputWith(postProcess: PostProcess): PostProcess;
  70911. /**
  70912. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70913. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70914. */
  70915. useOwnOutput(): void;
  70916. /**
  70917. * Updates the effect with the current post process compile time values and recompiles the shader.
  70918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70921. * @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
  70922. * @param onCompiled Called when the shader has been compiled.
  70923. * @param onError Called if there is an error when compiling a shader.
  70924. */
  70925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70926. /**
  70927. * The post process is reusable if it can be used multiple times within one frame.
  70928. * @returns If the post process is reusable
  70929. */
  70930. isReusable(): boolean;
  70931. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70932. markTextureDirty(): void;
  70933. /**
  70934. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70935. * 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.
  70936. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70937. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70938. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70939. * @returns The target texture that was bound to be written to.
  70940. */
  70941. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70942. /**
  70943. * If the post process is supported.
  70944. */
  70945. readonly isSupported: boolean;
  70946. /**
  70947. * The aspect ratio of the output texture.
  70948. */
  70949. readonly aspectRatio: number;
  70950. /**
  70951. * Get a value indicating if the post-process is ready to be used
  70952. * @returns true if the post-process is ready (shader is compiled)
  70953. */
  70954. isReady(): boolean;
  70955. /**
  70956. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70957. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70958. */
  70959. apply(): Nullable<Effect>;
  70960. private _disposeTextures;
  70961. /**
  70962. * Disposes the post process.
  70963. * @param camera The camera to dispose the post process on.
  70964. */
  70965. dispose(camera?: Camera): void;
  70966. }
  70967. }
  70968. declare module BABYLON {
  70969. /**
  70970. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70971. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70972. */
  70973. export class PostProcessManager {
  70974. private _scene;
  70975. private _indexBuffer;
  70976. private _vertexBuffers;
  70977. /**
  70978. * Creates a new instance PostProcess
  70979. * @param scene The scene that the post process is associated with.
  70980. */
  70981. constructor(scene: Scene);
  70982. private _prepareBuffers;
  70983. private _buildIndexBuffer;
  70984. /**
  70985. * Rebuilds the vertex buffers of the manager.
  70986. * @hidden
  70987. */
  70988. _rebuild(): void;
  70989. /**
  70990. * Prepares a frame to be run through a post process.
  70991. * @param sourceTexture The input texture to the post procesess. (default: null)
  70992. * @param postProcesses An array of post processes to be run. (default: null)
  70993. * @returns True if the post processes were able to be run.
  70994. * @hidden
  70995. */
  70996. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70997. /**
  70998. * Manually render a set of post processes to a texture.
  70999. * @param postProcesses An array of post processes to be run.
  71000. * @param targetTexture The target texture to render to.
  71001. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71002. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71003. * @param lodLevel defines which lod of the texture to render to
  71004. */
  71005. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71006. /**
  71007. * Finalize the result of the output of the postprocesses.
  71008. * @param doNotPresent If true the result will not be displayed to the screen.
  71009. * @param targetTexture The target texture to render to.
  71010. * @param faceIndex The index of the face to bind the target texture to.
  71011. * @param postProcesses The array of post processes to render.
  71012. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71013. * @hidden
  71014. */
  71015. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71016. /**
  71017. * Disposes of the post process manager.
  71018. */
  71019. dispose(): void;
  71020. }
  71021. }
  71022. declare module BABYLON {
  71023. interface AbstractScene {
  71024. /**
  71025. * The list of layers (background and foreground) of the scene
  71026. */
  71027. layers: Array<Layer>;
  71028. }
  71029. /**
  71030. * Defines the layer scene component responsible to manage any layers
  71031. * in a given scene.
  71032. */
  71033. export class LayerSceneComponent implements ISceneComponent {
  71034. /**
  71035. * The component name helpfull to identify the component in the list of scene components.
  71036. */
  71037. readonly name: string;
  71038. /**
  71039. * The scene the component belongs to.
  71040. */
  71041. scene: Scene;
  71042. private _engine;
  71043. /**
  71044. * Creates a new instance of the component for the given scene
  71045. * @param scene Defines the scene to register the component in
  71046. */
  71047. constructor(scene: Scene);
  71048. /**
  71049. * Registers the component in a given scene
  71050. */
  71051. register(): void;
  71052. /**
  71053. * Rebuilds the elements related to this component in case of
  71054. * context lost for instance.
  71055. */
  71056. rebuild(): void;
  71057. /**
  71058. * Disposes the component and the associated ressources.
  71059. */
  71060. dispose(): void;
  71061. private _draw;
  71062. private _drawCameraPredicate;
  71063. private _drawCameraBackground;
  71064. private _drawCameraForeground;
  71065. private _drawRenderTargetPredicate;
  71066. private _drawRenderTargetBackground;
  71067. private _drawRenderTargetForeground;
  71068. }
  71069. }
  71070. declare module BABYLON {
  71071. /** @hidden */
  71072. export var layerPixelShader: {
  71073. name: string;
  71074. shader: string;
  71075. };
  71076. }
  71077. declare module BABYLON {
  71078. /** @hidden */
  71079. export var layerVertexShader: {
  71080. name: string;
  71081. shader: string;
  71082. };
  71083. }
  71084. declare module BABYLON {
  71085. /**
  71086. * This represents a full screen 2d layer.
  71087. * This can be useful to display a picture in the background of your scene for instance.
  71088. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71089. */
  71090. export class Layer {
  71091. /**
  71092. * Define the name of the layer.
  71093. */
  71094. name: string;
  71095. /**
  71096. * Define the texture the layer should display.
  71097. */
  71098. texture: Nullable<Texture>;
  71099. /**
  71100. * Is the layer in background or foreground.
  71101. */
  71102. isBackground: boolean;
  71103. /**
  71104. * Define the color of the layer (instead of texture).
  71105. */
  71106. color: Color4;
  71107. /**
  71108. * Define the scale of the layer in order to zoom in out of the texture.
  71109. */
  71110. scale: Vector2;
  71111. /**
  71112. * Define an offset for the layer in order to shift the texture.
  71113. */
  71114. offset: Vector2;
  71115. /**
  71116. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71117. */
  71118. alphaBlendingMode: number;
  71119. /**
  71120. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71121. * Alpha test will not mix with the background color in case of transparency.
  71122. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71123. */
  71124. alphaTest: boolean;
  71125. /**
  71126. * Define a mask to restrict the layer to only some of the scene cameras.
  71127. */
  71128. layerMask: number;
  71129. /**
  71130. * Define the list of render target the layer is visible into.
  71131. */
  71132. renderTargetTextures: RenderTargetTexture[];
  71133. /**
  71134. * Define if the layer is only used in renderTarget or if it also
  71135. * renders in the main frame buffer of the canvas.
  71136. */
  71137. renderOnlyInRenderTargetTextures: boolean;
  71138. private _scene;
  71139. private _vertexBuffers;
  71140. private _indexBuffer;
  71141. private _effect;
  71142. private _alphaTestEffect;
  71143. /**
  71144. * An event triggered when the layer is disposed.
  71145. */
  71146. onDisposeObservable: Observable<Layer>;
  71147. private _onDisposeObserver;
  71148. /**
  71149. * Back compatibility with callback before the onDisposeObservable existed.
  71150. * The set callback will be triggered when the layer has been disposed.
  71151. */
  71152. onDispose: () => void;
  71153. /**
  71154. * An event triggered before rendering the scene
  71155. */
  71156. onBeforeRenderObservable: Observable<Layer>;
  71157. private _onBeforeRenderObserver;
  71158. /**
  71159. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71160. * The set callback will be triggered just before rendering the layer.
  71161. */
  71162. onBeforeRender: () => void;
  71163. /**
  71164. * An event triggered after rendering the scene
  71165. */
  71166. onAfterRenderObservable: Observable<Layer>;
  71167. private _onAfterRenderObserver;
  71168. /**
  71169. * Back compatibility with callback before the onAfterRenderObservable existed.
  71170. * The set callback will be triggered just after rendering the layer.
  71171. */
  71172. onAfterRender: () => void;
  71173. /**
  71174. * Instantiates a new layer.
  71175. * This represents a full screen 2d layer.
  71176. * This can be useful to display a picture in the background of your scene for instance.
  71177. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71178. * @param name Define the name of the layer in the scene
  71179. * @param imgUrl Define the url of the texture to display in the layer
  71180. * @param scene Define the scene the layer belongs to
  71181. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71182. * @param color Defines a color for the layer
  71183. */
  71184. constructor(
  71185. /**
  71186. * Define the name of the layer.
  71187. */
  71188. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71189. private _createIndexBuffer;
  71190. /** @hidden */
  71191. _rebuild(): void;
  71192. /**
  71193. * Renders the layer in the scene.
  71194. */
  71195. render(): void;
  71196. /**
  71197. * Disposes and releases the associated ressources.
  71198. */
  71199. dispose(): void;
  71200. }
  71201. }
  71202. declare module BABYLON {
  71203. interface AbstractScene {
  71204. /**
  71205. * The list of procedural textures added to the scene
  71206. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71207. */
  71208. proceduralTextures: Array<ProceduralTexture>;
  71209. }
  71210. /**
  71211. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71212. * in a given scene.
  71213. */
  71214. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71215. /**
  71216. * The component name helpfull to identify the component in the list of scene components.
  71217. */
  71218. readonly name: string;
  71219. /**
  71220. * The scene the component belongs to.
  71221. */
  71222. scene: Scene;
  71223. /**
  71224. * Creates a new instance of the component for the given scene
  71225. * @param scene Defines the scene to register the component in
  71226. */
  71227. constructor(scene: Scene);
  71228. /**
  71229. * Registers the component in a given scene
  71230. */
  71231. register(): void;
  71232. /**
  71233. * Rebuilds the elements related to this component in case of
  71234. * context lost for instance.
  71235. */
  71236. rebuild(): void;
  71237. /**
  71238. * Disposes the component and the associated ressources.
  71239. */
  71240. dispose(): void;
  71241. private _beforeClear;
  71242. }
  71243. }
  71244. declare module BABYLON {
  71245. /** @hidden */
  71246. export var proceduralVertexShader: {
  71247. name: string;
  71248. shader: string;
  71249. };
  71250. }
  71251. declare module BABYLON {
  71252. /**
  71253. * 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.
  71254. * This is the base class of any Procedural texture and contains most of the shareable code.
  71255. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71256. */
  71257. export class ProceduralTexture extends Texture {
  71258. isCube: boolean;
  71259. /**
  71260. * Define if the texture is enabled or not (disabled texture will not render)
  71261. */
  71262. isEnabled: boolean;
  71263. /**
  71264. * Define if the texture must be cleared before rendering (default is true)
  71265. */
  71266. autoClear: boolean;
  71267. /**
  71268. * Callback called when the texture is generated
  71269. */
  71270. onGenerated: () => void;
  71271. /**
  71272. * Event raised when the texture is generated
  71273. */
  71274. onGeneratedObservable: Observable<ProceduralTexture>;
  71275. /** @hidden */
  71276. _generateMipMaps: boolean;
  71277. /** @hidden **/
  71278. _effect: Effect;
  71279. /** @hidden */
  71280. _textures: {
  71281. [key: string]: Texture;
  71282. };
  71283. private _size;
  71284. private _currentRefreshId;
  71285. private _refreshRate;
  71286. private _vertexBuffers;
  71287. private _indexBuffer;
  71288. private _uniforms;
  71289. private _samplers;
  71290. private _fragment;
  71291. private _floats;
  71292. private _ints;
  71293. private _floatsArrays;
  71294. private _colors3;
  71295. private _colors4;
  71296. private _vectors2;
  71297. private _vectors3;
  71298. private _matrices;
  71299. private _fallbackTexture;
  71300. private _fallbackTextureUsed;
  71301. private _engine;
  71302. private _cachedDefines;
  71303. private _contentUpdateId;
  71304. private _contentData;
  71305. /**
  71306. * Instantiates a new procedural texture.
  71307. * 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.
  71308. * This is the base class of any Procedural texture and contains most of the shareable code.
  71309. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71310. * @param name Define the name of the texture
  71311. * @param size Define the size of the texture to create
  71312. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71313. * @param scene Define the scene the texture belongs to
  71314. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71315. * @param generateMipMaps Define if the texture should creates mip maps or not
  71316. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71317. */
  71318. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71319. /**
  71320. * The effect that is created when initializing the post process.
  71321. * @returns The created effect corrisponding the the postprocess.
  71322. */
  71323. getEffect(): Effect;
  71324. /**
  71325. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71326. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71327. */
  71328. getContent(): Nullable<ArrayBufferView>;
  71329. private _createIndexBuffer;
  71330. /** @hidden */
  71331. _rebuild(): void;
  71332. /**
  71333. * Resets the texture in order to recreate its associated resources.
  71334. * This can be called in case of context loss
  71335. */
  71336. reset(): void;
  71337. protected _getDefines(): string;
  71338. /**
  71339. * Is the texture ready to be used ? (rendered at least once)
  71340. * @returns true if ready, otherwise, false.
  71341. */
  71342. isReady(): boolean;
  71343. /**
  71344. * Resets the refresh counter of the texture and start bak from scratch.
  71345. * Could be useful to regenerate the texture if it is setup to render only once.
  71346. */
  71347. resetRefreshCounter(): void;
  71348. /**
  71349. * Set the fragment shader to use in order to render the texture.
  71350. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71351. */
  71352. setFragment(fragment: any): void;
  71353. /**
  71354. * Define the refresh rate of the texture or the rendering frequency.
  71355. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71356. */
  71357. refreshRate: number;
  71358. /** @hidden */
  71359. _shouldRender(): boolean;
  71360. /**
  71361. * Get the size the texture is rendering at.
  71362. * @returns the size (texture is always squared)
  71363. */
  71364. getRenderSize(): number;
  71365. /**
  71366. * Resize the texture to new value.
  71367. * @param size Define the new size the texture should have
  71368. * @param generateMipMaps Define whether the new texture should create mip maps
  71369. */
  71370. resize(size: number, generateMipMaps: boolean): void;
  71371. private _checkUniform;
  71372. /**
  71373. * Set a texture in the shader program used to render.
  71374. * @param name Define the name of the uniform samplers as defined in the shader
  71375. * @param texture Define the texture to bind to this sampler
  71376. * @return the texture itself allowing "fluent" like uniform updates
  71377. */
  71378. setTexture(name: string, texture: Texture): ProceduralTexture;
  71379. /**
  71380. * Set a float in the shader.
  71381. * @param name Define the name of the uniform as defined in the shader
  71382. * @param value Define the value to give to the uniform
  71383. * @return the texture itself allowing "fluent" like uniform updates
  71384. */
  71385. setFloat(name: string, value: number): ProceduralTexture;
  71386. /**
  71387. * Set a int in the shader.
  71388. * @param name Define the name of the uniform as defined in the shader
  71389. * @param value Define the value to give to the uniform
  71390. * @return the texture itself allowing "fluent" like uniform updates
  71391. */
  71392. setInt(name: string, value: number): ProceduralTexture;
  71393. /**
  71394. * Set an array of floats in the shader.
  71395. * @param name Define the name of the uniform as defined in the shader
  71396. * @param value Define the value to give to the uniform
  71397. * @return the texture itself allowing "fluent" like uniform updates
  71398. */
  71399. setFloats(name: string, value: number[]): ProceduralTexture;
  71400. /**
  71401. * Set a vec3 in the shader from a Color3.
  71402. * @param name Define the name of the uniform as defined in the shader
  71403. * @param value Define the value to give to the uniform
  71404. * @return the texture itself allowing "fluent" like uniform updates
  71405. */
  71406. setColor3(name: string, value: Color3): ProceduralTexture;
  71407. /**
  71408. * Set a vec4 in the shader from a Color4.
  71409. * @param name Define the name of the uniform as defined in the shader
  71410. * @param value Define the value to give to the uniform
  71411. * @return the texture itself allowing "fluent" like uniform updates
  71412. */
  71413. setColor4(name: string, value: Color4): ProceduralTexture;
  71414. /**
  71415. * Set a vec2 in the shader from a Vector2.
  71416. * @param name Define the name of the uniform as defined in the shader
  71417. * @param value Define the value to give to the uniform
  71418. * @return the texture itself allowing "fluent" like uniform updates
  71419. */
  71420. setVector2(name: string, value: Vector2): ProceduralTexture;
  71421. /**
  71422. * Set a vec3 in the shader from a Vector3.
  71423. * @param name Define the name of the uniform as defined in the shader
  71424. * @param value Define the value to give to the uniform
  71425. * @return the texture itself allowing "fluent" like uniform updates
  71426. */
  71427. setVector3(name: string, value: Vector3): ProceduralTexture;
  71428. /**
  71429. * Set a mat4 in the shader from a MAtrix.
  71430. * @param name Define the name of the uniform as defined in the shader
  71431. * @param value Define the value to give to the uniform
  71432. * @return the texture itself allowing "fluent" like uniform updates
  71433. */
  71434. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71435. /**
  71436. * Render the texture to its associated render target.
  71437. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71438. */
  71439. render(useCameraPostProcess?: boolean): void;
  71440. /**
  71441. * Clone the texture.
  71442. * @returns the cloned texture
  71443. */
  71444. clone(): ProceduralTexture;
  71445. /**
  71446. * Dispose the texture and release its asoociated resources.
  71447. */
  71448. dispose(): void;
  71449. }
  71450. }
  71451. declare module BABYLON {
  71452. /**
  71453. * This represents the base class for particle system in Babylon.
  71454. * 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.
  71455. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71456. * @example https://doc.babylonjs.com/babylon101/particles
  71457. */
  71458. export class BaseParticleSystem {
  71459. /**
  71460. * Source color is added to the destination color without alpha affecting the result
  71461. */
  71462. static BLENDMODE_ONEONE: number;
  71463. /**
  71464. * Blend current color and particle color using particle’s alpha
  71465. */
  71466. static BLENDMODE_STANDARD: number;
  71467. /**
  71468. * Add current color and particle color multiplied by particle’s alpha
  71469. */
  71470. static BLENDMODE_ADD: number;
  71471. /**
  71472. * Multiply current color with particle color
  71473. */
  71474. static BLENDMODE_MULTIPLY: number;
  71475. /**
  71476. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71477. */
  71478. static BLENDMODE_MULTIPLYADD: number;
  71479. /**
  71480. * List of animations used by the particle system.
  71481. */
  71482. animations: Animation[];
  71483. /**
  71484. * The id of the Particle system.
  71485. */
  71486. id: string;
  71487. /**
  71488. * The friendly name of the Particle system.
  71489. */
  71490. name: string;
  71491. /**
  71492. * The rendering group used by the Particle system to chose when to render.
  71493. */
  71494. renderingGroupId: number;
  71495. /**
  71496. * The emitter represents the Mesh or position we are attaching the particle system to.
  71497. */
  71498. emitter: Nullable<AbstractMesh | Vector3>;
  71499. /**
  71500. * The maximum number of particles to emit per frame
  71501. */
  71502. emitRate: number;
  71503. /**
  71504. * If you want to launch only a few particles at once, that can be done, as well.
  71505. */
  71506. manualEmitCount: number;
  71507. /**
  71508. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71509. */
  71510. updateSpeed: number;
  71511. /**
  71512. * The amount of time the particle system is running (depends of the overall update speed).
  71513. */
  71514. targetStopDuration: number;
  71515. /**
  71516. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71517. */
  71518. disposeOnStop: boolean;
  71519. /**
  71520. * Minimum power of emitting particles.
  71521. */
  71522. minEmitPower: number;
  71523. /**
  71524. * Maximum power of emitting particles.
  71525. */
  71526. maxEmitPower: number;
  71527. /**
  71528. * Minimum life time of emitting particles.
  71529. */
  71530. minLifeTime: number;
  71531. /**
  71532. * Maximum life time of emitting particles.
  71533. */
  71534. maxLifeTime: number;
  71535. /**
  71536. * Minimum Size of emitting particles.
  71537. */
  71538. minSize: number;
  71539. /**
  71540. * Maximum Size of emitting particles.
  71541. */
  71542. maxSize: number;
  71543. /**
  71544. * Minimum scale of emitting particles on X axis.
  71545. */
  71546. minScaleX: number;
  71547. /**
  71548. * Maximum scale of emitting particles on X axis.
  71549. */
  71550. maxScaleX: number;
  71551. /**
  71552. * Minimum scale of emitting particles on Y axis.
  71553. */
  71554. minScaleY: number;
  71555. /**
  71556. * Maximum scale of emitting particles on Y axis.
  71557. */
  71558. maxScaleY: number;
  71559. /**
  71560. * Gets or sets the minimal initial rotation in radians.
  71561. */
  71562. minInitialRotation: number;
  71563. /**
  71564. * Gets or sets the maximal initial rotation in radians.
  71565. */
  71566. maxInitialRotation: number;
  71567. /**
  71568. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71569. */
  71570. minAngularSpeed: number;
  71571. /**
  71572. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71573. */
  71574. maxAngularSpeed: number;
  71575. /**
  71576. * The texture used to render each particle. (this can be a spritesheet)
  71577. */
  71578. particleTexture: Nullable<Texture>;
  71579. /**
  71580. * The layer mask we are rendering the particles through.
  71581. */
  71582. layerMask: number;
  71583. /**
  71584. * This can help using your own shader to render the particle system.
  71585. * The according effect will be created
  71586. */
  71587. customShader: any;
  71588. /**
  71589. * By default particle system starts as soon as they are created. This prevents the
  71590. * automatic start to happen and let you decide when to start emitting particles.
  71591. */
  71592. preventAutoStart: boolean;
  71593. private _noiseTexture;
  71594. /**
  71595. * Gets or sets a texture used to add random noise to particle positions
  71596. */
  71597. noiseTexture: Nullable<ProceduralTexture>;
  71598. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71599. noiseStrength: Vector3;
  71600. /**
  71601. * Callback triggered when the particle animation is ending.
  71602. */
  71603. onAnimationEnd: Nullable<() => void>;
  71604. /**
  71605. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71606. */
  71607. blendMode: number;
  71608. /**
  71609. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71610. * to override the particles.
  71611. */
  71612. forceDepthWrite: boolean;
  71613. /** 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 */
  71614. preWarmCycles: number;
  71615. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71616. preWarmStepOffset: number;
  71617. /**
  71618. * 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)
  71619. */
  71620. spriteCellChangeSpeed: number;
  71621. /**
  71622. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71623. */
  71624. startSpriteCellID: number;
  71625. /**
  71626. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71627. */
  71628. endSpriteCellID: number;
  71629. /**
  71630. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71631. */
  71632. spriteCellWidth: number;
  71633. /**
  71634. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71635. */
  71636. spriteCellHeight: number;
  71637. /**
  71638. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71639. */
  71640. spriteRandomStartCell: boolean;
  71641. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71642. translationPivot: Vector2;
  71643. /** @hidden */
  71644. protected _isAnimationSheetEnabled: boolean;
  71645. /**
  71646. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71647. */
  71648. beginAnimationOnStart: boolean;
  71649. /**
  71650. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71651. */
  71652. beginAnimationFrom: number;
  71653. /**
  71654. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71655. */
  71656. beginAnimationTo: number;
  71657. /**
  71658. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71659. */
  71660. beginAnimationLoop: boolean;
  71661. /**
  71662. * Gets or sets a world offset applied to all particles
  71663. */
  71664. worldOffset: Vector3;
  71665. /**
  71666. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71667. */
  71668. isAnimationSheetEnabled: boolean;
  71669. /**
  71670. * Get hosting scene
  71671. * @returns the scene
  71672. */
  71673. getScene(): Scene;
  71674. /**
  71675. * You can use gravity if you want to give an orientation to your particles.
  71676. */
  71677. gravity: Vector3;
  71678. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71679. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71680. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71681. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71682. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71683. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71684. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71685. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71686. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71687. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71688. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71689. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71690. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71691. /**
  71692. * Defines the delay in milliseconds before starting the system (0 by default)
  71693. */
  71694. startDelay: number;
  71695. /**
  71696. * Gets the current list of drag gradients.
  71697. * You must use addDragGradient and removeDragGradient to udpate this list
  71698. * @returns the list of drag gradients
  71699. */
  71700. getDragGradients(): Nullable<Array<FactorGradient>>;
  71701. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71702. limitVelocityDamping: number;
  71703. /**
  71704. * Gets the current list of limit velocity gradients.
  71705. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71706. * @returns the list of limit velocity gradients
  71707. */
  71708. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71709. /**
  71710. * Gets the current list of color gradients.
  71711. * You must use addColorGradient and removeColorGradient to udpate this list
  71712. * @returns the list of color gradients
  71713. */
  71714. getColorGradients(): Nullable<Array<ColorGradient>>;
  71715. /**
  71716. * Gets the current list of size gradients.
  71717. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71718. * @returns the list of size gradients
  71719. */
  71720. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71721. /**
  71722. * Gets the current list of color remap gradients.
  71723. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71724. * @returns the list of color remap gradients
  71725. */
  71726. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71727. /**
  71728. * Gets the current list of alpha remap gradients.
  71729. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71730. * @returns the list of alpha remap gradients
  71731. */
  71732. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71733. /**
  71734. * Gets the current list of life time gradients.
  71735. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71736. * @returns the list of life time gradients
  71737. */
  71738. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71739. /**
  71740. * Gets the current list of angular speed gradients.
  71741. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71742. * @returns the list of angular speed gradients
  71743. */
  71744. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71745. /**
  71746. * Gets the current list of velocity gradients.
  71747. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71748. * @returns the list of velocity gradients
  71749. */
  71750. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71751. /**
  71752. * Gets the current list of start size gradients.
  71753. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71754. * @returns the list of start size gradients
  71755. */
  71756. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71757. /**
  71758. * Gets the current list of emit rate gradients.
  71759. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71760. * @returns the list of emit rate gradients
  71761. */
  71762. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71763. /**
  71764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71765. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71766. */
  71767. direction1: Vector3;
  71768. /**
  71769. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71770. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71771. */
  71772. direction2: Vector3;
  71773. /**
  71774. * 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.
  71775. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71776. */
  71777. minEmitBox: Vector3;
  71778. /**
  71779. * 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.
  71780. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71781. */
  71782. maxEmitBox: Vector3;
  71783. /**
  71784. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71785. */
  71786. color1: Color4;
  71787. /**
  71788. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71789. */
  71790. color2: Color4;
  71791. /**
  71792. * Color the particle will have at the end of its lifetime
  71793. */
  71794. colorDead: Color4;
  71795. /**
  71796. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71797. */
  71798. textureMask: Color4;
  71799. /**
  71800. * The particle emitter type defines the emitter used by the particle system.
  71801. * It can be for example box, sphere, or cone...
  71802. */
  71803. particleEmitterType: IParticleEmitterType;
  71804. /** @hidden */
  71805. _isSubEmitter: boolean;
  71806. /**
  71807. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71808. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71809. */
  71810. billboardMode: number;
  71811. protected _isBillboardBased: boolean;
  71812. /**
  71813. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71814. */
  71815. isBillboardBased: boolean;
  71816. /**
  71817. * The scene the particle system belongs to.
  71818. */
  71819. protected _scene: Scene;
  71820. /**
  71821. * Local cache of defines for image processing.
  71822. */
  71823. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71824. /**
  71825. * Default configuration related to image processing available in the standard Material.
  71826. */
  71827. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71828. /**
  71829. * Gets the image processing configuration used either in this material.
  71830. */
  71831. /**
  71832. * Sets the Default image processing configuration used either in the this material.
  71833. *
  71834. * If sets to null, the scene one is in use.
  71835. */
  71836. imageProcessingConfiguration: ImageProcessingConfiguration;
  71837. /**
  71838. * Attaches a new image processing configuration to the Standard Material.
  71839. * @param configuration
  71840. */
  71841. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71842. /** @hidden */
  71843. protected _reset(): void;
  71844. /** @hidden */
  71845. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71846. /**
  71847. * Instantiates a particle system.
  71848. * 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.
  71849. * @param name The name of the particle system
  71850. */
  71851. constructor(name: string);
  71852. /**
  71853. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71856. * @returns the emitter
  71857. */
  71858. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71859. /**
  71860. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71861. * @param radius The radius of the hemisphere to emit from
  71862. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71863. * @returns the emitter
  71864. */
  71865. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71866. /**
  71867. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71868. * @param radius The radius of the sphere to emit from
  71869. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71870. * @returns the emitter
  71871. */
  71872. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71873. /**
  71874. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71875. * @param radius The radius of the sphere to emit from
  71876. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71877. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71878. * @returns the emitter
  71879. */
  71880. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71881. /**
  71882. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71883. * @param radius The radius of the emission cylinder
  71884. * @param height The height of the emission cylinder
  71885. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71886. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71887. * @returns the emitter
  71888. */
  71889. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71890. /**
  71891. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71892. * @param radius The radius of the cylinder to emit from
  71893. * @param height The height of the emission cylinder
  71894. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71895. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71896. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71897. * @returns the emitter
  71898. */
  71899. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71900. /**
  71901. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71902. * @param radius The radius of the cone to emit from
  71903. * @param angle The base angle of the cone
  71904. * @returns the emitter
  71905. */
  71906. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71907. /**
  71908. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71909. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71910. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71911. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71912. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71913. * @returns the emitter
  71914. */
  71915. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71916. }
  71917. }
  71918. declare module BABYLON {
  71919. /**
  71920. * Type of sub emitter
  71921. */
  71922. export enum SubEmitterType {
  71923. /**
  71924. * Attached to the particle over it's lifetime
  71925. */
  71926. ATTACHED = 0,
  71927. /**
  71928. * Created when the particle dies
  71929. */
  71930. END = 1
  71931. }
  71932. /**
  71933. * Sub emitter class used to emit particles from an existing particle
  71934. */
  71935. export class SubEmitter {
  71936. /**
  71937. * the particle system to be used by the sub emitter
  71938. */
  71939. particleSystem: ParticleSystem;
  71940. /**
  71941. * Type of the submitter (Default: END)
  71942. */
  71943. type: SubEmitterType;
  71944. /**
  71945. * 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)
  71946. * Note: This only is supported when using an emitter of type Mesh
  71947. */
  71948. inheritDirection: boolean;
  71949. /**
  71950. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71951. */
  71952. inheritedVelocityAmount: number;
  71953. /**
  71954. * Creates a sub emitter
  71955. * @param particleSystem the particle system to be used by the sub emitter
  71956. */
  71957. constructor(
  71958. /**
  71959. * the particle system to be used by the sub emitter
  71960. */
  71961. particleSystem: ParticleSystem);
  71962. /**
  71963. * Clones the sub emitter
  71964. * @returns the cloned sub emitter
  71965. */
  71966. clone(): SubEmitter;
  71967. /**
  71968. * Serialize current object to a JSON object
  71969. * @returns the serialized object
  71970. */
  71971. serialize(): any;
  71972. /** @hidden */
  71973. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71974. /**
  71975. * Creates a new SubEmitter from a serialized JSON version
  71976. * @param serializationObject defines the JSON object to read from
  71977. * @param scene defines the hosting scene
  71978. * @param rootUrl defines the rootUrl for data loading
  71979. * @returns a new SubEmitter
  71980. */
  71981. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71982. /** Release associated resources */
  71983. dispose(): void;
  71984. }
  71985. }
  71986. declare module BABYLON {
  71987. /** @hidden */
  71988. export var clipPlaneFragmentDeclaration: {
  71989. name: string;
  71990. shader: string;
  71991. };
  71992. }
  71993. declare module BABYLON {
  71994. /** @hidden */
  71995. export var imageProcessingDeclaration: {
  71996. name: string;
  71997. shader: string;
  71998. };
  71999. }
  72000. declare module BABYLON {
  72001. /** @hidden */
  72002. export var imageProcessingFunctions: {
  72003. name: string;
  72004. shader: string;
  72005. };
  72006. }
  72007. declare module BABYLON {
  72008. /** @hidden */
  72009. export var clipPlaneFragment: {
  72010. name: string;
  72011. shader: string;
  72012. };
  72013. }
  72014. declare module BABYLON {
  72015. /** @hidden */
  72016. export var particlesPixelShader: {
  72017. name: string;
  72018. shader: string;
  72019. };
  72020. }
  72021. declare module BABYLON {
  72022. /** @hidden */
  72023. export var clipPlaneVertexDeclaration: {
  72024. name: string;
  72025. shader: string;
  72026. };
  72027. }
  72028. declare module BABYLON {
  72029. /** @hidden */
  72030. export var clipPlaneVertex: {
  72031. name: string;
  72032. shader: string;
  72033. };
  72034. }
  72035. declare module BABYLON {
  72036. /** @hidden */
  72037. export var particlesVertexShader: {
  72038. name: string;
  72039. shader: string;
  72040. };
  72041. }
  72042. declare module BABYLON {
  72043. /**
  72044. * This represents a particle system in Babylon.
  72045. * 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.
  72046. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72047. * @example https://doc.babylonjs.com/babylon101/particles
  72048. */
  72049. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72050. /**
  72051. * Billboard mode will only apply to Y axis
  72052. */
  72053. static readonly BILLBOARDMODE_Y: number;
  72054. /**
  72055. * Billboard mode will apply to all axes
  72056. */
  72057. static readonly BILLBOARDMODE_ALL: number;
  72058. /**
  72059. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72060. */
  72061. static readonly BILLBOARDMODE_STRETCHED: number;
  72062. /**
  72063. * This function can be defined to provide custom update for active particles.
  72064. * This function will be called instead of regular update (age, position, color, etc.).
  72065. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72066. */
  72067. updateFunction: (particles: Particle[]) => void;
  72068. private _emitterWorldMatrix;
  72069. /**
  72070. * This function can be defined to specify initial direction for every new particle.
  72071. * It by default use the emitterType defined function
  72072. */
  72073. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72074. /**
  72075. * This function can be defined to specify initial position for every new particle.
  72076. * It by default use the emitterType defined function
  72077. */
  72078. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72079. /**
  72080. * @hidden
  72081. */
  72082. _inheritedVelocityOffset: Vector3;
  72083. /**
  72084. * An event triggered when the system is disposed
  72085. */
  72086. onDisposeObservable: Observable<ParticleSystem>;
  72087. private _onDisposeObserver;
  72088. /**
  72089. * Sets a callback that will be triggered when the system is disposed
  72090. */
  72091. onDispose: () => void;
  72092. private _particles;
  72093. private _epsilon;
  72094. private _capacity;
  72095. private _stockParticles;
  72096. private _newPartsExcess;
  72097. private _vertexData;
  72098. private _vertexBuffer;
  72099. private _vertexBuffers;
  72100. private _spriteBuffer;
  72101. private _indexBuffer;
  72102. private _effect;
  72103. private _customEffect;
  72104. private _cachedDefines;
  72105. private _scaledColorStep;
  72106. private _colorDiff;
  72107. private _scaledDirection;
  72108. private _scaledGravity;
  72109. private _currentRenderId;
  72110. private _alive;
  72111. private _useInstancing;
  72112. private _started;
  72113. private _stopped;
  72114. private _actualFrame;
  72115. private _scaledUpdateSpeed;
  72116. private _vertexBufferSize;
  72117. /** @hidden */
  72118. _currentEmitRateGradient: Nullable<FactorGradient>;
  72119. /** @hidden */
  72120. _currentEmitRate1: number;
  72121. /** @hidden */
  72122. _currentEmitRate2: number;
  72123. /** @hidden */
  72124. _currentStartSizeGradient: Nullable<FactorGradient>;
  72125. /** @hidden */
  72126. _currentStartSize1: number;
  72127. /** @hidden */
  72128. _currentStartSize2: number;
  72129. private readonly _rawTextureWidth;
  72130. private _rampGradientsTexture;
  72131. private _useRampGradients;
  72132. /** Gets or sets a boolean indicating that ramp gradients must be used
  72133. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72134. */
  72135. useRampGradients: boolean;
  72136. /**
  72137. * 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.
  72138. * 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: [])
  72139. */
  72140. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72141. private _subEmitters;
  72142. /**
  72143. * @hidden
  72144. * If the particle systems emitter should be disposed when the particle system is disposed
  72145. */
  72146. _disposeEmitterOnDispose: boolean;
  72147. /**
  72148. * The current active Sub-systems, this property is used by the root particle system only.
  72149. */
  72150. activeSubSystems: Array<ParticleSystem>;
  72151. private _rootParticleSystem;
  72152. /**
  72153. * Gets the current list of active particles
  72154. */
  72155. readonly particles: Particle[];
  72156. /**
  72157. * Returns the string "ParticleSystem"
  72158. * @returns a string containing the class name
  72159. */
  72160. getClassName(): string;
  72161. /**
  72162. * Instantiates a particle system.
  72163. * 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.
  72164. * @param name The name of the particle system
  72165. * @param capacity The max number of particles alive at the same time
  72166. * @param scene The scene the particle system belongs to
  72167. * @param customEffect a custom effect used to change the way particles are rendered by default
  72168. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72169. * @param epsilon Offset used to render the particles
  72170. */
  72171. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72172. private _addFactorGradient;
  72173. private _removeFactorGradient;
  72174. /**
  72175. * Adds a new life time gradient
  72176. * @param gradient defines the gradient to use (between 0 and 1)
  72177. * @param factor defines the life time factor to affect to the specified gradient
  72178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72179. * @returns the current particle system
  72180. */
  72181. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72182. /**
  72183. * Remove a specific life time gradient
  72184. * @param gradient defines the gradient to remove
  72185. * @returns the current particle system
  72186. */
  72187. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72188. /**
  72189. * Adds a new size gradient
  72190. * @param gradient defines the gradient to use (between 0 and 1)
  72191. * @param factor defines the size factor to affect to the specified gradient
  72192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72193. * @returns the current particle system
  72194. */
  72195. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72196. /**
  72197. * Remove a specific size gradient
  72198. * @param gradient defines the gradient to remove
  72199. * @returns the current particle system
  72200. */
  72201. removeSizeGradient(gradient: number): IParticleSystem;
  72202. /**
  72203. * Adds a new color remap gradient
  72204. * @param gradient defines the gradient to use (between 0 and 1)
  72205. * @param min defines the color remap minimal range
  72206. * @param max defines the color remap maximal range
  72207. * @returns the current particle system
  72208. */
  72209. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72210. /**
  72211. * Remove a specific color remap gradient
  72212. * @param gradient defines the gradient to remove
  72213. * @returns the current particle system
  72214. */
  72215. removeColorRemapGradient(gradient: number): IParticleSystem;
  72216. /**
  72217. * Adds a new alpha remap gradient
  72218. * @param gradient defines the gradient to use (between 0 and 1)
  72219. * @param min defines the alpha remap minimal range
  72220. * @param max defines the alpha remap maximal range
  72221. * @returns the current particle system
  72222. */
  72223. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72224. /**
  72225. * Remove a specific alpha remap gradient
  72226. * @param gradient defines the gradient to remove
  72227. * @returns the current particle system
  72228. */
  72229. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72230. /**
  72231. * Adds a new angular speed gradient
  72232. * @param gradient defines the gradient to use (between 0 and 1)
  72233. * @param factor defines the angular speed to affect to the specified gradient
  72234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72235. * @returns the current particle system
  72236. */
  72237. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72238. /**
  72239. * Remove a specific angular speed gradient
  72240. * @param gradient defines the gradient to remove
  72241. * @returns the current particle system
  72242. */
  72243. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72244. /**
  72245. * Adds a new velocity gradient
  72246. * @param gradient defines the gradient to use (between 0 and 1)
  72247. * @param factor defines the velocity to affect to the specified gradient
  72248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72249. * @returns the current particle system
  72250. */
  72251. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72252. /**
  72253. * Remove a specific velocity gradient
  72254. * @param gradient defines the gradient to remove
  72255. * @returns the current particle system
  72256. */
  72257. removeVelocityGradient(gradient: number): IParticleSystem;
  72258. /**
  72259. * Adds a new limit velocity gradient
  72260. * @param gradient defines the gradient to use (between 0 and 1)
  72261. * @param factor defines the limit velocity value to affect to the specified gradient
  72262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72263. * @returns the current particle system
  72264. */
  72265. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72266. /**
  72267. * Remove a specific limit velocity gradient
  72268. * @param gradient defines the gradient to remove
  72269. * @returns the current particle system
  72270. */
  72271. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72272. /**
  72273. * Adds a new drag gradient
  72274. * @param gradient defines the gradient to use (between 0 and 1)
  72275. * @param factor defines the drag value to affect to the specified gradient
  72276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72277. * @returns the current particle system
  72278. */
  72279. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72280. /**
  72281. * Remove a specific drag gradient
  72282. * @param gradient defines the gradient to remove
  72283. * @returns the current particle system
  72284. */
  72285. removeDragGradient(gradient: number): IParticleSystem;
  72286. /**
  72287. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72288. * @param gradient defines the gradient to use (between 0 and 1)
  72289. * @param factor defines the emit rate value to affect to the specified gradient
  72290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72291. * @returns the current particle system
  72292. */
  72293. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72294. /**
  72295. * Remove a specific emit rate gradient
  72296. * @param gradient defines the gradient to remove
  72297. * @returns the current particle system
  72298. */
  72299. removeEmitRateGradient(gradient: number): IParticleSystem;
  72300. /**
  72301. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72302. * @param gradient defines the gradient to use (between 0 and 1)
  72303. * @param factor defines the start size value to affect to the specified gradient
  72304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72305. * @returns the current particle system
  72306. */
  72307. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72308. /**
  72309. * Remove a specific start size gradient
  72310. * @param gradient defines the gradient to remove
  72311. * @returns the current particle system
  72312. */
  72313. removeStartSizeGradient(gradient: number): IParticleSystem;
  72314. private _createRampGradientTexture;
  72315. /**
  72316. * Gets the current list of ramp gradients.
  72317. * You must use addRampGradient and removeRampGradient to udpate this list
  72318. * @returns the list of ramp gradients
  72319. */
  72320. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72321. /**
  72322. * Adds a new ramp gradient used to remap particle colors
  72323. * @param gradient defines the gradient to use (between 0 and 1)
  72324. * @param color defines the color to affect to the specified gradient
  72325. * @returns the current particle system
  72326. */
  72327. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72328. /**
  72329. * Remove a specific ramp gradient
  72330. * @param gradient defines the gradient to remove
  72331. * @returns the current particle system
  72332. */
  72333. removeRampGradient(gradient: number): ParticleSystem;
  72334. /**
  72335. * Adds a new color gradient
  72336. * @param gradient defines the gradient to use (between 0 and 1)
  72337. * @param color1 defines the color to affect to the specified gradient
  72338. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72339. * @returns this particle system
  72340. */
  72341. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72342. /**
  72343. * Remove a specific color gradient
  72344. * @param gradient defines the gradient to remove
  72345. * @returns this particle system
  72346. */
  72347. removeColorGradient(gradient: number): IParticleSystem;
  72348. private _fetchR;
  72349. protected _reset(): void;
  72350. private _resetEffect;
  72351. private _createVertexBuffers;
  72352. private _createIndexBuffer;
  72353. /**
  72354. * Gets the maximum number of particles active at the same time.
  72355. * @returns The max number of active particles.
  72356. */
  72357. getCapacity(): number;
  72358. /**
  72359. * Gets whether there are still active particles in the system.
  72360. * @returns True if it is alive, otherwise false.
  72361. */
  72362. isAlive(): boolean;
  72363. /**
  72364. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72365. * @returns True if it has been started, otherwise false.
  72366. */
  72367. isStarted(): boolean;
  72368. private _prepareSubEmitterInternalArray;
  72369. /**
  72370. * Starts the particle system and begins to emit
  72371. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72372. */
  72373. start(delay?: number): void;
  72374. /**
  72375. * Stops the particle system.
  72376. * @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.
  72377. */
  72378. stop(stopSubEmitters?: boolean): void;
  72379. /**
  72380. * Remove all active particles
  72381. */
  72382. reset(): void;
  72383. /**
  72384. * @hidden (for internal use only)
  72385. */
  72386. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72387. /**
  72388. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72389. * Its lifetime will start back at 0.
  72390. */
  72391. recycleParticle: (particle: Particle) => void;
  72392. private _stopSubEmitters;
  72393. private _createParticle;
  72394. private _removeFromRoot;
  72395. private _emitFromParticle;
  72396. private _update;
  72397. /** @hidden */
  72398. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72399. /** @hidden */
  72400. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72401. /** @hidden */
  72402. private _getEffect;
  72403. /**
  72404. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72405. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72406. */
  72407. animate(preWarmOnly?: boolean): void;
  72408. private _appendParticleVertices;
  72409. /**
  72410. * Rebuilds the particle system.
  72411. */
  72412. rebuild(): void;
  72413. /**
  72414. * Is this system ready to be used/rendered
  72415. * @return true if the system is ready
  72416. */
  72417. isReady(): boolean;
  72418. private _render;
  72419. /**
  72420. * Renders the particle system in its current state.
  72421. * @returns the current number of particles
  72422. */
  72423. render(): number;
  72424. /**
  72425. * Disposes the particle system and free the associated resources
  72426. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72427. */
  72428. dispose(disposeTexture?: boolean): void;
  72429. /**
  72430. * Clones the particle system.
  72431. * @param name The name of the cloned object
  72432. * @param newEmitter The new emitter to use
  72433. * @returns the cloned particle system
  72434. */
  72435. clone(name: string, newEmitter: any): ParticleSystem;
  72436. /**
  72437. * Serializes the particle system to a JSON object.
  72438. * @returns the JSON object
  72439. */
  72440. serialize(): any;
  72441. /** @hidden */
  72442. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72443. /** @hidden */
  72444. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72445. /**
  72446. * Parses a JSON object to create a particle system.
  72447. * @param parsedParticleSystem The JSON object to parse
  72448. * @param scene The scene to create the particle system in
  72449. * @param rootUrl The root url to use to load external dependencies like texture
  72450. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72451. * @returns the Parsed particle system
  72452. */
  72453. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72454. }
  72455. }
  72456. declare module BABYLON {
  72457. /**
  72458. * A particle represents one of the element emitted by a particle system.
  72459. * This is mainly define by its coordinates, direction, velocity and age.
  72460. */
  72461. export class Particle {
  72462. /**
  72463. * The particle system the particle belongs to.
  72464. */
  72465. particleSystem: ParticleSystem;
  72466. private static _Count;
  72467. /**
  72468. * Unique ID of the particle
  72469. */
  72470. id: number;
  72471. /**
  72472. * The world position of the particle in the scene.
  72473. */
  72474. position: Vector3;
  72475. /**
  72476. * The world direction of the particle in the scene.
  72477. */
  72478. direction: Vector3;
  72479. /**
  72480. * The color of the particle.
  72481. */
  72482. color: Color4;
  72483. /**
  72484. * The color change of the particle per step.
  72485. */
  72486. colorStep: Color4;
  72487. /**
  72488. * Defines how long will the life of the particle be.
  72489. */
  72490. lifeTime: number;
  72491. /**
  72492. * The current age of the particle.
  72493. */
  72494. age: number;
  72495. /**
  72496. * The current size of the particle.
  72497. */
  72498. size: number;
  72499. /**
  72500. * The current scale of the particle.
  72501. */
  72502. scale: Vector2;
  72503. /**
  72504. * The current angle of the particle.
  72505. */
  72506. angle: number;
  72507. /**
  72508. * Defines how fast is the angle changing.
  72509. */
  72510. angularSpeed: number;
  72511. /**
  72512. * Defines the cell index used by the particle to be rendered from a sprite.
  72513. */
  72514. cellIndex: number;
  72515. /**
  72516. * The information required to support color remapping
  72517. */
  72518. remapData: Vector4;
  72519. /** @hidden */
  72520. _randomCellOffset?: number;
  72521. /** @hidden */
  72522. _initialDirection: Nullable<Vector3>;
  72523. /** @hidden */
  72524. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72525. /** @hidden */
  72526. _initialStartSpriteCellID: number;
  72527. /** @hidden */
  72528. _initialEndSpriteCellID: number;
  72529. /** @hidden */
  72530. _currentColorGradient: Nullable<ColorGradient>;
  72531. /** @hidden */
  72532. _currentColor1: Color4;
  72533. /** @hidden */
  72534. _currentColor2: Color4;
  72535. /** @hidden */
  72536. _currentSizeGradient: Nullable<FactorGradient>;
  72537. /** @hidden */
  72538. _currentSize1: number;
  72539. /** @hidden */
  72540. _currentSize2: number;
  72541. /** @hidden */
  72542. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72543. /** @hidden */
  72544. _currentAngularSpeed1: number;
  72545. /** @hidden */
  72546. _currentAngularSpeed2: number;
  72547. /** @hidden */
  72548. _currentVelocityGradient: Nullable<FactorGradient>;
  72549. /** @hidden */
  72550. _currentVelocity1: number;
  72551. /** @hidden */
  72552. _currentVelocity2: number;
  72553. /** @hidden */
  72554. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72555. /** @hidden */
  72556. _currentLimitVelocity1: number;
  72557. /** @hidden */
  72558. _currentLimitVelocity2: number;
  72559. /** @hidden */
  72560. _currentDragGradient: Nullable<FactorGradient>;
  72561. /** @hidden */
  72562. _currentDrag1: number;
  72563. /** @hidden */
  72564. _currentDrag2: number;
  72565. /** @hidden */
  72566. _randomNoiseCoordinates1: Vector3;
  72567. /** @hidden */
  72568. _randomNoiseCoordinates2: Vector3;
  72569. /**
  72570. * Creates a new instance Particle
  72571. * @param particleSystem the particle system the particle belongs to
  72572. */
  72573. constructor(
  72574. /**
  72575. * The particle system the particle belongs to.
  72576. */
  72577. particleSystem: ParticleSystem);
  72578. private updateCellInfoFromSystem;
  72579. /**
  72580. * Defines how the sprite cell index is updated for the particle
  72581. */
  72582. updateCellIndex(): void;
  72583. /** @hidden */
  72584. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72585. /** @hidden */
  72586. _inheritParticleInfoToSubEmitters(): void;
  72587. /** @hidden */
  72588. _reset(): void;
  72589. /**
  72590. * Copy the properties of particle to another one.
  72591. * @param other the particle to copy the information to.
  72592. */
  72593. copyTo(other: Particle): void;
  72594. }
  72595. }
  72596. declare module BABYLON {
  72597. /**
  72598. * Particle emitter represents a volume emitting particles.
  72599. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72600. */
  72601. export interface IParticleEmitterType {
  72602. /**
  72603. * Called by the particle System when the direction is computed for the created particle.
  72604. * @param worldMatrix is the world matrix of the particle system
  72605. * @param directionToUpdate is the direction vector to update with the result
  72606. * @param particle is the particle we are computed the direction for
  72607. */
  72608. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72609. /**
  72610. * Called by the particle System when the position is computed for the created particle.
  72611. * @param worldMatrix is the world matrix of the particle system
  72612. * @param positionToUpdate is the position vector to update with the result
  72613. * @param particle is the particle we are computed the position for
  72614. */
  72615. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72616. /**
  72617. * Clones the current emitter and returns a copy of it
  72618. * @returns the new emitter
  72619. */
  72620. clone(): IParticleEmitterType;
  72621. /**
  72622. * Called by the GPUParticleSystem to setup the update shader
  72623. * @param effect defines the update shader
  72624. */
  72625. applyToShader(effect: Effect): void;
  72626. /**
  72627. * Returns a string to use to update the GPU particles update shader
  72628. * @returns the effect defines string
  72629. */
  72630. getEffectDefines(): string;
  72631. /**
  72632. * Returns a string representing the class name
  72633. * @returns a string containing the class name
  72634. */
  72635. getClassName(): string;
  72636. /**
  72637. * Serializes the particle system to a JSON object.
  72638. * @returns the JSON object
  72639. */
  72640. serialize(): any;
  72641. /**
  72642. * Parse properties from a JSON object
  72643. * @param serializationObject defines the JSON object
  72644. */
  72645. parse(serializationObject: any): void;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /**
  72650. * Particle emitter emitting particles from the inside of a box.
  72651. * It emits the particles randomly between 2 given directions.
  72652. */
  72653. export class BoxParticleEmitter implements IParticleEmitterType {
  72654. /**
  72655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72656. */
  72657. direction1: Vector3;
  72658. /**
  72659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72660. */
  72661. direction2: Vector3;
  72662. /**
  72663. * 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.
  72664. */
  72665. minEmitBox: Vector3;
  72666. /**
  72667. * 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.
  72668. */
  72669. maxEmitBox: Vector3;
  72670. /**
  72671. * Creates a new instance BoxParticleEmitter
  72672. */
  72673. constructor();
  72674. /**
  72675. * Called by the particle System when the direction is computed for the created particle.
  72676. * @param worldMatrix is the world matrix of the particle system
  72677. * @param directionToUpdate is the direction vector to update with the result
  72678. * @param particle is the particle we are computed the direction for
  72679. */
  72680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72681. /**
  72682. * Called by the particle System when the position is computed for the created particle.
  72683. * @param worldMatrix is the world matrix of the particle system
  72684. * @param positionToUpdate is the position vector to update with the result
  72685. * @param particle is the particle we are computed the position for
  72686. */
  72687. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72688. /**
  72689. * Clones the current emitter and returns a copy of it
  72690. * @returns the new emitter
  72691. */
  72692. clone(): BoxParticleEmitter;
  72693. /**
  72694. * Called by the GPUParticleSystem to setup the update shader
  72695. * @param effect defines the update shader
  72696. */
  72697. applyToShader(effect: Effect): void;
  72698. /**
  72699. * Returns a string to use to update the GPU particles update shader
  72700. * @returns a string containng the defines string
  72701. */
  72702. getEffectDefines(): string;
  72703. /**
  72704. * Returns the string "BoxParticleEmitter"
  72705. * @returns a string containing the class name
  72706. */
  72707. getClassName(): string;
  72708. /**
  72709. * Serializes the particle system to a JSON object.
  72710. * @returns the JSON object
  72711. */
  72712. serialize(): any;
  72713. /**
  72714. * Parse properties from a JSON object
  72715. * @param serializationObject defines the JSON object
  72716. */
  72717. parse(serializationObject: any): void;
  72718. }
  72719. }
  72720. declare module BABYLON {
  72721. /**
  72722. * Particle emitter emitting particles from the inside of a cone.
  72723. * It emits the particles alongside the cone volume from the base to the particle.
  72724. * The emission direction might be randomized.
  72725. */
  72726. export class ConeParticleEmitter implements IParticleEmitterType {
  72727. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72728. directionRandomizer: number;
  72729. private _radius;
  72730. private _angle;
  72731. private _height;
  72732. /**
  72733. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72734. */
  72735. radiusRange: number;
  72736. /**
  72737. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72738. */
  72739. heightRange: number;
  72740. /**
  72741. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72742. */
  72743. emitFromSpawnPointOnly: boolean;
  72744. /**
  72745. * Gets or sets the radius of the emission cone
  72746. */
  72747. radius: number;
  72748. /**
  72749. * Gets or sets the angle of the emission cone
  72750. */
  72751. angle: number;
  72752. private _buildHeight;
  72753. /**
  72754. * Creates a new instance ConeParticleEmitter
  72755. * @param radius the radius of the emission cone (1 by default)
  72756. * @param angle the cone base angle (PI by default)
  72757. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72758. */
  72759. constructor(radius?: number, angle?: number,
  72760. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72761. directionRandomizer?: number);
  72762. /**
  72763. * Called by the particle System when the direction is computed for the created particle.
  72764. * @param worldMatrix is the world matrix of the particle system
  72765. * @param directionToUpdate is the direction vector to update with the result
  72766. * @param particle is the particle we are computed the direction for
  72767. */
  72768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72769. /**
  72770. * Called by the particle System when the position is computed for the created particle.
  72771. * @param worldMatrix is the world matrix of the particle system
  72772. * @param positionToUpdate is the position vector to update with the result
  72773. * @param particle is the particle we are computed the position for
  72774. */
  72775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72776. /**
  72777. * Clones the current emitter and returns a copy of it
  72778. * @returns the new emitter
  72779. */
  72780. clone(): ConeParticleEmitter;
  72781. /**
  72782. * Called by the GPUParticleSystem to setup the update shader
  72783. * @param effect defines the update shader
  72784. */
  72785. applyToShader(effect: Effect): void;
  72786. /**
  72787. * Returns a string to use to update the GPU particles update shader
  72788. * @returns a string containng the defines string
  72789. */
  72790. getEffectDefines(): string;
  72791. /**
  72792. * Returns the string "ConeParticleEmitter"
  72793. * @returns a string containing the class name
  72794. */
  72795. getClassName(): string;
  72796. /**
  72797. * Serializes the particle system to a JSON object.
  72798. * @returns the JSON object
  72799. */
  72800. serialize(): any;
  72801. /**
  72802. * Parse properties from a JSON object
  72803. * @param serializationObject defines the JSON object
  72804. */
  72805. parse(serializationObject: any): void;
  72806. }
  72807. }
  72808. declare module BABYLON {
  72809. /**
  72810. * Particle emitter emitting particles from the inside of a cylinder.
  72811. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72812. */
  72813. export class CylinderParticleEmitter implements IParticleEmitterType {
  72814. /**
  72815. * The radius of the emission cylinder.
  72816. */
  72817. radius: number;
  72818. /**
  72819. * The height of the emission cylinder.
  72820. */
  72821. height: number;
  72822. /**
  72823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72824. */
  72825. radiusRange: number;
  72826. /**
  72827. * How much to randomize the particle direction [0-1].
  72828. */
  72829. directionRandomizer: number;
  72830. /**
  72831. * Creates a new instance CylinderParticleEmitter
  72832. * @param radius the radius of the emission cylinder (1 by default)
  72833. * @param height the height of the emission cylinder (1 by default)
  72834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72835. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72836. */
  72837. constructor(
  72838. /**
  72839. * The radius of the emission cylinder.
  72840. */
  72841. radius?: number,
  72842. /**
  72843. * The height of the emission cylinder.
  72844. */
  72845. height?: number,
  72846. /**
  72847. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72848. */
  72849. radiusRange?: number,
  72850. /**
  72851. * How much to randomize the particle direction [0-1].
  72852. */
  72853. directionRandomizer?: number);
  72854. /**
  72855. * Called by the particle System when the direction is computed for the created particle.
  72856. * @param worldMatrix is the world matrix of the particle system
  72857. * @param directionToUpdate is the direction vector to update with the result
  72858. * @param particle is the particle we are computed the direction for
  72859. */
  72860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72861. /**
  72862. * Called by the particle System when the position is computed for the created particle.
  72863. * @param worldMatrix is the world matrix of the particle system
  72864. * @param positionToUpdate is the position vector to update with the result
  72865. * @param particle is the particle we are computed the position for
  72866. */
  72867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72868. /**
  72869. * Clones the current emitter and returns a copy of it
  72870. * @returns the new emitter
  72871. */
  72872. clone(): CylinderParticleEmitter;
  72873. /**
  72874. * Called by the GPUParticleSystem to setup the update shader
  72875. * @param effect defines the update shader
  72876. */
  72877. applyToShader(effect: Effect): void;
  72878. /**
  72879. * Returns a string to use to update the GPU particles update shader
  72880. * @returns a string containng the defines string
  72881. */
  72882. getEffectDefines(): string;
  72883. /**
  72884. * Returns the string "CylinderParticleEmitter"
  72885. * @returns a string containing the class name
  72886. */
  72887. getClassName(): string;
  72888. /**
  72889. * Serializes the particle system to a JSON object.
  72890. * @returns the JSON object
  72891. */
  72892. serialize(): any;
  72893. /**
  72894. * Parse properties from a JSON object
  72895. * @param serializationObject defines the JSON object
  72896. */
  72897. parse(serializationObject: any): void;
  72898. }
  72899. /**
  72900. * Particle emitter emitting particles from the inside of a cylinder.
  72901. * It emits the particles randomly between two vectors.
  72902. */
  72903. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72904. /**
  72905. * The min limit of the emission direction.
  72906. */
  72907. direction1: Vector3;
  72908. /**
  72909. * The max limit of the emission direction.
  72910. */
  72911. direction2: Vector3;
  72912. /**
  72913. * Creates a new instance CylinderDirectedParticleEmitter
  72914. * @param radius the radius of the emission cylinder (1 by default)
  72915. * @param height the height of the emission cylinder (1 by default)
  72916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72917. * @param direction1 the min limit of the emission direction (up vector by default)
  72918. * @param direction2 the max limit of the emission direction (up vector by default)
  72919. */
  72920. constructor(radius?: number, height?: number, radiusRange?: number,
  72921. /**
  72922. * The min limit of the emission direction.
  72923. */
  72924. direction1?: Vector3,
  72925. /**
  72926. * The max limit of the emission direction.
  72927. */
  72928. direction2?: Vector3);
  72929. /**
  72930. * Called by the particle System when the direction is computed for the created particle.
  72931. * @param worldMatrix is the world matrix of the particle system
  72932. * @param directionToUpdate is the direction vector to update with the result
  72933. * @param particle is the particle we are computed the direction for
  72934. */
  72935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72936. /**
  72937. * Clones the current emitter and returns a copy of it
  72938. * @returns the new emitter
  72939. */
  72940. clone(): CylinderDirectedParticleEmitter;
  72941. /**
  72942. * Called by the GPUParticleSystem to setup the update shader
  72943. * @param effect defines the update shader
  72944. */
  72945. applyToShader(effect: Effect): void;
  72946. /**
  72947. * Returns a string to use to update the GPU particles update shader
  72948. * @returns a string containng the defines string
  72949. */
  72950. getEffectDefines(): string;
  72951. /**
  72952. * Returns the string "CylinderDirectedParticleEmitter"
  72953. * @returns a string containing the class name
  72954. */
  72955. getClassName(): string;
  72956. /**
  72957. * Serializes the particle system to a JSON object.
  72958. * @returns the JSON object
  72959. */
  72960. serialize(): any;
  72961. /**
  72962. * Parse properties from a JSON object
  72963. * @param serializationObject defines the JSON object
  72964. */
  72965. parse(serializationObject: any): void;
  72966. }
  72967. }
  72968. declare module BABYLON {
  72969. /**
  72970. * Particle emitter emitting particles from the inside of a hemisphere.
  72971. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72972. */
  72973. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72974. /**
  72975. * The radius of the emission hemisphere.
  72976. */
  72977. radius: number;
  72978. /**
  72979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72980. */
  72981. radiusRange: number;
  72982. /**
  72983. * How much to randomize the particle direction [0-1].
  72984. */
  72985. directionRandomizer: number;
  72986. /**
  72987. * Creates a new instance HemisphericParticleEmitter
  72988. * @param radius the radius of the emission hemisphere (1 by default)
  72989. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72990. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72991. */
  72992. constructor(
  72993. /**
  72994. * The radius of the emission hemisphere.
  72995. */
  72996. radius?: number,
  72997. /**
  72998. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72999. */
  73000. radiusRange?: number,
  73001. /**
  73002. * How much to randomize the particle direction [0-1].
  73003. */
  73004. directionRandomizer?: number);
  73005. /**
  73006. * Called by the particle System when the direction is computed for the created particle.
  73007. * @param worldMatrix is the world matrix of the particle system
  73008. * @param directionToUpdate is the direction vector to update with the result
  73009. * @param particle is the particle we are computed the direction for
  73010. */
  73011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73012. /**
  73013. * Called by the particle System when the position is computed for the created particle.
  73014. * @param worldMatrix is the world matrix of the particle system
  73015. * @param positionToUpdate is the position vector to update with the result
  73016. * @param particle is the particle we are computed the position for
  73017. */
  73018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73019. /**
  73020. * Clones the current emitter and returns a copy of it
  73021. * @returns the new emitter
  73022. */
  73023. clone(): HemisphericParticleEmitter;
  73024. /**
  73025. * Called by the GPUParticleSystem to setup the update shader
  73026. * @param effect defines the update shader
  73027. */
  73028. applyToShader(effect: Effect): void;
  73029. /**
  73030. * Returns a string to use to update the GPU particles update shader
  73031. * @returns a string containng the defines string
  73032. */
  73033. getEffectDefines(): string;
  73034. /**
  73035. * Returns the string "HemisphericParticleEmitter"
  73036. * @returns a string containing the class name
  73037. */
  73038. getClassName(): string;
  73039. /**
  73040. * Serializes the particle system to a JSON object.
  73041. * @returns the JSON object
  73042. */
  73043. serialize(): any;
  73044. /**
  73045. * Parse properties from a JSON object
  73046. * @param serializationObject defines the JSON object
  73047. */
  73048. parse(serializationObject: any): void;
  73049. }
  73050. }
  73051. declare module BABYLON {
  73052. /**
  73053. * Particle emitter emitting particles from a point.
  73054. * It emits the particles randomly between 2 given directions.
  73055. */
  73056. export class PointParticleEmitter implements IParticleEmitterType {
  73057. /**
  73058. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73059. */
  73060. direction1: Vector3;
  73061. /**
  73062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73063. */
  73064. direction2: Vector3;
  73065. /**
  73066. * Creates a new instance PointParticleEmitter
  73067. */
  73068. constructor();
  73069. /**
  73070. * Called by the particle System when the direction is computed for the created particle.
  73071. * @param worldMatrix is the world matrix of the particle system
  73072. * @param directionToUpdate is the direction vector to update with the result
  73073. * @param particle is the particle we are computed the direction for
  73074. */
  73075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73076. /**
  73077. * Called by the particle System when the position is computed for the created particle.
  73078. * @param worldMatrix is the world matrix of the particle system
  73079. * @param positionToUpdate is the position vector to update with the result
  73080. * @param particle is the particle we are computed the position for
  73081. */
  73082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73083. /**
  73084. * Clones the current emitter and returns a copy of it
  73085. * @returns the new emitter
  73086. */
  73087. clone(): PointParticleEmitter;
  73088. /**
  73089. * Called by the GPUParticleSystem to setup the update shader
  73090. * @param effect defines the update shader
  73091. */
  73092. applyToShader(effect: Effect): void;
  73093. /**
  73094. * Returns a string to use to update the GPU particles update shader
  73095. * @returns a string containng the defines string
  73096. */
  73097. getEffectDefines(): string;
  73098. /**
  73099. * Returns the string "PointParticleEmitter"
  73100. * @returns a string containing the class name
  73101. */
  73102. getClassName(): string;
  73103. /**
  73104. * Serializes the particle system to a JSON object.
  73105. * @returns the JSON object
  73106. */
  73107. serialize(): any;
  73108. /**
  73109. * Parse properties from a JSON object
  73110. * @param serializationObject defines the JSON object
  73111. */
  73112. parse(serializationObject: any): void;
  73113. }
  73114. }
  73115. declare module BABYLON {
  73116. /**
  73117. * Particle emitter emitting particles from the inside of a sphere.
  73118. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73119. */
  73120. export class SphereParticleEmitter implements IParticleEmitterType {
  73121. /**
  73122. * The radius of the emission sphere.
  73123. */
  73124. radius: number;
  73125. /**
  73126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73127. */
  73128. radiusRange: number;
  73129. /**
  73130. * How much to randomize the particle direction [0-1].
  73131. */
  73132. directionRandomizer: number;
  73133. /**
  73134. * Creates a new instance SphereParticleEmitter
  73135. * @param radius the radius of the emission sphere (1 by default)
  73136. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73138. */
  73139. constructor(
  73140. /**
  73141. * The radius of the emission sphere.
  73142. */
  73143. radius?: number,
  73144. /**
  73145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73146. */
  73147. radiusRange?: number,
  73148. /**
  73149. * How much to randomize the particle direction [0-1].
  73150. */
  73151. directionRandomizer?: number);
  73152. /**
  73153. * Called by the particle System when the direction is computed for the created particle.
  73154. * @param worldMatrix is the world matrix of the particle system
  73155. * @param directionToUpdate is the direction vector to update with the result
  73156. * @param particle is the particle we are computed the direction for
  73157. */
  73158. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73159. /**
  73160. * Called by the particle System when the position is computed for the created particle.
  73161. * @param worldMatrix is the world matrix of the particle system
  73162. * @param positionToUpdate is the position vector to update with the result
  73163. * @param particle is the particle we are computed the position for
  73164. */
  73165. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73166. /**
  73167. * Clones the current emitter and returns a copy of it
  73168. * @returns the new emitter
  73169. */
  73170. clone(): SphereParticleEmitter;
  73171. /**
  73172. * Called by the GPUParticleSystem to setup the update shader
  73173. * @param effect defines the update shader
  73174. */
  73175. applyToShader(effect: Effect): void;
  73176. /**
  73177. * Returns a string to use to update the GPU particles update shader
  73178. * @returns a string containng the defines string
  73179. */
  73180. getEffectDefines(): string;
  73181. /**
  73182. * Returns the string "SphereParticleEmitter"
  73183. * @returns a string containing the class name
  73184. */
  73185. getClassName(): string;
  73186. /**
  73187. * Serializes the particle system to a JSON object.
  73188. * @returns the JSON object
  73189. */
  73190. serialize(): any;
  73191. /**
  73192. * Parse properties from a JSON object
  73193. * @param serializationObject defines the JSON object
  73194. */
  73195. parse(serializationObject: any): void;
  73196. }
  73197. /**
  73198. * Particle emitter emitting particles from the inside of a sphere.
  73199. * It emits the particles randomly between two vectors.
  73200. */
  73201. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73202. /**
  73203. * The min limit of the emission direction.
  73204. */
  73205. direction1: Vector3;
  73206. /**
  73207. * The max limit of the emission direction.
  73208. */
  73209. direction2: Vector3;
  73210. /**
  73211. * Creates a new instance SphereDirectedParticleEmitter
  73212. * @param radius the radius of the emission sphere (1 by default)
  73213. * @param direction1 the min limit of the emission direction (up vector by default)
  73214. * @param direction2 the max limit of the emission direction (up vector by default)
  73215. */
  73216. constructor(radius?: number,
  73217. /**
  73218. * The min limit of the emission direction.
  73219. */
  73220. direction1?: Vector3,
  73221. /**
  73222. * The max limit of the emission direction.
  73223. */
  73224. direction2?: Vector3);
  73225. /**
  73226. * Called by the particle System when the direction is computed for the created particle.
  73227. * @param worldMatrix is the world matrix of the particle system
  73228. * @param directionToUpdate is the direction vector to update with the result
  73229. * @param particle is the particle we are computed the direction for
  73230. */
  73231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73232. /**
  73233. * Clones the current emitter and returns a copy of it
  73234. * @returns the new emitter
  73235. */
  73236. clone(): SphereDirectedParticleEmitter;
  73237. /**
  73238. * Called by the GPUParticleSystem to setup the update shader
  73239. * @param effect defines the update shader
  73240. */
  73241. applyToShader(effect: Effect): void;
  73242. /**
  73243. * Returns a string to use to update the GPU particles update shader
  73244. * @returns a string containng the defines string
  73245. */
  73246. getEffectDefines(): string;
  73247. /**
  73248. * Returns the string "SphereDirectedParticleEmitter"
  73249. * @returns a string containing the class name
  73250. */
  73251. getClassName(): string;
  73252. /**
  73253. * Serializes the particle system to a JSON object.
  73254. * @returns the JSON object
  73255. */
  73256. serialize(): any;
  73257. /**
  73258. * Parse properties from a JSON object
  73259. * @param serializationObject defines the JSON object
  73260. */
  73261. parse(serializationObject: any): void;
  73262. }
  73263. }
  73264. declare module BABYLON {
  73265. /**
  73266. * Interface representing a particle system in Babylon.js.
  73267. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73268. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73269. */
  73270. export interface IParticleSystem {
  73271. /**
  73272. * List of animations used by the particle system.
  73273. */
  73274. animations: Animation[];
  73275. /**
  73276. * The id of the Particle system.
  73277. */
  73278. id: string;
  73279. /**
  73280. * The name of the Particle system.
  73281. */
  73282. name: string;
  73283. /**
  73284. * The emitter represents the Mesh or position we are attaching the particle system to.
  73285. */
  73286. emitter: Nullable<AbstractMesh | Vector3>;
  73287. /**
  73288. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73289. */
  73290. isBillboardBased: boolean;
  73291. /**
  73292. * The rendering group used by the Particle system to chose when to render.
  73293. */
  73294. renderingGroupId: number;
  73295. /**
  73296. * The layer mask we are rendering the particles through.
  73297. */
  73298. layerMask: number;
  73299. /**
  73300. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73301. */
  73302. updateSpeed: number;
  73303. /**
  73304. * The amount of time the particle system is running (depends of the overall update speed).
  73305. */
  73306. targetStopDuration: number;
  73307. /**
  73308. * The texture used to render each particle. (this can be a spritesheet)
  73309. */
  73310. particleTexture: Nullable<Texture>;
  73311. /**
  73312. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73313. */
  73314. blendMode: number;
  73315. /**
  73316. * Minimum life time of emitting particles.
  73317. */
  73318. minLifeTime: number;
  73319. /**
  73320. * Maximum life time of emitting particles.
  73321. */
  73322. maxLifeTime: number;
  73323. /**
  73324. * Minimum Size of emitting particles.
  73325. */
  73326. minSize: number;
  73327. /**
  73328. * Maximum Size of emitting particles.
  73329. */
  73330. maxSize: number;
  73331. /**
  73332. * Minimum scale of emitting particles on X axis.
  73333. */
  73334. minScaleX: number;
  73335. /**
  73336. * Maximum scale of emitting particles on X axis.
  73337. */
  73338. maxScaleX: number;
  73339. /**
  73340. * Minimum scale of emitting particles on Y axis.
  73341. */
  73342. minScaleY: number;
  73343. /**
  73344. * Maximum scale of emitting particles on Y axis.
  73345. */
  73346. maxScaleY: number;
  73347. /**
  73348. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73349. */
  73350. color1: Color4;
  73351. /**
  73352. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73353. */
  73354. color2: Color4;
  73355. /**
  73356. * Color the particle will have at the end of its lifetime.
  73357. */
  73358. colorDead: Color4;
  73359. /**
  73360. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73361. */
  73362. emitRate: number;
  73363. /**
  73364. * You can use gravity if you want to give an orientation to your particles.
  73365. */
  73366. gravity: Vector3;
  73367. /**
  73368. * Minimum power of emitting particles.
  73369. */
  73370. minEmitPower: number;
  73371. /**
  73372. * Maximum power of emitting particles.
  73373. */
  73374. maxEmitPower: number;
  73375. /**
  73376. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73377. */
  73378. minAngularSpeed: number;
  73379. /**
  73380. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73381. */
  73382. maxAngularSpeed: number;
  73383. /**
  73384. * Gets or sets the minimal initial rotation in radians.
  73385. */
  73386. minInitialRotation: number;
  73387. /**
  73388. * Gets or sets the maximal initial rotation in radians.
  73389. */
  73390. maxInitialRotation: number;
  73391. /**
  73392. * The particle emitter type defines the emitter used by the particle system.
  73393. * It can be for example box, sphere, or cone...
  73394. */
  73395. particleEmitterType: Nullable<IParticleEmitterType>;
  73396. /**
  73397. * Defines the delay in milliseconds before starting the system (0 by default)
  73398. */
  73399. startDelay: number;
  73400. /**
  73401. * 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
  73402. */
  73403. preWarmCycles: number;
  73404. /**
  73405. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73406. */
  73407. preWarmStepOffset: number;
  73408. /**
  73409. * 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)
  73410. */
  73411. spriteCellChangeSpeed: number;
  73412. /**
  73413. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73414. */
  73415. startSpriteCellID: number;
  73416. /**
  73417. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73418. */
  73419. endSpriteCellID: number;
  73420. /**
  73421. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73422. */
  73423. spriteCellWidth: number;
  73424. /**
  73425. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73426. */
  73427. spriteCellHeight: number;
  73428. /**
  73429. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73430. */
  73431. spriteRandomStartCell: boolean;
  73432. /**
  73433. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73434. */
  73435. isAnimationSheetEnabled: boolean;
  73436. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73437. translationPivot: Vector2;
  73438. /**
  73439. * Gets or sets a texture used to add random noise to particle positions
  73440. */
  73441. noiseTexture: Nullable<BaseTexture>;
  73442. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73443. noiseStrength: Vector3;
  73444. /**
  73445. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73446. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73447. */
  73448. billboardMode: number;
  73449. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73450. limitVelocityDamping: number;
  73451. /**
  73452. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73453. */
  73454. beginAnimationOnStart: boolean;
  73455. /**
  73456. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73457. */
  73458. beginAnimationFrom: number;
  73459. /**
  73460. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73461. */
  73462. beginAnimationTo: number;
  73463. /**
  73464. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73465. */
  73466. beginAnimationLoop: boolean;
  73467. /**
  73468. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73469. */
  73470. disposeOnStop: boolean;
  73471. /**
  73472. * Gets the maximum number of particles active at the same time.
  73473. * @returns The max number of active particles.
  73474. */
  73475. getCapacity(): number;
  73476. /**
  73477. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73478. * @returns True if it has been started, otherwise false.
  73479. */
  73480. isStarted(): boolean;
  73481. /**
  73482. * Animates the particle system for this frame.
  73483. */
  73484. animate(): void;
  73485. /**
  73486. * Renders the particle system in its current state.
  73487. * @returns the current number of particles
  73488. */
  73489. render(): number;
  73490. /**
  73491. * Dispose the particle system and frees its associated resources.
  73492. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73493. */
  73494. dispose(disposeTexture?: boolean): void;
  73495. /**
  73496. * Clones the particle system.
  73497. * @param name The name of the cloned object
  73498. * @param newEmitter The new emitter to use
  73499. * @returns the cloned particle system
  73500. */
  73501. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73502. /**
  73503. * Serializes the particle system to a JSON object.
  73504. * @returns the JSON object
  73505. */
  73506. serialize(): any;
  73507. /**
  73508. * Rebuild the particle system
  73509. */
  73510. rebuild(): void;
  73511. /**
  73512. * Starts the particle system and begins to emit
  73513. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73514. */
  73515. start(delay?: number): void;
  73516. /**
  73517. * Stops the particle system.
  73518. */
  73519. stop(): void;
  73520. /**
  73521. * Remove all active particles
  73522. */
  73523. reset(): void;
  73524. /**
  73525. * Is this system ready to be used/rendered
  73526. * @return true if the system is ready
  73527. */
  73528. isReady(): boolean;
  73529. /**
  73530. * Adds a new color gradient
  73531. * @param gradient defines the gradient to use (between 0 and 1)
  73532. * @param color1 defines the color to affect to the specified gradient
  73533. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73534. * @returns the current particle system
  73535. */
  73536. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73537. /**
  73538. * Remove a specific color gradient
  73539. * @param gradient defines the gradient to remove
  73540. * @returns the current particle system
  73541. */
  73542. removeColorGradient(gradient: number): IParticleSystem;
  73543. /**
  73544. * Adds a new size gradient
  73545. * @param gradient defines the gradient to use (between 0 and 1)
  73546. * @param factor defines the size factor to affect to the specified gradient
  73547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73548. * @returns the current particle system
  73549. */
  73550. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73551. /**
  73552. * Remove a specific size gradient
  73553. * @param gradient defines the gradient to remove
  73554. * @returns the current particle system
  73555. */
  73556. removeSizeGradient(gradient: number): IParticleSystem;
  73557. /**
  73558. * Gets the current list of color gradients.
  73559. * You must use addColorGradient and removeColorGradient to udpate this list
  73560. * @returns the list of color gradients
  73561. */
  73562. getColorGradients(): Nullable<Array<ColorGradient>>;
  73563. /**
  73564. * Gets the current list of size gradients.
  73565. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73566. * @returns the list of size gradients
  73567. */
  73568. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73569. /**
  73570. * Gets the current list of angular speed gradients.
  73571. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73572. * @returns the list of angular speed gradients
  73573. */
  73574. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73575. /**
  73576. * Adds a new angular speed gradient
  73577. * @param gradient defines the gradient to use (between 0 and 1)
  73578. * @param factor defines the angular speed to affect to the specified gradient
  73579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73580. * @returns the current particle system
  73581. */
  73582. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73583. /**
  73584. * Remove a specific angular speed gradient
  73585. * @param gradient defines the gradient to remove
  73586. * @returns the current particle system
  73587. */
  73588. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73589. /**
  73590. * Gets the current list of velocity gradients.
  73591. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73592. * @returns the list of velocity gradients
  73593. */
  73594. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73595. /**
  73596. * Adds a new velocity gradient
  73597. * @param gradient defines the gradient to use (between 0 and 1)
  73598. * @param factor defines the velocity to affect to the specified gradient
  73599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73600. * @returns the current particle system
  73601. */
  73602. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73603. /**
  73604. * Remove a specific velocity gradient
  73605. * @param gradient defines the gradient to remove
  73606. * @returns the current particle system
  73607. */
  73608. removeVelocityGradient(gradient: number): IParticleSystem;
  73609. /**
  73610. * Gets the current list of limit velocity gradients.
  73611. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73612. * @returns the list of limit velocity gradients
  73613. */
  73614. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73615. /**
  73616. * Adds a new limit velocity gradient
  73617. * @param gradient defines the gradient to use (between 0 and 1)
  73618. * @param factor defines the limit velocity to affect to the specified gradient
  73619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73620. * @returns the current particle system
  73621. */
  73622. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73623. /**
  73624. * Remove a specific limit velocity gradient
  73625. * @param gradient defines the gradient to remove
  73626. * @returns the current particle system
  73627. */
  73628. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73629. /**
  73630. * Adds a new drag gradient
  73631. * @param gradient defines the gradient to use (between 0 and 1)
  73632. * @param factor defines the drag to affect to the specified gradient
  73633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73634. * @returns the current particle system
  73635. */
  73636. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73637. /**
  73638. * Remove a specific drag gradient
  73639. * @param gradient defines the gradient to remove
  73640. * @returns the current particle system
  73641. */
  73642. removeDragGradient(gradient: number): IParticleSystem;
  73643. /**
  73644. * Gets the current list of drag gradients.
  73645. * You must use addDragGradient and removeDragGradient to udpate this list
  73646. * @returns the list of drag gradients
  73647. */
  73648. getDragGradients(): Nullable<Array<FactorGradient>>;
  73649. /**
  73650. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73651. * @param gradient defines the gradient to use (between 0 and 1)
  73652. * @param factor defines the emit rate to affect to the specified gradient
  73653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73654. * @returns the current particle system
  73655. */
  73656. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73657. /**
  73658. * Remove a specific emit rate gradient
  73659. * @param gradient defines the gradient to remove
  73660. * @returns the current particle system
  73661. */
  73662. removeEmitRateGradient(gradient: number): IParticleSystem;
  73663. /**
  73664. * Gets the current list of emit rate gradients.
  73665. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73666. * @returns the list of emit rate gradients
  73667. */
  73668. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73669. /**
  73670. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73671. * @param gradient defines the gradient to use (between 0 and 1)
  73672. * @param factor defines the start size to affect to the specified gradient
  73673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73674. * @returns the current particle system
  73675. */
  73676. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73677. /**
  73678. * Remove a specific start size gradient
  73679. * @param gradient defines the gradient to remove
  73680. * @returns the current particle system
  73681. */
  73682. removeStartSizeGradient(gradient: number): IParticleSystem;
  73683. /**
  73684. * Gets the current list of start size gradients.
  73685. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73686. * @returns the list of start size gradients
  73687. */
  73688. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73689. /**
  73690. * Adds a new life time gradient
  73691. * @param gradient defines the gradient to use (between 0 and 1)
  73692. * @param factor defines the life time factor to affect to the specified gradient
  73693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73694. * @returns the current particle system
  73695. */
  73696. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73697. /**
  73698. * Remove a specific life time gradient
  73699. * @param gradient defines the gradient to remove
  73700. * @returns the current particle system
  73701. */
  73702. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73703. /**
  73704. * Gets the current list of life time gradients.
  73705. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73706. * @returns the list of life time gradients
  73707. */
  73708. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73709. /**
  73710. * Gets the current list of color gradients.
  73711. * You must use addColorGradient and removeColorGradient to udpate this list
  73712. * @returns the list of color gradients
  73713. */
  73714. getColorGradients(): Nullable<Array<ColorGradient>>;
  73715. /**
  73716. * Adds a new ramp gradient used to remap particle colors
  73717. * @param gradient defines the gradient to use (between 0 and 1)
  73718. * @param color defines the color to affect to the specified gradient
  73719. * @returns the current particle system
  73720. */
  73721. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73722. /**
  73723. * Gets the current list of ramp gradients.
  73724. * You must use addRampGradient and removeRampGradient to udpate this list
  73725. * @returns the list of ramp gradients
  73726. */
  73727. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73728. /** Gets or sets a boolean indicating that ramp gradients must be used
  73729. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73730. */
  73731. useRampGradients: boolean;
  73732. /**
  73733. * Adds a new color remap gradient
  73734. * @param gradient defines the gradient to use (between 0 and 1)
  73735. * @param min defines the color remap minimal range
  73736. * @param max defines the color remap maximal range
  73737. * @returns the current particle system
  73738. */
  73739. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73740. /**
  73741. * Gets the current list of color remap gradients.
  73742. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73743. * @returns the list of color remap gradients
  73744. */
  73745. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73746. /**
  73747. * Adds a new alpha remap gradient
  73748. * @param gradient defines the gradient to use (between 0 and 1)
  73749. * @param min defines the alpha remap minimal range
  73750. * @param max defines the alpha remap maximal range
  73751. * @returns the current particle system
  73752. */
  73753. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73754. /**
  73755. * Gets the current list of alpha remap gradients.
  73756. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73757. * @returns the list of alpha remap gradients
  73758. */
  73759. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73760. /**
  73761. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73764. * @returns the emitter
  73765. */
  73766. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73767. /**
  73768. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73769. * @param radius The radius of the hemisphere to emit from
  73770. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73771. * @returns the emitter
  73772. */
  73773. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73774. /**
  73775. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73776. * @param radius The radius of the sphere to emit from
  73777. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73778. * @returns the emitter
  73779. */
  73780. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73781. /**
  73782. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73783. * @param radius The radius of the sphere to emit from
  73784. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73785. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73786. * @returns the emitter
  73787. */
  73788. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73789. /**
  73790. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73791. * @param radius The radius of the emission cylinder
  73792. * @param height The height of the emission cylinder
  73793. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73794. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73795. * @returns the emitter
  73796. */
  73797. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73798. /**
  73799. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73800. * @param radius The radius of the cylinder to emit from
  73801. * @param height The height of the emission cylinder
  73802. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73803. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73804. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73805. * @returns the emitter
  73806. */
  73807. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73808. /**
  73809. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73810. * @param radius The radius of the cone to emit from
  73811. * @param angle The base angle of the cone
  73812. * @returns the emitter
  73813. */
  73814. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73815. /**
  73816. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73817. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73818. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73819. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73820. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73821. * @returns the emitter
  73822. */
  73823. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73824. /**
  73825. * Get hosting scene
  73826. * @returns the scene
  73827. */
  73828. getScene(): Scene;
  73829. }
  73830. }
  73831. declare module BABYLON {
  73832. /**
  73833. * Creates an instance based on a source mesh.
  73834. */
  73835. export class InstancedMesh extends AbstractMesh {
  73836. private _sourceMesh;
  73837. private _currentLOD;
  73838. /** @hidden */
  73839. _indexInSourceMeshInstanceArray: number;
  73840. constructor(name: string, source: Mesh);
  73841. /**
  73842. * Returns the string "InstancedMesh".
  73843. */
  73844. getClassName(): string;
  73845. /**
  73846. * If the source mesh receives shadows
  73847. */
  73848. readonly receiveShadows: boolean;
  73849. /**
  73850. * The material of the source mesh
  73851. */
  73852. readonly material: Nullable<Material>;
  73853. /**
  73854. * Visibility of the source mesh
  73855. */
  73856. readonly visibility: number;
  73857. /**
  73858. * Skeleton of the source mesh
  73859. */
  73860. readonly skeleton: Nullable<Skeleton>;
  73861. /**
  73862. * Rendering ground id of the source mesh
  73863. */
  73864. renderingGroupId: number;
  73865. /**
  73866. * Returns the total number of vertices (integer).
  73867. */
  73868. getTotalVertices(): number;
  73869. /**
  73870. * Returns a positive integer : the total number of indices in this mesh geometry.
  73871. * @returns the numner of indices or zero if the mesh has no geometry.
  73872. */
  73873. getTotalIndices(): number;
  73874. /**
  73875. * The source mesh of the instance
  73876. */
  73877. readonly sourceMesh: Mesh;
  73878. /**
  73879. * Is this node ready to be used/rendered
  73880. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73881. * @return {boolean} is it ready
  73882. */
  73883. isReady(completeCheck?: boolean): boolean;
  73884. /**
  73885. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73886. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73887. * @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.
  73888. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73889. */
  73890. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73891. /**
  73892. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73893. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73894. * The `data` are either a numeric array either a Float32Array.
  73895. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73896. * 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).
  73897. * Note that a new underlying VertexBuffer object is created each call.
  73898. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73899. *
  73900. * Possible `kind` values :
  73901. * - VertexBuffer.PositionKind
  73902. * - VertexBuffer.UVKind
  73903. * - VertexBuffer.UV2Kind
  73904. * - VertexBuffer.UV3Kind
  73905. * - VertexBuffer.UV4Kind
  73906. * - VertexBuffer.UV5Kind
  73907. * - VertexBuffer.UV6Kind
  73908. * - VertexBuffer.ColorKind
  73909. * - VertexBuffer.MatricesIndicesKind
  73910. * - VertexBuffer.MatricesIndicesExtraKind
  73911. * - VertexBuffer.MatricesWeightsKind
  73912. * - VertexBuffer.MatricesWeightsExtraKind
  73913. *
  73914. * Returns the Mesh.
  73915. */
  73916. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73917. /**
  73918. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73919. * If the mesh has no geometry, it is simply returned as it is.
  73920. * The `data` are either a numeric array either a Float32Array.
  73921. * No new underlying VertexBuffer object is created.
  73922. * 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.
  73923. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73924. *
  73925. * Possible `kind` values :
  73926. * - VertexBuffer.PositionKind
  73927. * - VertexBuffer.UVKind
  73928. * - VertexBuffer.UV2Kind
  73929. * - VertexBuffer.UV3Kind
  73930. * - VertexBuffer.UV4Kind
  73931. * - VertexBuffer.UV5Kind
  73932. * - VertexBuffer.UV6Kind
  73933. * - VertexBuffer.ColorKind
  73934. * - VertexBuffer.MatricesIndicesKind
  73935. * - VertexBuffer.MatricesIndicesExtraKind
  73936. * - VertexBuffer.MatricesWeightsKind
  73937. * - VertexBuffer.MatricesWeightsExtraKind
  73938. *
  73939. * Returns the Mesh.
  73940. */
  73941. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73942. /**
  73943. * Sets the mesh indices.
  73944. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73945. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73946. * This method creates a new index buffer each call.
  73947. * Returns the Mesh.
  73948. */
  73949. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73950. /**
  73951. * Boolean : True if the mesh owns the requested kind of data.
  73952. */
  73953. isVerticesDataPresent(kind: string): boolean;
  73954. /**
  73955. * Returns an array of indices (IndicesArray).
  73956. */
  73957. getIndices(): Nullable<IndicesArray>;
  73958. readonly _positions: Nullable<Vector3[]>;
  73959. /**
  73960. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73961. * This means the mesh underlying bounding box and sphere are recomputed.
  73962. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73963. * @returns the current mesh
  73964. */
  73965. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73966. /** @hidden */
  73967. _preActivate(): InstancedMesh;
  73968. /** @hidden */
  73969. _activate(renderId: number): InstancedMesh;
  73970. /**
  73971. * Returns the current associated LOD AbstractMesh.
  73972. */
  73973. getLOD(camera: Camera): AbstractMesh;
  73974. /** @hidden */
  73975. _syncSubMeshes(): InstancedMesh;
  73976. /** @hidden */
  73977. _generatePointsArray(): boolean;
  73978. /**
  73979. * Creates a new InstancedMesh from the current mesh.
  73980. * - name (string) : the cloned mesh name
  73981. * - newParent (optional Node) : the optional Node to parent the clone to.
  73982. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73983. *
  73984. * Returns the clone.
  73985. */
  73986. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73987. /**
  73988. * Disposes the InstancedMesh.
  73989. * Returns nothing.
  73990. */
  73991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73992. }
  73993. }
  73994. declare module BABYLON {
  73995. /**
  73996. * Defines the options associated with the creation of a shader material.
  73997. */
  73998. export interface IShaderMaterialOptions {
  73999. /**
  74000. * Does the material work in alpha blend mode
  74001. */
  74002. needAlphaBlending: boolean;
  74003. /**
  74004. * Does the material work in alpha test mode
  74005. */
  74006. needAlphaTesting: boolean;
  74007. /**
  74008. * The list of attribute names used in the shader
  74009. */
  74010. attributes: string[];
  74011. /**
  74012. * The list of unifrom names used in the shader
  74013. */
  74014. uniforms: string[];
  74015. /**
  74016. * The list of UBO names used in the shader
  74017. */
  74018. uniformBuffers: string[];
  74019. /**
  74020. * The list of sampler names used in the shader
  74021. */
  74022. samplers: string[];
  74023. /**
  74024. * The list of defines used in the shader
  74025. */
  74026. defines: string[];
  74027. }
  74028. /**
  74029. * 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.
  74030. *
  74031. * This returned material effects how the mesh will look based on the code in the shaders.
  74032. *
  74033. * @see http://doc.babylonjs.com/how_to/shader_material
  74034. */
  74035. export class ShaderMaterial extends Material {
  74036. private _shaderPath;
  74037. private _options;
  74038. private _textures;
  74039. private _textureArrays;
  74040. private _floats;
  74041. private _ints;
  74042. private _floatsArrays;
  74043. private _colors3;
  74044. private _colors3Arrays;
  74045. private _colors4;
  74046. private _vectors2;
  74047. private _vectors3;
  74048. private _vectors4;
  74049. private _matrices;
  74050. private _matrices3x3;
  74051. private _matrices2x2;
  74052. private _vectors2Arrays;
  74053. private _vectors3Arrays;
  74054. private _cachedWorldViewMatrix;
  74055. private _renderId;
  74056. /**
  74057. * Instantiate a new shader material.
  74058. * 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.
  74059. * This returned material effects how the mesh will look based on the code in the shaders.
  74060. * @see http://doc.babylonjs.com/how_to/shader_material
  74061. * @param name Define the name of the material in the scene
  74062. * @param scene Define the scene the material belongs to
  74063. * @param shaderPath Defines the route to the shader code in one of three ways:
  74064. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74065. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74066. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74067. * @param options Define the options used to create the shader
  74068. */
  74069. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74070. /**
  74071. * Gets the options used to compile the shader.
  74072. * They can be modified to trigger a new compilation
  74073. */
  74074. readonly options: IShaderMaterialOptions;
  74075. /**
  74076. * Gets the current class name of the material e.g. "ShaderMaterial"
  74077. * Mainly use in serialization.
  74078. * @returns the class name
  74079. */
  74080. getClassName(): string;
  74081. /**
  74082. * Specifies if the material will require alpha blending
  74083. * @returns a boolean specifying if alpha blending is needed
  74084. */
  74085. needAlphaBlending(): boolean;
  74086. /**
  74087. * Specifies if this material should be rendered in alpha test mode
  74088. * @returns a boolean specifying if an alpha test is needed.
  74089. */
  74090. needAlphaTesting(): boolean;
  74091. private _checkUniform;
  74092. /**
  74093. * Set a texture in the shader.
  74094. * @param name Define the name of the uniform samplers as defined in the shader
  74095. * @param texture Define the texture to bind to this sampler
  74096. * @return the material itself allowing "fluent" like uniform updates
  74097. */
  74098. setTexture(name: string, texture: Texture): ShaderMaterial;
  74099. /**
  74100. * Set a texture array in the shader.
  74101. * @param name Define the name of the uniform sampler array as defined in the shader
  74102. * @param textures Define the list of textures to bind to this sampler
  74103. * @return the material itself allowing "fluent" like uniform updates
  74104. */
  74105. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74106. /**
  74107. * Set a float in the shader.
  74108. * @param name Define the name of the uniform as defined in the shader
  74109. * @param value Define the value to give to the uniform
  74110. * @return the material itself allowing "fluent" like uniform updates
  74111. */
  74112. setFloat(name: string, value: number): ShaderMaterial;
  74113. /**
  74114. * Set a int in the shader.
  74115. * @param name Define the name of the uniform as defined in the shader
  74116. * @param value Define the value to give to the uniform
  74117. * @return the material itself allowing "fluent" like uniform updates
  74118. */
  74119. setInt(name: string, value: number): ShaderMaterial;
  74120. /**
  74121. * Set an array of floats in the shader.
  74122. * @param name Define the name of the uniform as defined in the shader
  74123. * @param value Define the value to give to the uniform
  74124. * @return the material itself allowing "fluent" like uniform updates
  74125. */
  74126. setFloats(name: string, value: number[]): ShaderMaterial;
  74127. /**
  74128. * Set a vec3 in the shader from a Color3.
  74129. * @param name Define the name of the uniform as defined in the shader
  74130. * @param value Define the value to give to the uniform
  74131. * @return the material itself allowing "fluent" like uniform updates
  74132. */
  74133. setColor3(name: string, value: Color3): ShaderMaterial;
  74134. /**
  74135. * Set a vec3 array in the shader from a Color3 array.
  74136. * @param name Define the name of the uniform as defined in the shader
  74137. * @param value Define the value to give to the uniform
  74138. * @return the material itself allowing "fluent" like uniform updates
  74139. */
  74140. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74141. /**
  74142. * Set a vec4 in the shader from a Color4.
  74143. * @param name Define the name of the uniform as defined in the shader
  74144. * @param value Define the value to give to the uniform
  74145. * @return the material itself allowing "fluent" like uniform updates
  74146. */
  74147. setColor4(name: string, value: Color4): ShaderMaterial;
  74148. /**
  74149. * Set a vec2 in the shader from a Vector2.
  74150. * @param name Define the name of the uniform as defined in the shader
  74151. * @param value Define the value to give to the uniform
  74152. * @return the material itself allowing "fluent" like uniform updates
  74153. */
  74154. setVector2(name: string, value: Vector2): ShaderMaterial;
  74155. /**
  74156. * Set a vec3 in the shader from a Vector3.
  74157. * @param name Define the name of the uniform as defined in the shader
  74158. * @param value Define the value to give to the uniform
  74159. * @return the material itself allowing "fluent" like uniform updates
  74160. */
  74161. setVector3(name: string, value: Vector3): ShaderMaterial;
  74162. /**
  74163. * Set a vec4 in the shader from a Vector4.
  74164. * @param name Define the name of the uniform as defined in the shader
  74165. * @param value Define the value to give to the uniform
  74166. * @return the material itself allowing "fluent" like uniform updates
  74167. */
  74168. setVector4(name: string, value: Vector4): ShaderMaterial;
  74169. /**
  74170. * Set a mat4 in the shader from a Matrix.
  74171. * @param name Define the name of the uniform as defined in the shader
  74172. * @param value Define the value to give to the uniform
  74173. * @return the material itself allowing "fluent" like uniform updates
  74174. */
  74175. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74176. /**
  74177. * Set a mat3 in the shader from a Float32Array.
  74178. * @param name Define the name of the uniform as defined in the shader
  74179. * @param value Define the value to give to the uniform
  74180. * @return the material itself allowing "fluent" like uniform updates
  74181. */
  74182. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74183. /**
  74184. * Set a mat2 in the shader from a Float32Array.
  74185. * @param name Define the name of the uniform as defined in the shader
  74186. * @param value Define the value to give to the uniform
  74187. * @return the material itself allowing "fluent" like uniform updates
  74188. */
  74189. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74190. /**
  74191. * Set a vec2 array in the shader from a number array.
  74192. * @param name Define the name of the uniform as defined in the shader
  74193. * @param value Define the value to give to the uniform
  74194. * @return the material itself allowing "fluent" like uniform updates
  74195. */
  74196. setArray2(name: string, value: number[]): ShaderMaterial;
  74197. /**
  74198. * Set a vec3 array in the shader from a number array.
  74199. * @param name Define the name of the uniform as defined in the shader
  74200. * @param value Define the value to give to the uniform
  74201. * @return the material itself allowing "fluent" like uniform updates
  74202. */
  74203. setArray3(name: string, value: number[]): ShaderMaterial;
  74204. private _checkCache;
  74205. /**
  74206. * Checks if the material is ready to render the requested mesh
  74207. * @param mesh Define the mesh to render
  74208. * @param useInstances Define whether or not the material is used with instances
  74209. * @returns true if ready, otherwise false
  74210. */
  74211. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74212. /**
  74213. * Binds the world matrix to the material
  74214. * @param world defines the world transformation matrix
  74215. */
  74216. bindOnlyWorldMatrix(world: Matrix): void;
  74217. /**
  74218. * Binds the material to the mesh
  74219. * @param world defines the world transformation matrix
  74220. * @param mesh defines the mesh to bind the material to
  74221. */
  74222. bind(world: Matrix, mesh?: Mesh): void;
  74223. /**
  74224. * Gets the active textures from the material
  74225. * @returns an array of textures
  74226. */
  74227. getActiveTextures(): BaseTexture[];
  74228. /**
  74229. * Specifies if the material uses a texture
  74230. * @param texture defines the texture to check against the material
  74231. * @returns a boolean specifying if the material uses the texture
  74232. */
  74233. hasTexture(texture: BaseTexture): boolean;
  74234. /**
  74235. * Makes a duplicate of the material, and gives it a new name
  74236. * @param name defines the new name for the duplicated material
  74237. * @returns the cloned material
  74238. */
  74239. clone(name: string): ShaderMaterial;
  74240. /**
  74241. * Disposes the material
  74242. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74243. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74244. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74245. */
  74246. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74247. /**
  74248. * Serializes this material in a JSON representation
  74249. * @returns the serialized material object
  74250. */
  74251. serialize(): any;
  74252. /**
  74253. * Creates a shader material from parsed shader material data
  74254. * @param source defines the JSON represnetation of the material
  74255. * @param scene defines the hosting scene
  74256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74257. * @returns a new material
  74258. */
  74259. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /** @hidden */
  74264. export var colorPixelShader: {
  74265. name: string;
  74266. shader: string;
  74267. };
  74268. }
  74269. declare module BABYLON {
  74270. /** @hidden */
  74271. export var colorVertexShader: {
  74272. name: string;
  74273. shader: string;
  74274. };
  74275. }
  74276. declare module BABYLON {
  74277. /**
  74278. * Line mesh
  74279. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74280. */
  74281. export class LinesMesh extends Mesh {
  74282. /**
  74283. * If vertex color should be applied to the mesh
  74284. */
  74285. useVertexColor?: boolean | undefined;
  74286. /**
  74287. * If vertex alpha should be applied to the mesh
  74288. */
  74289. useVertexAlpha?: boolean | undefined;
  74290. /**
  74291. * Color of the line (Default: White)
  74292. */
  74293. color: Color3;
  74294. /**
  74295. * Alpha of the line (Default: 1)
  74296. */
  74297. alpha: number;
  74298. /**
  74299. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74300. * This margin is expressed in world space coordinates, so its value may vary.
  74301. * Default value is 0.1
  74302. */
  74303. intersectionThreshold: number;
  74304. private _colorShader;
  74305. /**
  74306. * Creates a new LinesMesh
  74307. * @param name defines the name
  74308. * @param scene defines the hosting scene
  74309. * @param parent defines the parent mesh if any
  74310. * @param source defines the optional source LinesMesh used to clone data from
  74311. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74312. * When false, achieved by calling a clone(), also passing False.
  74313. * This will make creation of children, recursive.
  74314. * @param useVertexColor defines if this LinesMesh supports vertex color
  74315. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74316. */
  74317. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74318. /**
  74319. * If vertex color should be applied to the mesh
  74320. */
  74321. useVertexColor?: boolean | undefined,
  74322. /**
  74323. * If vertex alpha should be applied to the mesh
  74324. */
  74325. useVertexAlpha?: boolean | undefined);
  74326. private _addClipPlaneDefine;
  74327. private _removeClipPlaneDefine;
  74328. isReady(): boolean;
  74329. /**
  74330. * Returns the string "LineMesh"
  74331. */
  74332. getClassName(): string;
  74333. /**
  74334. * @hidden
  74335. */
  74336. /**
  74337. * @hidden
  74338. */
  74339. material: Material;
  74340. /**
  74341. * @hidden
  74342. */
  74343. readonly checkCollisions: boolean;
  74344. /** @hidden */
  74345. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74346. /** @hidden */
  74347. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74348. /**
  74349. * Disposes of the line mesh
  74350. * @param doNotRecurse If children should be disposed
  74351. */
  74352. dispose(doNotRecurse?: boolean): void;
  74353. /**
  74354. * Returns a new LineMesh object cloned from the current one.
  74355. */
  74356. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74357. /**
  74358. * Creates a new InstancedLinesMesh object from the mesh model.
  74359. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74360. * @param name defines the name of the new instance
  74361. * @returns a new InstancedLinesMesh
  74362. */
  74363. createInstance(name: string): InstancedLinesMesh;
  74364. }
  74365. /**
  74366. * Creates an instance based on a source LinesMesh
  74367. */
  74368. export class InstancedLinesMesh extends InstancedMesh {
  74369. /**
  74370. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74371. * This margin is expressed in world space coordinates, so its value may vary.
  74372. * Initilized with the intersectionThreshold value of the source LinesMesh
  74373. */
  74374. intersectionThreshold: number;
  74375. constructor(name: string, source: LinesMesh);
  74376. /**
  74377. * Returns the string "InstancedLinesMesh".
  74378. */
  74379. getClassName(): string;
  74380. }
  74381. }
  74382. declare module BABYLON {
  74383. /** @hidden */
  74384. export var linePixelShader: {
  74385. name: string;
  74386. shader: string;
  74387. };
  74388. }
  74389. declare module BABYLON {
  74390. /** @hidden */
  74391. export var lineVertexShader: {
  74392. name: string;
  74393. shader: string;
  74394. };
  74395. }
  74396. declare module BABYLON {
  74397. interface AbstractMesh {
  74398. /**
  74399. * Disables the mesh edge rendering mode
  74400. * @returns the currentAbstractMesh
  74401. */
  74402. disableEdgesRendering(): AbstractMesh;
  74403. /**
  74404. * Enables the edge rendering mode on the mesh.
  74405. * This mode makes the mesh edges visible
  74406. * @param epsilon defines the maximal distance between two angles to detect a face
  74407. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74408. * @returns the currentAbstractMesh
  74409. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74410. */
  74411. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74412. /**
  74413. * Gets the edgesRenderer associated with the mesh
  74414. */
  74415. edgesRenderer: Nullable<EdgesRenderer>;
  74416. }
  74417. interface LinesMesh {
  74418. /**
  74419. * Enables the edge rendering mode on the mesh.
  74420. * This mode makes the mesh edges visible
  74421. * @param epsilon defines the maximal distance between two angles to detect a face
  74422. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74423. * @returns the currentAbstractMesh
  74424. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74425. */
  74426. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74427. }
  74428. interface InstancedLinesMesh {
  74429. /**
  74430. * Enables the edge rendering mode on the mesh.
  74431. * This mode makes the mesh edges visible
  74432. * @param epsilon defines the maximal distance between two angles to detect a face
  74433. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74434. * @returns the current InstancedLinesMesh
  74435. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74436. */
  74437. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74438. }
  74439. /**
  74440. * Defines the minimum contract an Edges renderer should follow.
  74441. */
  74442. export interface IEdgesRenderer extends IDisposable {
  74443. /**
  74444. * Gets or sets a boolean indicating if the edgesRenderer is active
  74445. */
  74446. isEnabled: boolean;
  74447. /**
  74448. * Renders the edges of the attached mesh,
  74449. */
  74450. render(): void;
  74451. /**
  74452. * Checks wether or not the edges renderer is ready to render.
  74453. * @return true if ready, otherwise false.
  74454. */
  74455. isReady(): boolean;
  74456. }
  74457. /**
  74458. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74459. */
  74460. export class EdgesRenderer implements IEdgesRenderer {
  74461. /**
  74462. * Define the size of the edges with an orthographic camera
  74463. */
  74464. edgesWidthScalerForOrthographic: number;
  74465. /**
  74466. * Define the size of the edges with a perspective camera
  74467. */
  74468. edgesWidthScalerForPerspective: number;
  74469. protected _source: AbstractMesh;
  74470. protected _linesPositions: number[];
  74471. protected _linesNormals: number[];
  74472. protected _linesIndices: number[];
  74473. protected _epsilon: number;
  74474. protected _indicesCount: number;
  74475. protected _lineShader: ShaderMaterial;
  74476. protected _ib: WebGLBuffer;
  74477. protected _buffers: {
  74478. [key: string]: Nullable<VertexBuffer>;
  74479. };
  74480. protected _checkVerticesInsteadOfIndices: boolean;
  74481. private _meshRebuildObserver;
  74482. private _meshDisposeObserver;
  74483. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74484. isEnabled: boolean;
  74485. /**
  74486. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74487. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74488. * @param source Mesh used to create edges
  74489. * @param epsilon sum of angles in adjacency to check for edge
  74490. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74491. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74492. */
  74493. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74494. protected _prepareRessources(): void;
  74495. /** @hidden */
  74496. _rebuild(): void;
  74497. /**
  74498. * Releases the required resources for the edges renderer
  74499. */
  74500. dispose(): void;
  74501. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74502. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74503. /**
  74504. * Checks if the pair of p0 and p1 is en edge
  74505. * @param faceIndex
  74506. * @param edge
  74507. * @param faceNormals
  74508. * @param p0
  74509. * @param p1
  74510. * @private
  74511. */
  74512. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74513. /**
  74514. * push line into the position, normal and index buffer
  74515. * @protected
  74516. */
  74517. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74518. /**
  74519. * Generates lines edges from adjacencjes
  74520. * @private
  74521. */
  74522. _generateEdgesLines(): void;
  74523. /**
  74524. * Checks wether or not the edges renderer is ready to render.
  74525. * @return true if ready, otherwise false.
  74526. */
  74527. isReady(): boolean;
  74528. /**
  74529. * Renders the edges of the attached mesh,
  74530. */
  74531. render(): void;
  74532. }
  74533. /**
  74534. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74535. */
  74536. export class LineEdgesRenderer extends EdgesRenderer {
  74537. /**
  74538. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74539. * @param source LineMesh used to generate edges
  74540. * @param epsilon not important (specified angle for edge detection)
  74541. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74542. */
  74543. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74544. /**
  74545. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74546. */
  74547. _generateEdgesLines(): void;
  74548. }
  74549. }
  74550. declare module BABYLON {
  74551. /**
  74552. * This represents the object necessary to create a rendering group.
  74553. * This is exclusively used and created by the rendering manager.
  74554. * To modify the behavior, you use the available helpers in your scene or meshes.
  74555. * @hidden
  74556. */
  74557. export class RenderingGroup {
  74558. index: number;
  74559. private _scene;
  74560. private _opaqueSubMeshes;
  74561. private _transparentSubMeshes;
  74562. private _alphaTestSubMeshes;
  74563. private _depthOnlySubMeshes;
  74564. private _particleSystems;
  74565. private _spriteManagers;
  74566. private _opaqueSortCompareFn;
  74567. private _alphaTestSortCompareFn;
  74568. private _transparentSortCompareFn;
  74569. private _renderOpaque;
  74570. private _renderAlphaTest;
  74571. private _renderTransparent;
  74572. private _edgesRenderers;
  74573. onBeforeTransparentRendering: () => void;
  74574. /**
  74575. * Set the opaque sort comparison function.
  74576. * If null the sub meshes will be render in the order they were created
  74577. */
  74578. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74579. /**
  74580. * Set the alpha test sort comparison function.
  74581. * If null the sub meshes will be render in the order they were created
  74582. */
  74583. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74584. /**
  74585. * Set the transparent sort comparison function.
  74586. * If null the sub meshes will be render in the order they were created
  74587. */
  74588. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74589. /**
  74590. * Creates a new rendering group.
  74591. * @param index The rendering group index
  74592. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74593. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74594. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74595. */
  74596. 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>);
  74597. /**
  74598. * Render all the sub meshes contained in the group.
  74599. * @param customRenderFunction Used to override the default render behaviour of the group.
  74600. * @returns true if rendered some submeshes.
  74601. */
  74602. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74603. /**
  74604. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74605. * @param subMeshes The submeshes to render
  74606. */
  74607. private renderOpaqueSorted;
  74608. /**
  74609. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74610. * @param subMeshes The submeshes to render
  74611. */
  74612. private renderAlphaTestSorted;
  74613. /**
  74614. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74615. * @param subMeshes The submeshes to render
  74616. */
  74617. private renderTransparentSorted;
  74618. /**
  74619. * Renders the submeshes in a specified order.
  74620. * @param subMeshes The submeshes to sort before render
  74621. * @param sortCompareFn The comparison function use to sort
  74622. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74623. * @param transparent Specifies to activate blending if true
  74624. */
  74625. private static renderSorted;
  74626. /**
  74627. * Renders the submeshes in the order they were dispatched (no sort applied).
  74628. * @param subMeshes The submeshes to render
  74629. */
  74630. private static renderUnsorted;
  74631. /**
  74632. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74633. * are rendered back to front if in the same alpha index.
  74634. *
  74635. * @param a The first submesh
  74636. * @param b The second submesh
  74637. * @returns The result of the comparison
  74638. */
  74639. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74640. /**
  74641. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74642. * are rendered back to front.
  74643. *
  74644. * @param a The first submesh
  74645. * @param b The second submesh
  74646. * @returns The result of the comparison
  74647. */
  74648. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74649. /**
  74650. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74651. * are rendered front to back (prevent overdraw).
  74652. *
  74653. * @param a The first submesh
  74654. * @param b The second submesh
  74655. * @returns The result of the comparison
  74656. */
  74657. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74658. /**
  74659. * Resets the different lists of submeshes to prepare a new frame.
  74660. */
  74661. prepare(): void;
  74662. dispose(): void;
  74663. /**
  74664. * Inserts the submesh in its correct queue depending on its material.
  74665. * @param subMesh The submesh to dispatch
  74666. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74667. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74668. */
  74669. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74670. dispatchSprites(spriteManager: ISpriteManager): void;
  74671. dispatchParticles(particleSystem: IParticleSystem): void;
  74672. private _renderParticles;
  74673. private _renderSprites;
  74674. }
  74675. }
  74676. declare module BABYLON {
  74677. /**
  74678. * Interface describing the different options available in the rendering manager
  74679. * regarding Auto Clear between groups.
  74680. */
  74681. export interface IRenderingManagerAutoClearSetup {
  74682. /**
  74683. * Defines whether or not autoclear is enable.
  74684. */
  74685. autoClear: boolean;
  74686. /**
  74687. * Defines whether or not to autoclear the depth buffer.
  74688. */
  74689. depth: boolean;
  74690. /**
  74691. * Defines whether or not to autoclear the stencil buffer.
  74692. */
  74693. stencil: boolean;
  74694. }
  74695. /**
  74696. * This class is used by the onRenderingGroupObservable
  74697. */
  74698. export class RenderingGroupInfo {
  74699. /**
  74700. * The Scene that being rendered
  74701. */
  74702. scene: Scene;
  74703. /**
  74704. * The camera currently used for the rendering pass
  74705. */
  74706. camera: Nullable<Camera>;
  74707. /**
  74708. * The ID of the renderingGroup being processed
  74709. */
  74710. renderingGroupId: number;
  74711. }
  74712. /**
  74713. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74714. * It is enable to manage the different groups as well as the different necessary sort functions.
  74715. * This should not be used directly aside of the few static configurations
  74716. */
  74717. export class RenderingManager {
  74718. /**
  74719. * The max id used for rendering groups (not included)
  74720. */
  74721. static MAX_RENDERINGGROUPS: number;
  74722. /**
  74723. * The min id used for rendering groups (included)
  74724. */
  74725. static MIN_RENDERINGGROUPS: number;
  74726. /**
  74727. * Used to globally prevent autoclearing scenes.
  74728. */
  74729. static AUTOCLEAR: boolean;
  74730. /**
  74731. * @hidden
  74732. */
  74733. _useSceneAutoClearSetup: boolean;
  74734. private _scene;
  74735. private _renderingGroups;
  74736. private _depthStencilBufferAlreadyCleaned;
  74737. private _autoClearDepthStencil;
  74738. private _customOpaqueSortCompareFn;
  74739. private _customAlphaTestSortCompareFn;
  74740. private _customTransparentSortCompareFn;
  74741. private _renderingGroupInfo;
  74742. /**
  74743. * Instantiates a new rendering group for a particular scene
  74744. * @param scene Defines the scene the groups belongs to
  74745. */
  74746. constructor(scene: Scene);
  74747. private _clearDepthStencilBuffer;
  74748. /**
  74749. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74750. * @hidden
  74751. */
  74752. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74753. /**
  74754. * Resets the different information of the group to prepare a new frame
  74755. * @hidden
  74756. */
  74757. reset(): void;
  74758. /**
  74759. * Dispose and release the group and its associated resources.
  74760. * @hidden
  74761. */
  74762. dispose(): void;
  74763. /**
  74764. * Clear the info related to rendering groups preventing retention points during dispose.
  74765. */
  74766. freeRenderingGroups(): void;
  74767. private _prepareRenderingGroup;
  74768. /**
  74769. * Add a sprite manager to the rendering manager in order to render it this frame.
  74770. * @param spriteManager Define the sprite manager to render
  74771. */
  74772. dispatchSprites(spriteManager: ISpriteManager): void;
  74773. /**
  74774. * Add a particle system to the rendering manager in order to render it this frame.
  74775. * @param particleSystem Define the particle system to render
  74776. */
  74777. dispatchParticles(particleSystem: IParticleSystem): void;
  74778. /**
  74779. * Add a submesh to the manager in order to render it this frame
  74780. * @param subMesh The submesh to dispatch
  74781. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74782. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74783. */
  74784. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74785. /**
  74786. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74787. * This allowed control for front to back rendering or reversly depending of the special needs.
  74788. *
  74789. * @param renderingGroupId The rendering group id corresponding to its index
  74790. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74791. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74792. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74793. */
  74794. 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;
  74795. /**
  74796. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74797. *
  74798. * @param renderingGroupId The rendering group id corresponding to its index
  74799. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74800. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74801. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74802. */
  74803. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74804. /**
  74805. * Gets the current auto clear configuration for one rendering group of the rendering
  74806. * manager.
  74807. * @param index the rendering group index to get the information for
  74808. * @returns The auto clear setup for the requested rendering group
  74809. */
  74810. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74811. }
  74812. }
  74813. declare module BABYLON {
  74814. /**
  74815. * This Helps creating a texture that will be created from a camera in your scene.
  74816. * It is basically a dynamic texture that could be used to create special effects for instance.
  74817. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74818. */
  74819. export class RenderTargetTexture extends Texture {
  74820. isCube: boolean;
  74821. /**
  74822. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74823. */
  74824. static readonly REFRESHRATE_RENDER_ONCE: number;
  74825. /**
  74826. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74827. */
  74828. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74829. /**
  74830. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74831. * the central point of your effect and can save a lot of performances.
  74832. */
  74833. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74834. /**
  74835. * Use this predicate to dynamically define the list of mesh you want to render.
  74836. * If set, the renderList property will be overwritten.
  74837. */
  74838. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74839. private _renderList;
  74840. /**
  74841. * Use this list to define the list of mesh you want to render.
  74842. */
  74843. renderList: Nullable<Array<AbstractMesh>>;
  74844. private _hookArray;
  74845. /**
  74846. * Define if particles should be rendered in your texture.
  74847. */
  74848. renderParticles: boolean;
  74849. /**
  74850. * Define if sprites should be rendered in your texture.
  74851. */
  74852. renderSprites: boolean;
  74853. /**
  74854. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74855. */
  74856. coordinatesMode: number;
  74857. /**
  74858. * Define the camera used to render the texture.
  74859. */
  74860. activeCamera: Nullable<Camera>;
  74861. /**
  74862. * Override the render function of the texture with your own one.
  74863. */
  74864. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74865. /**
  74866. * Define if camera post processes should be use while rendering the texture.
  74867. */
  74868. useCameraPostProcesses: boolean;
  74869. /**
  74870. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74871. */
  74872. ignoreCameraViewport: boolean;
  74873. private _postProcessManager;
  74874. private _postProcesses;
  74875. private _resizeObserver;
  74876. /**
  74877. * An event triggered when the texture is unbind.
  74878. */
  74879. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74880. /**
  74881. * An event triggered when the texture is unbind.
  74882. */
  74883. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74884. private _onAfterUnbindObserver;
  74885. /**
  74886. * Set a after unbind callback in the texture.
  74887. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74888. */
  74889. onAfterUnbind: () => void;
  74890. /**
  74891. * An event triggered before rendering the texture
  74892. */
  74893. onBeforeRenderObservable: Observable<number>;
  74894. private _onBeforeRenderObserver;
  74895. /**
  74896. * Set a before render callback in the texture.
  74897. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74898. */
  74899. onBeforeRender: (faceIndex: number) => void;
  74900. /**
  74901. * An event triggered after rendering the texture
  74902. */
  74903. onAfterRenderObservable: Observable<number>;
  74904. private _onAfterRenderObserver;
  74905. /**
  74906. * Set a after render callback in the texture.
  74907. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74908. */
  74909. onAfterRender: (faceIndex: number) => void;
  74910. /**
  74911. * An event triggered after the texture clear
  74912. */
  74913. onClearObservable: Observable<Engine>;
  74914. private _onClearObserver;
  74915. /**
  74916. * Set a clear callback in the texture.
  74917. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74918. */
  74919. onClear: (Engine: Engine) => void;
  74920. /**
  74921. * Define the clear color of the Render Target if it should be different from the scene.
  74922. */
  74923. clearColor: Color4;
  74924. protected _size: number | {
  74925. width: number;
  74926. height: number;
  74927. };
  74928. protected _initialSizeParameter: number | {
  74929. width: number;
  74930. height: number;
  74931. } | {
  74932. ratio: number;
  74933. };
  74934. protected _sizeRatio: Nullable<number>;
  74935. /** @hidden */
  74936. _generateMipMaps: boolean;
  74937. protected _renderingManager: RenderingManager;
  74938. /** @hidden */
  74939. _waitingRenderList: string[];
  74940. protected _doNotChangeAspectRatio: boolean;
  74941. protected _currentRefreshId: number;
  74942. protected _refreshRate: number;
  74943. protected _textureMatrix: Matrix;
  74944. protected _samples: number;
  74945. protected _renderTargetOptions: RenderTargetCreationOptions;
  74946. /**
  74947. * Gets render target creation options that were used.
  74948. */
  74949. readonly renderTargetOptions: RenderTargetCreationOptions;
  74950. protected _engine: Engine;
  74951. protected _onRatioRescale(): void;
  74952. /**
  74953. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74954. * It must define where the camera used to render the texture is set
  74955. */
  74956. boundingBoxPosition: Vector3;
  74957. private _boundingBoxSize;
  74958. /**
  74959. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74960. * When defined, the cubemap will switch to local mode
  74961. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74962. * @example https://www.babylonjs-playground.com/#RNASML
  74963. */
  74964. boundingBoxSize: Vector3;
  74965. /**
  74966. * In case the RTT has been created with a depth texture, get the associated
  74967. * depth texture.
  74968. * Otherwise, return null.
  74969. */
  74970. depthStencilTexture: Nullable<InternalTexture>;
  74971. /**
  74972. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74973. * or used a shadow, depth texture...
  74974. * @param name The friendly name of the texture
  74975. * @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)
  74976. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74977. * @param generateMipMaps True if mip maps need to be generated after render.
  74978. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74979. * @param type The type of the buffer in the RTT (int, half float, float...)
  74980. * @param isCube True if a cube texture needs to be created
  74981. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74982. * @param generateDepthBuffer True to generate a depth buffer
  74983. * @param generateStencilBuffer True to generate a stencil buffer
  74984. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74985. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74986. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74987. */
  74988. constructor(name: string, size: number | {
  74989. width: number;
  74990. height: number;
  74991. } | {
  74992. ratio: number;
  74993. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74994. /**
  74995. * Creates a depth stencil texture.
  74996. * This is only available in WebGL 2 or with the depth texture extension available.
  74997. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74998. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74999. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75000. */
  75001. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75002. private _processSizeParameter;
  75003. /**
  75004. * Define the number of samples to use in case of MSAA.
  75005. * It defaults to one meaning no MSAA has been enabled.
  75006. */
  75007. samples: number;
  75008. /**
  75009. * Resets the refresh counter of the texture and start bak from scratch.
  75010. * Could be useful to regenerate the texture if it is setup to render only once.
  75011. */
  75012. resetRefreshCounter(): void;
  75013. /**
  75014. * Define the refresh rate of the texture or the rendering frequency.
  75015. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75016. */
  75017. refreshRate: number;
  75018. /**
  75019. * Adds a post process to the render target rendering passes.
  75020. * @param postProcess define the post process to add
  75021. */
  75022. addPostProcess(postProcess: PostProcess): void;
  75023. /**
  75024. * Clear all the post processes attached to the render target
  75025. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75026. */
  75027. clearPostProcesses(dispose?: boolean): void;
  75028. /**
  75029. * Remove one of the post process from the list of attached post processes to the texture
  75030. * @param postProcess define the post process to remove from the list
  75031. */
  75032. removePostProcess(postProcess: PostProcess): void;
  75033. /** @hidden */
  75034. _shouldRender(): boolean;
  75035. /**
  75036. * Gets the actual render size of the texture.
  75037. * @returns the width of the render size
  75038. */
  75039. getRenderSize(): number;
  75040. /**
  75041. * Gets the actual render width of the texture.
  75042. * @returns the width of the render size
  75043. */
  75044. getRenderWidth(): number;
  75045. /**
  75046. * Gets the actual render height of the texture.
  75047. * @returns the height of the render size
  75048. */
  75049. getRenderHeight(): number;
  75050. /**
  75051. * Get if the texture can be rescaled or not.
  75052. */
  75053. readonly canRescale: boolean;
  75054. /**
  75055. * Resize the texture using a ratio.
  75056. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75057. */
  75058. scale(ratio: number): void;
  75059. /**
  75060. * Get the texture reflection matrix used to rotate/transform the reflection.
  75061. * @returns the reflection matrix
  75062. */
  75063. getReflectionTextureMatrix(): Matrix;
  75064. /**
  75065. * Resize the texture to a new desired size.
  75066. * Be carrefull as it will recreate all the data in the new texture.
  75067. * @param size Define the new size. It can be:
  75068. * - a number for squared texture,
  75069. * - an object containing { width: number, height: number }
  75070. * - or an object containing a ratio { ratio: number }
  75071. */
  75072. resize(size: number | {
  75073. width: number;
  75074. height: number;
  75075. } | {
  75076. ratio: number;
  75077. }): void;
  75078. /**
  75079. * Renders all the objects from the render list into the texture.
  75080. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75081. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75082. */
  75083. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75084. private _bestReflectionRenderTargetDimension;
  75085. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75086. private renderToTarget;
  75087. /**
  75088. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75089. * This allowed control for front to back rendering or reversly depending of the special needs.
  75090. *
  75091. * @param renderingGroupId The rendering group id corresponding to its index
  75092. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75093. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75094. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75095. */
  75096. 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;
  75097. /**
  75098. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75099. *
  75100. * @param renderingGroupId The rendering group id corresponding to its index
  75101. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75102. */
  75103. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75104. /**
  75105. * Clones the texture.
  75106. * @returns the cloned texture
  75107. */
  75108. clone(): RenderTargetTexture;
  75109. /**
  75110. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75111. * @returns The JSON representation of the texture
  75112. */
  75113. serialize(): any;
  75114. /**
  75115. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75116. */
  75117. disposeFramebufferObjects(): void;
  75118. /**
  75119. * Dispose the texture and release its associated resources.
  75120. */
  75121. dispose(): void;
  75122. /** @hidden */
  75123. _rebuild(): void;
  75124. /**
  75125. * Clear the info related to rendering groups preventing retention point in material dispose.
  75126. */
  75127. freeRenderingGroups(): void;
  75128. }
  75129. }
  75130. declare module BABYLON {
  75131. /**
  75132. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75133. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75134. * You can then easily use it as a reflectionTexture on a flat surface.
  75135. * In case the surface is not a plane, please consider relying on reflection probes.
  75136. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75137. */
  75138. export class MirrorTexture extends RenderTargetTexture {
  75139. private scene;
  75140. /**
  75141. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75142. * 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.
  75143. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75144. */
  75145. mirrorPlane: Plane;
  75146. /**
  75147. * Define the blur ratio used to blur the reflection if needed.
  75148. */
  75149. blurRatio: number;
  75150. /**
  75151. * Define the adaptive blur kernel used to blur the reflection if needed.
  75152. * This will autocompute the closest best match for the `blurKernel`
  75153. */
  75154. adaptiveBlurKernel: number;
  75155. /**
  75156. * Define the blur kernel used to blur the reflection if needed.
  75157. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75158. */
  75159. blurKernel: number;
  75160. /**
  75161. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75162. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75163. */
  75164. blurKernelX: number;
  75165. /**
  75166. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75167. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75168. */
  75169. blurKernelY: number;
  75170. private _autoComputeBlurKernel;
  75171. protected _onRatioRescale(): void;
  75172. private _updateGammaSpace;
  75173. private _imageProcessingConfigChangeObserver;
  75174. private _transformMatrix;
  75175. private _mirrorMatrix;
  75176. private _savedViewMatrix;
  75177. private _blurX;
  75178. private _blurY;
  75179. private _adaptiveBlurKernel;
  75180. private _blurKernelX;
  75181. private _blurKernelY;
  75182. private _blurRatio;
  75183. /**
  75184. * Instantiates a Mirror Texture.
  75185. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75186. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75187. * You can then easily use it as a reflectionTexture on a flat surface.
  75188. * In case the surface is not a plane, please consider relying on reflection probes.
  75189. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75190. * @param name
  75191. * @param size
  75192. * @param scene
  75193. * @param generateMipMaps
  75194. * @param type
  75195. * @param samplingMode
  75196. * @param generateDepthBuffer
  75197. */
  75198. constructor(name: string, size: number | {
  75199. width: number;
  75200. height: number;
  75201. } | {
  75202. ratio: number;
  75203. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75204. private _preparePostProcesses;
  75205. /**
  75206. * Clone the mirror texture.
  75207. * @returns the cloned texture
  75208. */
  75209. clone(): MirrorTexture;
  75210. /**
  75211. * Serialize the texture to a JSON representation you could use in Parse later on
  75212. * @returns the serialized JSON representation
  75213. */
  75214. serialize(): any;
  75215. /**
  75216. * Dispose the texture and release its associated resources.
  75217. */
  75218. dispose(): void;
  75219. }
  75220. }
  75221. declare module BABYLON {
  75222. /**
  75223. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75224. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75225. */
  75226. export class Texture extends BaseTexture {
  75227. /** @hidden */
  75228. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75229. /** @hidden */
  75230. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75231. /** @hidden */
  75232. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75233. /** nearest is mag = nearest and min = nearest and mip = linear */
  75234. static readonly NEAREST_SAMPLINGMODE: number;
  75235. /** nearest is mag = nearest and min = nearest and mip = linear */
  75236. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75237. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75238. static readonly BILINEAR_SAMPLINGMODE: number;
  75239. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75240. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75241. /** Trilinear is mag = linear and min = linear and mip = linear */
  75242. static readonly TRILINEAR_SAMPLINGMODE: number;
  75243. /** Trilinear is mag = linear and min = linear and mip = linear */
  75244. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75245. /** mag = nearest and min = nearest and mip = nearest */
  75246. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75247. /** mag = nearest and min = linear and mip = nearest */
  75248. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75249. /** mag = nearest and min = linear and mip = linear */
  75250. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75251. /** mag = nearest and min = linear and mip = none */
  75252. static readonly NEAREST_LINEAR: number;
  75253. /** mag = nearest and min = nearest and mip = none */
  75254. static readonly NEAREST_NEAREST: number;
  75255. /** mag = linear and min = nearest and mip = nearest */
  75256. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75257. /** mag = linear and min = nearest and mip = linear */
  75258. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75259. /** mag = linear and min = linear and mip = none */
  75260. static readonly LINEAR_LINEAR: number;
  75261. /** mag = linear and min = nearest and mip = none */
  75262. static readonly LINEAR_NEAREST: number;
  75263. /** Explicit coordinates mode */
  75264. static readonly EXPLICIT_MODE: number;
  75265. /** Spherical coordinates mode */
  75266. static readonly SPHERICAL_MODE: number;
  75267. /** Planar coordinates mode */
  75268. static readonly PLANAR_MODE: number;
  75269. /** Cubic coordinates mode */
  75270. static readonly CUBIC_MODE: number;
  75271. /** Projection coordinates mode */
  75272. static readonly PROJECTION_MODE: number;
  75273. /** Inverse Cubic coordinates mode */
  75274. static readonly SKYBOX_MODE: number;
  75275. /** Inverse Cubic coordinates mode */
  75276. static readonly INVCUBIC_MODE: number;
  75277. /** Equirectangular coordinates mode */
  75278. static readonly EQUIRECTANGULAR_MODE: number;
  75279. /** Equirectangular Fixed coordinates mode */
  75280. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75281. /** Equirectangular Fixed Mirrored coordinates mode */
  75282. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75283. /** Texture is not repeating outside of 0..1 UVs */
  75284. static readonly CLAMP_ADDRESSMODE: number;
  75285. /** Texture is repeating outside of 0..1 UVs */
  75286. static readonly WRAP_ADDRESSMODE: number;
  75287. /** Texture is repeating and mirrored */
  75288. static readonly MIRROR_ADDRESSMODE: number;
  75289. /**
  75290. * 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
  75291. */
  75292. static UseSerializedUrlIfAny: boolean;
  75293. /**
  75294. * Define the url of the texture.
  75295. */
  75296. url: Nullable<string>;
  75297. /**
  75298. * Define an offset on the texture to offset the u coordinates of the UVs
  75299. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75300. */
  75301. uOffset: number;
  75302. /**
  75303. * Define an offset on the texture to offset the v coordinates of the UVs
  75304. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75305. */
  75306. vOffset: number;
  75307. /**
  75308. * Define an offset on the texture to scale the u coordinates of the UVs
  75309. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75310. */
  75311. uScale: number;
  75312. /**
  75313. * Define an offset on the texture to scale the v coordinates of the UVs
  75314. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75315. */
  75316. vScale: number;
  75317. /**
  75318. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75319. * @see http://doc.babylonjs.com/how_to/more_materials
  75320. */
  75321. uAng: number;
  75322. /**
  75323. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75324. * @see http://doc.babylonjs.com/how_to/more_materials
  75325. */
  75326. vAng: number;
  75327. /**
  75328. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75329. * @see http://doc.babylonjs.com/how_to/more_materials
  75330. */
  75331. wAng: number;
  75332. /**
  75333. * Defines the center of rotation (U)
  75334. */
  75335. uRotationCenter: number;
  75336. /**
  75337. * Defines the center of rotation (V)
  75338. */
  75339. vRotationCenter: number;
  75340. /**
  75341. * Defines the center of rotation (W)
  75342. */
  75343. wRotationCenter: number;
  75344. /**
  75345. * Are mip maps generated for this texture or not.
  75346. */
  75347. readonly noMipmap: boolean;
  75348. private _noMipmap;
  75349. /** @hidden */
  75350. _invertY: boolean;
  75351. private _rowGenerationMatrix;
  75352. private _cachedTextureMatrix;
  75353. private _projectionModeMatrix;
  75354. private _t0;
  75355. private _t1;
  75356. private _t2;
  75357. private _cachedUOffset;
  75358. private _cachedVOffset;
  75359. private _cachedUScale;
  75360. private _cachedVScale;
  75361. private _cachedUAng;
  75362. private _cachedVAng;
  75363. private _cachedWAng;
  75364. private _cachedProjectionMatrixId;
  75365. private _cachedCoordinatesMode;
  75366. /** @hidden */
  75367. protected _initialSamplingMode: number;
  75368. /** @hidden */
  75369. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75370. private _deleteBuffer;
  75371. protected _format: Nullable<number>;
  75372. private _delayedOnLoad;
  75373. private _delayedOnError;
  75374. /**
  75375. * Observable triggered once the texture has been loaded.
  75376. */
  75377. onLoadObservable: Observable<Texture>;
  75378. protected _isBlocking: boolean;
  75379. /**
  75380. * Is the texture preventing material to render while loading.
  75381. * If false, a default texture will be used instead of the loading one during the preparation step.
  75382. */
  75383. isBlocking: boolean;
  75384. /**
  75385. * Get the current sampling mode associated with the texture.
  75386. */
  75387. readonly samplingMode: number;
  75388. /**
  75389. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75390. */
  75391. readonly invertY: boolean;
  75392. /**
  75393. * Instantiates a new texture.
  75394. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75395. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75396. * @param url define the url of the picture to load as a texture
  75397. * @param scene define the scene the texture will belong to
  75398. * @param noMipmap define if the texture will require mip maps or not
  75399. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75400. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75401. * @param onLoad define a callback triggered when the texture has been loaded
  75402. * @param onError define a callback triggered when an error occurred during the loading session
  75403. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75404. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75405. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75406. */
  75407. 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);
  75408. /**
  75409. * Update the url (and optional buffer) of this texture if url was null during construction.
  75410. * @param url the url of the texture
  75411. * @param buffer the buffer of the texture (defaults to null)
  75412. * @param onLoad callback called when the texture is loaded (defaults to null)
  75413. */
  75414. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75415. /**
  75416. * Finish the loading sequence of a texture flagged as delayed load.
  75417. * @hidden
  75418. */
  75419. delayLoad(): void;
  75420. private _prepareRowForTextureGeneration;
  75421. /**
  75422. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75423. * @returns the transform matrix of the texture.
  75424. */
  75425. getTextureMatrix(): Matrix;
  75426. /**
  75427. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75428. * @returns The reflection texture transform
  75429. */
  75430. getReflectionTextureMatrix(): Matrix;
  75431. /**
  75432. * Clones the texture.
  75433. * @returns the cloned texture
  75434. */
  75435. clone(): Texture;
  75436. /**
  75437. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75438. * @returns The JSON representation of the texture
  75439. */
  75440. serialize(): any;
  75441. /**
  75442. * Get the current class name of the texture useful for serialization or dynamic coding.
  75443. * @returns "Texture"
  75444. */
  75445. getClassName(): string;
  75446. /**
  75447. * Dispose the texture and release its associated resources.
  75448. */
  75449. dispose(): void;
  75450. /**
  75451. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75452. * @param parsedTexture Define the JSON representation of the texture
  75453. * @param scene Define the scene the parsed texture should be instantiated in
  75454. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75455. * @returns The parsed texture if successful
  75456. */
  75457. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75458. /**
  75459. * Creates a texture from its base 64 representation.
  75460. * @param data Define the base64 payload without the data: prefix
  75461. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75462. * @param scene Define the scene the texture should belong to
  75463. * @param noMipmap Forces the texture to not create mip map information if true
  75464. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75465. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75466. * @param onLoad define a callback triggered when the texture has been loaded
  75467. * @param onError define a callback triggered when an error occurred during the loading session
  75468. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75469. * @returns the created texture
  75470. */
  75471. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75472. /**
  75473. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75474. * @param data Define the base64 payload without the data: prefix
  75475. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75476. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75477. * @param scene Define the scene the texture should belong to
  75478. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75479. * @param noMipmap Forces the texture to not create mip map information if true
  75480. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75481. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75482. * @param onLoad define a callback triggered when the texture has been loaded
  75483. * @param onError define a callback triggered when an error occurred during the loading session
  75484. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75485. * @returns the created texture
  75486. */
  75487. 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;
  75488. }
  75489. }
  75490. declare module BABYLON {
  75491. /**
  75492. * Raw texture can help creating a texture directly from an array of data.
  75493. * This can be super useful if you either get the data from an uncompressed source or
  75494. * if you wish to create your texture pixel by pixel.
  75495. */
  75496. export class RawTexture extends Texture {
  75497. /**
  75498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75499. */
  75500. format: number;
  75501. private _engine;
  75502. /**
  75503. * Instantiates a new RawTexture.
  75504. * Raw texture can help creating a texture directly from an array of data.
  75505. * This can be super useful if you either get the data from an uncompressed source or
  75506. * if you wish to create your texture pixel by pixel.
  75507. * @param data define the array of data to use to create the texture
  75508. * @param width define the width of the texture
  75509. * @param height define the height of the texture
  75510. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75511. * @param scene define the scene the texture belongs to
  75512. * @param generateMipMaps define whether mip maps should be generated or not
  75513. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75514. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75515. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75516. */
  75517. constructor(data: ArrayBufferView, width: number, height: number,
  75518. /**
  75519. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75520. */
  75521. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75522. /**
  75523. * Updates the texture underlying data.
  75524. * @param data Define the new data of the texture
  75525. */
  75526. update(data: ArrayBufferView): void;
  75527. /**
  75528. * Creates a luminance texture from some data.
  75529. * @param data Define the texture data
  75530. * @param width Define the width of the texture
  75531. * @param height Define the height of the texture
  75532. * @param scene Define the scene the texture belongs to
  75533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75536. * @returns the luminance texture
  75537. */
  75538. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75539. /**
  75540. * Creates a luminance alpha texture from some data.
  75541. * @param data Define the texture data
  75542. * @param width Define the width of the texture
  75543. * @param height Define the height of the texture
  75544. * @param scene Define the scene the texture belongs to
  75545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75548. * @returns the luminance alpha texture
  75549. */
  75550. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75551. /**
  75552. * Creates an alpha texture from some data.
  75553. * @param data Define the texture data
  75554. * @param width Define the width of the texture
  75555. * @param height Define the height of the texture
  75556. * @param scene Define the scene the texture belongs to
  75557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75560. * @returns the alpha texture
  75561. */
  75562. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75563. /**
  75564. * Creates a RGB texture from some data.
  75565. * @param data Define the texture data
  75566. * @param width Define the width of the texture
  75567. * @param height Define the height of the texture
  75568. * @param scene Define the scene the texture belongs to
  75569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75573. * @returns the RGB alpha texture
  75574. */
  75575. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75576. /**
  75577. * Creates a RGBA texture from some data.
  75578. * @param data Define the texture data
  75579. * @param width Define the width of the texture
  75580. * @param height Define the height of the texture
  75581. * @param scene Define the scene the texture belongs to
  75582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75585. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75586. * @returns the RGBA texture
  75587. */
  75588. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75589. /**
  75590. * Creates a R texture from some data.
  75591. * @param data Define the texture data
  75592. * @param width Define the width of the texture
  75593. * @param height Define the height of the texture
  75594. * @param scene Define the scene the texture belongs to
  75595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75599. * @returns the R texture
  75600. */
  75601. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75602. }
  75603. }
  75604. declare module BABYLON {
  75605. /**
  75606. * Defines a runtime animation
  75607. */
  75608. export class RuntimeAnimation {
  75609. private _events;
  75610. /**
  75611. * The current frame of the runtime animation
  75612. */
  75613. private _currentFrame;
  75614. /**
  75615. * The animation used by the runtime animation
  75616. */
  75617. private _animation;
  75618. /**
  75619. * The target of the runtime animation
  75620. */
  75621. private _target;
  75622. /**
  75623. * The initiating animatable
  75624. */
  75625. private _host;
  75626. /**
  75627. * The original value of the runtime animation
  75628. */
  75629. private _originalValue;
  75630. /**
  75631. * The original blend value of the runtime animation
  75632. */
  75633. private _originalBlendValue;
  75634. /**
  75635. * The offsets cache of the runtime animation
  75636. */
  75637. private _offsetsCache;
  75638. /**
  75639. * The high limits cache of the runtime animation
  75640. */
  75641. private _highLimitsCache;
  75642. /**
  75643. * Specifies if the runtime animation has been stopped
  75644. */
  75645. private _stopped;
  75646. /**
  75647. * The blending factor of the runtime animation
  75648. */
  75649. private _blendingFactor;
  75650. /**
  75651. * The BabylonJS scene
  75652. */
  75653. private _scene;
  75654. /**
  75655. * The current value of the runtime animation
  75656. */
  75657. private _currentValue;
  75658. /** @hidden */
  75659. _workValue: any;
  75660. /**
  75661. * The active target of the runtime animation
  75662. */
  75663. private _activeTarget;
  75664. /**
  75665. * The target path of the runtime animation
  75666. */
  75667. private _targetPath;
  75668. /**
  75669. * The weight of the runtime animation
  75670. */
  75671. private _weight;
  75672. /**
  75673. * The ratio offset of the runtime animation
  75674. */
  75675. private _ratioOffset;
  75676. /**
  75677. * The previous delay of the runtime animation
  75678. */
  75679. private _previousDelay;
  75680. /**
  75681. * The previous ratio of the runtime animation
  75682. */
  75683. private _previousRatio;
  75684. /**
  75685. * Gets the current frame of the runtime animation
  75686. */
  75687. readonly currentFrame: number;
  75688. /**
  75689. * Gets the weight of the runtime animation
  75690. */
  75691. readonly weight: number;
  75692. /**
  75693. * Gets the current value of the runtime animation
  75694. */
  75695. readonly currentValue: any;
  75696. /**
  75697. * Gets the target path of the runtime animation
  75698. */
  75699. readonly targetPath: string;
  75700. /**
  75701. * Gets the actual target of the runtime animation
  75702. */
  75703. readonly target: any;
  75704. /**
  75705. * Create a new RuntimeAnimation object
  75706. * @param target defines the target of the animation
  75707. * @param animation defines the source animation object
  75708. * @param scene defines the hosting scene
  75709. * @param host defines the initiating Animatable
  75710. */
  75711. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75712. /**
  75713. * Gets the animation from the runtime animation
  75714. */
  75715. readonly animation: Animation;
  75716. /**
  75717. * Resets the runtime animation to the beginning
  75718. * @param restoreOriginal defines whether to restore the target property to the original value
  75719. */
  75720. reset(restoreOriginal?: boolean): void;
  75721. /**
  75722. * Specifies if the runtime animation is stopped
  75723. * @returns Boolean specifying if the runtime animation is stopped
  75724. */
  75725. isStopped(): boolean;
  75726. /**
  75727. * Disposes of the runtime animation
  75728. */
  75729. dispose(): void;
  75730. /**
  75731. * Interpolates the animation from the current frame
  75732. * @param currentFrame The frame to interpolate the animation to
  75733. * @param repeatCount The number of times that the animation should loop
  75734. * @param loopMode The type of looping mode to use
  75735. * @param offsetValue Animation offset value
  75736. * @param highLimitValue The high limit value
  75737. * @returns The interpolated value
  75738. */
  75739. private _interpolate;
  75740. /**
  75741. * Apply the interpolated value to the target
  75742. * @param currentValue defines the value computed by the animation
  75743. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75744. */
  75745. setValue(currentValue: any, weight?: number): void;
  75746. private _setValue;
  75747. /**
  75748. * Gets the loop pmode of the runtime animation
  75749. * @returns Loop Mode
  75750. */
  75751. private _getCorrectLoopMode;
  75752. /**
  75753. * Move the current animation to a given frame
  75754. * @param frame defines the frame to move to
  75755. */
  75756. goToFrame(frame: number): void;
  75757. /**
  75758. * @hidden Internal use only
  75759. */
  75760. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75761. /**
  75762. * Execute the current animation
  75763. * @param delay defines the delay to add to the current frame
  75764. * @param from defines the lower bound of the animation range
  75765. * @param to defines the upper bound of the animation range
  75766. * @param loop defines if the current animation must loop
  75767. * @param speedRatio defines the current speed ratio
  75768. * @param weight defines the weight of the animation (default is -1 so no weight)
  75769. * @param onLoop optional callback called when animation loops
  75770. * @returns a boolean indicating if the animation is running
  75771. */
  75772. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75773. }
  75774. }
  75775. declare module BABYLON {
  75776. /**
  75777. * Class used to store an actual running animation
  75778. */
  75779. export class Animatable {
  75780. /** defines the target object */
  75781. target: any;
  75782. /** defines the starting frame number (default is 0) */
  75783. fromFrame: number;
  75784. /** defines the ending frame number (default is 100) */
  75785. toFrame: number;
  75786. /** defines if the animation must loop (default is false) */
  75787. loopAnimation: boolean;
  75788. /** defines a callback to call when animation ends if it is not looping */
  75789. onAnimationEnd?: (() => void) | null | undefined;
  75790. /** defines a callback to call when animation loops */
  75791. onAnimationLoop?: (() => void) | null | undefined;
  75792. private _localDelayOffset;
  75793. private _pausedDelay;
  75794. private _runtimeAnimations;
  75795. private _paused;
  75796. private _scene;
  75797. private _speedRatio;
  75798. private _weight;
  75799. private _syncRoot;
  75800. /**
  75801. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75802. * This will only apply for non looping animation (default is true)
  75803. */
  75804. disposeOnEnd: boolean;
  75805. /**
  75806. * Gets a boolean indicating if the animation has started
  75807. */
  75808. animationStarted: boolean;
  75809. /**
  75810. * Observer raised when the animation ends
  75811. */
  75812. onAnimationEndObservable: Observable<Animatable>;
  75813. /**
  75814. * Observer raised when the animation loops
  75815. */
  75816. onAnimationLoopObservable: Observable<Animatable>;
  75817. /**
  75818. * Gets the root Animatable used to synchronize and normalize animations
  75819. */
  75820. readonly syncRoot: Animatable;
  75821. /**
  75822. * Gets the current frame of the first RuntimeAnimation
  75823. * Used to synchronize Animatables
  75824. */
  75825. readonly masterFrame: number;
  75826. /**
  75827. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75828. */
  75829. weight: number;
  75830. /**
  75831. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75832. */
  75833. speedRatio: number;
  75834. /**
  75835. * Creates a new Animatable
  75836. * @param scene defines the hosting scene
  75837. * @param target defines the target object
  75838. * @param fromFrame defines the starting frame number (default is 0)
  75839. * @param toFrame defines the ending frame number (default is 100)
  75840. * @param loopAnimation defines if the animation must loop (default is false)
  75841. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75842. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75843. * @param animations defines a group of animation to add to the new Animatable
  75844. * @param onAnimationLoop defines a callback to call when animation loops
  75845. */
  75846. constructor(scene: Scene,
  75847. /** defines the target object */
  75848. target: any,
  75849. /** defines the starting frame number (default is 0) */
  75850. fromFrame?: number,
  75851. /** defines the ending frame number (default is 100) */
  75852. toFrame?: number,
  75853. /** defines if the animation must loop (default is false) */
  75854. loopAnimation?: boolean, speedRatio?: number,
  75855. /** defines a callback to call when animation ends if it is not looping */
  75856. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75857. /** defines a callback to call when animation loops */
  75858. onAnimationLoop?: (() => void) | null | undefined);
  75859. /**
  75860. * Synchronize and normalize current Animatable with a source Animatable
  75861. * This is useful when using animation weights and when animations are not of the same length
  75862. * @param root defines the root Animatable to synchronize with
  75863. * @returns the current Animatable
  75864. */
  75865. syncWith(root: Animatable): Animatable;
  75866. /**
  75867. * Gets the list of runtime animations
  75868. * @returns an array of RuntimeAnimation
  75869. */
  75870. getAnimations(): RuntimeAnimation[];
  75871. /**
  75872. * Adds more animations to the current animatable
  75873. * @param target defines the target of the animations
  75874. * @param animations defines the new animations to add
  75875. */
  75876. appendAnimations(target: any, animations: Animation[]): void;
  75877. /**
  75878. * Gets the source animation for a specific property
  75879. * @param property defines the propertyu to look for
  75880. * @returns null or the source animation for the given property
  75881. */
  75882. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75883. /**
  75884. * Gets the runtime animation for a specific property
  75885. * @param property defines the propertyu to look for
  75886. * @returns null or the runtime animation for the given property
  75887. */
  75888. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75889. /**
  75890. * Resets the animatable to its original state
  75891. */
  75892. reset(): void;
  75893. /**
  75894. * Allows the animatable to blend with current running animations
  75895. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75896. * @param blendingSpeed defines the blending speed to use
  75897. */
  75898. enableBlending(blendingSpeed: number): void;
  75899. /**
  75900. * Disable animation blending
  75901. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75902. */
  75903. disableBlending(): void;
  75904. /**
  75905. * Jump directly to a given frame
  75906. * @param frame defines the frame to jump to
  75907. */
  75908. goToFrame(frame: number): void;
  75909. /**
  75910. * Pause the animation
  75911. */
  75912. pause(): void;
  75913. /**
  75914. * Restart the animation
  75915. */
  75916. restart(): void;
  75917. private _raiseOnAnimationEnd;
  75918. /**
  75919. * Stop and delete the current animation
  75920. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75921. * @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)
  75922. */
  75923. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75924. /**
  75925. * Wait asynchronously for the animation to end
  75926. * @returns a promise which will be fullfilled when the animation ends
  75927. */
  75928. waitAsync(): Promise<Animatable>;
  75929. /** @hidden */
  75930. _animate(delay: number): boolean;
  75931. }
  75932. interface Scene {
  75933. /** @hidden */
  75934. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75935. /** @hidden */
  75936. _processLateAnimationBindingsForMatrices(holder: {
  75937. totalWeight: number;
  75938. animations: RuntimeAnimation[];
  75939. originalValue: Matrix;
  75940. }): any;
  75941. /** @hidden */
  75942. _processLateAnimationBindingsForQuaternions(holder: {
  75943. totalWeight: number;
  75944. animations: RuntimeAnimation[];
  75945. originalValue: Quaternion;
  75946. }, refQuaternion: Quaternion): Quaternion;
  75947. /** @hidden */
  75948. _processLateAnimationBindings(): void;
  75949. /**
  75950. * Will start the animation sequence of a given target
  75951. * @param target defines the target
  75952. * @param from defines from which frame should animation start
  75953. * @param to defines until which frame should animation run.
  75954. * @param weight defines the weight to apply to the animation (1.0 by default)
  75955. * @param loop defines if the animation loops
  75956. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75957. * @param onAnimationEnd defines the function to be executed when the animation ends
  75958. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75959. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75960. * @param onAnimationLoop defines the callback to call when an animation loops
  75961. * @returns the animatable object created for this animation
  75962. */
  75963. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75964. /**
  75965. * Will start the animation sequence of a given target
  75966. * @param target defines the target
  75967. * @param from defines from which frame should animation start
  75968. * @param to defines until which frame should animation run.
  75969. * @param loop defines if the animation loops
  75970. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75971. * @param onAnimationEnd defines the function to be executed when the animation ends
  75972. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75973. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75974. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75975. * @param onAnimationLoop defines the callback to call when an animation loops
  75976. * @returns the animatable object created for this animation
  75977. */
  75978. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75979. /**
  75980. * Will start the animation sequence of a given target and its hierarchy
  75981. * @param target defines the target
  75982. * @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.
  75983. * @param from defines from which frame should animation start
  75984. * @param to defines until which frame should animation run.
  75985. * @param loop defines if the animation loops
  75986. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75987. * @param onAnimationEnd defines the function to be executed when the animation ends
  75988. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75989. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75990. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75991. * @param onAnimationLoop defines the callback to call when an animation loops
  75992. * @returns the list of created animatables
  75993. */
  75994. 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[];
  75995. /**
  75996. * Begin a new animation on a given node
  75997. * @param target defines the target where the animation will take place
  75998. * @param animations defines the list of animations to start
  75999. * @param from defines the initial value
  76000. * @param to defines the final value
  76001. * @param loop defines if you want animation to loop (off by default)
  76002. * @param speedRatio defines the speed ratio to apply to all animations
  76003. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76004. * @param onAnimationLoop defines the callback to call when an animation loops
  76005. * @returns the list of created animatables
  76006. */
  76007. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76008. /**
  76009. * Begin a new animation on a given node and its hierarchy
  76010. * @param target defines the root node where the animation will take place
  76011. * @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.
  76012. * @param animations defines the list of animations to start
  76013. * @param from defines the initial value
  76014. * @param to defines the final value
  76015. * @param loop defines if you want animation to loop (off by default)
  76016. * @param speedRatio defines the speed ratio to apply to all animations
  76017. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76018. * @param onAnimationLoop defines the callback to call when an animation loops
  76019. * @returns the list of animatables created for all nodes
  76020. */
  76021. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76022. /**
  76023. * Gets the animatable associated with a specific target
  76024. * @param target defines the target of the animatable
  76025. * @returns the required animatable if found
  76026. */
  76027. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76028. /**
  76029. * Gets all animatables associated with a given target
  76030. * @param target defines the target to look animatables for
  76031. * @returns an array of Animatables
  76032. */
  76033. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76034. /**
  76035. * Will stop the animation of the given target
  76036. * @param target - the target
  76037. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76038. * @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)
  76039. */
  76040. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76041. /**
  76042. * Stops and removes all animations that have been applied to the scene
  76043. */
  76044. stopAllAnimations(): void;
  76045. }
  76046. interface Bone {
  76047. /**
  76048. * Copy an animation range from another bone
  76049. * @param source defines the source bone
  76050. * @param rangeName defines the range name to copy
  76051. * @param frameOffset defines the frame offset
  76052. * @param rescaleAsRequired defines if rescaling must be applied if required
  76053. * @param skelDimensionsRatio defines the scaling ratio
  76054. * @returns true if operation was successful
  76055. */
  76056. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76057. }
  76058. }
  76059. declare module BABYLON {
  76060. /**
  76061. * Class used to handle skinning animations
  76062. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76063. */
  76064. export class Skeleton implements IAnimatable {
  76065. /** defines the skeleton name */
  76066. name: string;
  76067. /** defines the skeleton Id */
  76068. id: string;
  76069. /**
  76070. * Defines the list of child bones
  76071. */
  76072. bones: Bone[];
  76073. /**
  76074. * Defines an estimate of the dimension of the skeleton at rest
  76075. */
  76076. dimensionsAtRest: Vector3;
  76077. /**
  76078. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76079. */
  76080. needInitialSkinMatrix: boolean;
  76081. /**
  76082. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76083. */
  76084. overrideMesh: Nullable<AbstractMesh>;
  76085. /**
  76086. * Gets the list of animations attached to this skeleton
  76087. */
  76088. animations: Array<Animation>;
  76089. private _scene;
  76090. private _isDirty;
  76091. private _transformMatrices;
  76092. private _transformMatrixTexture;
  76093. private _meshesWithPoseMatrix;
  76094. private _animatables;
  76095. private _identity;
  76096. private _synchronizedWithMesh;
  76097. private _ranges;
  76098. private _lastAbsoluteTransformsUpdateId;
  76099. private _canUseTextureForBones;
  76100. /** @hidden */
  76101. _numBonesWithLinkedTransformNode: number;
  76102. /**
  76103. * Specifies if the skeleton should be serialized
  76104. */
  76105. doNotSerialize: boolean;
  76106. /**
  76107. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76108. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76109. */
  76110. useTextureToStoreBoneMatrices: boolean;
  76111. private _animationPropertiesOverride;
  76112. /**
  76113. * Gets or sets the animation properties override
  76114. */
  76115. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76116. /**
  76117. * An observable triggered before computing the skeleton's matrices
  76118. */
  76119. onBeforeComputeObservable: Observable<Skeleton>;
  76120. /**
  76121. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76122. */
  76123. readonly isUsingTextureForMatrices: boolean;
  76124. /**
  76125. * Creates a new skeleton
  76126. * @param name defines the skeleton name
  76127. * @param id defines the skeleton Id
  76128. * @param scene defines the hosting scene
  76129. */
  76130. constructor(
  76131. /** defines the skeleton name */
  76132. name: string,
  76133. /** defines the skeleton Id */
  76134. id: string, scene: Scene);
  76135. /**
  76136. * Gets the current object class name.
  76137. * @return the class name
  76138. */
  76139. getClassName(): string;
  76140. /**
  76141. * Returns an array containing the root bones
  76142. * @returns an array containing the root bones
  76143. */
  76144. getChildren(): Array<Bone>;
  76145. /**
  76146. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76147. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76148. * @returns a Float32Array containing matrices data
  76149. */
  76150. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76151. /**
  76152. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76153. * @returns a raw texture containing the data
  76154. */
  76155. getTransformMatrixTexture(): Nullable<RawTexture>;
  76156. /**
  76157. * Gets the current hosting scene
  76158. * @returns a scene object
  76159. */
  76160. getScene(): Scene;
  76161. /**
  76162. * Gets a string representing the current skeleton data
  76163. * @param fullDetails defines a boolean indicating if we want a verbose version
  76164. * @returns a string representing the current skeleton data
  76165. */
  76166. toString(fullDetails?: boolean): string;
  76167. /**
  76168. * Get bone's index searching by name
  76169. * @param name defines bone's name to search for
  76170. * @return the indice of the bone. Returns -1 if not found
  76171. */
  76172. getBoneIndexByName(name: string): number;
  76173. /**
  76174. * Creater a new animation range
  76175. * @param name defines the name of the range
  76176. * @param from defines the start key
  76177. * @param to defines the end key
  76178. */
  76179. createAnimationRange(name: string, from: number, to: number): void;
  76180. /**
  76181. * Delete a specific animation range
  76182. * @param name defines the name of the range
  76183. * @param deleteFrames defines if frames must be removed as well
  76184. */
  76185. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76186. /**
  76187. * Gets a specific animation range
  76188. * @param name defines the name of the range to look for
  76189. * @returns the requested animation range or null if not found
  76190. */
  76191. getAnimationRange(name: string): Nullable<AnimationRange>;
  76192. /**
  76193. * Gets the list of all animation ranges defined on this skeleton
  76194. * @returns an array
  76195. */
  76196. getAnimationRanges(): Nullable<AnimationRange>[];
  76197. /**
  76198. * Copy animation range from a source skeleton.
  76199. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76200. * @param source defines the source skeleton
  76201. * @param name defines the name of the range to copy
  76202. * @param rescaleAsRequired defines if rescaling must be applied if required
  76203. * @returns true if operation was successful
  76204. */
  76205. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76206. /**
  76207. * Forces the skeleton to go to rest pose
  76208. */
  76209. returnToRest(): void;
  76210. private _getHighestAnimationFrame;
  76211. /**
  76212. * Begin a specific animation range
  76213. * @param name defines the name of the range to start
  76214. * @param loop defines if looping must be turned on (false by default)
  76215. * @param speedRatio defines the speed ratio to apply (1 by default)
  76216. * @param onAnimationEnd defines a callback which will be called when animation will end
  76217. * @returns a new animatable
  76218. */
  76219. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76220. /** @hidden */
  76221. _markAsDirty(): void;
  76222. /** @hidden */
  76223. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76224. /** @hidden */
  76225. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76226. private _computeTransformMatrices;
  76227. /**
  76228. * Build all resources required to render a skeleton
  76229. */
  76230. prepare(): void;
  76231. /**
  76232. * Gets the list of animatables currently running for this skeleton
  76233. * @returns an array of animatables
  76234. */
  76235. getAnimatables(): IAnimatable[];
  76236. /**
  76237. * Clone the current skeleton
  76238. * @param name defines the name of the new skeleton
  76239. * @param id defines the id of the enw skeleton
  76240. * @returns the new skeleton
  76241. */
  76242. clone(name: string, id: string): Skeleton;
  76243. /**
  76244. * Enable animation blending for this skeleton
  76245. * @param blendingSpeed defines the blending speed to apply
  76246. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76247. */
  76248. enableBlending(blendingSpeed?: number): void;
  76249. /**
  76250. * Releases all resources associated with the current skeleton
  76251. */
  76252. dispose(): void;
  76253. /**
  76254. * Serialize the skeleton in a JSON object
  76255. * @returns a JSON object
  76256. */
  76257. serialize(): any;
  76258. /**
  76259. * Creates a new skeleton from serialized data
  76260. * @param parsedSkeleton defines the serialized data
  76261. * @param scene defines the hosting scene
  76262. * @returns a new skeleton
  76263. */
  76264. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76265. /**
  76266. * Compute all node absolute transforms
  76267. * @param forceUpdate defines if computation must be done even if cache is up to date
  76268. */
  76269. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76270. /**
  76271. * Gets the root pose matrix
  76272. * @returns a matrix
  76273. */
  76274. getPoseMatrix(): Nullable<Matrix>;
  76275. /**
  76276. * Sorts bones per internal index
  76277. */
  76278. sortBones(): void;
  76279. private _sortBones;
  76280. }
  76281. }
  76282. declare module BABYLON {
  76283. /**
  76284. * Defines a target to use with MorphTargetManager
  76285. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76286. */
  76287. export class MorphTarget implements IAnimatable {
  76288. /** defines the name of the target */
  76289. name: string;
  76290. /**
  76291. * Gets or sets the list of animations
  76292. */
  76293. animations: Animation[];
  76294. private _scene;
  76295. private _positions;
  76296. private _normals;
  76297. private _tangents;
  76298. private _influence;
  76299. /**
  76300. * Observable raised when the influence changes
  76301. */
  76302. onInfluenceChanged: Observable<boolean>;
  76303. /** @hidden */
  76304. _onDataLayoutChanged: Observable<void>;
  76305. /**
  76306. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76307. */
  76308. influence: number;
  76309. /**
  76310. * Gets or sets the id of the morph Target
  76311. */
  76312. id: string;
  76313. private _animationPropertiesOverride;
  76314. /**
  76315. * Gets or sets the animation properties override
  76316. */
  76317. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76318. /**
  76319. * Creates a new MorphTarget
  76320. * @param name defines the name of the target
  76321. * @param influence defines the influence to use
  76322. * @param scene defines the scene the morphtarget belongs to
  76323. */
  76324. constructor(
  76325. /** defines the name of the target */
  76326. name: string, influence?: number, scene?: Nullable<Scene>);
  76327. /**
  76328. * Gets a boolean defining if the target contains position data
  76329. */
  76330. readonly hasPositions: boolean;
  76331. /**
  76332. * Gets a boolean defining if the target contains normal data
  76333. */
  76334. readonly hasNormals: boolean;
  76335. /**
  76336. * Gets a boolean defining if the target contains tangent data
  76337. */
  76338. readonly hasTangents: boolean;
  76339. /**
  76340. * Affects position data to this target
  76341. * @param data defines the position data to use
  76342. */
  76343. setPositions(data: Nullable<FloatArray>): void;
  76344. /**
  76345. * Gets the position data stored in this target
  76346. * @returns a FloatArray containing the position data (or null if not present)
  76347. */
  76348. getPositions(): Nullable<FloatArray>;
  76349. /**
  76350. * Affects normal data to this target
  76351. * @param data defines the normal data to use
  76352. */
  76353. setNormals(data: Nullable<FloatArray>): void;
  76354. /**
  76355. * Gets the normal data stored in this target
  76356. * @returns a FloatArray containing the normal data (or null if not present)
  76357. */
  76358. getNormals(): Nullable<FloatArray>;
  76359. /**
  76360. * Affects tangent data to this target
  76361. * @param data defines the tangent data to use
  76362. */
  76363. setTangents(data: Nullable<FloatArray>): void;
  76364. /**
  76365. * Gets the tangent data stored in this target
  76366. * @returns a FloatArray containing the tangent data (or null if not present)
  76367. */
  76368. getTangents(): Nullable<FloatArray>;
  76369. /**
  76370. * Serializes the current target into a Serialization object
  76371. * @returns the serialized object
  76372. */
  76373. serialize(): any;
  76374. /**
  76375. * Returns the string "MorphTarget"
  76376. * @returns "MorphTarget"
  76377. */
  76378. getClassName(): string;
  76379. /**
  76380. * Creates a new target from serialized data
  76381. * @param serializationObject defines the serialized data to use
  76382. * @returns a new MorphTarget
  76383. */
  76384. static Parse(serializationObject: any): MorphTarget;
  76385. /**
  76386. * Creates a MorphTarget from mesh data
  76387. * @param mesh defines the source mesh
  76388. * @param name defines the name to use for the new target
  76389. * @param influence defines the influence to attach to the target
  76390. * @returns a new MorphTarget
  76391. */
  76392. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76393. }
  76394. }
  76395. declare module BABYLON {
  76396. /**
  76397. * This class is used to deform meshes using morphing between different targets
  76398. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76399. */
  76400. export class MorphTargetManager {
  76401. private _targets;
  76402. private _targetInfluenceChangedObservers;
  76403. private _targetDataLayoutChangedObservers;
  76404. private _activeTargets;
  76405. private _scene;
  76406. private _influences;
  76407. private _supportsNormals;
  76408. private _supportsTangents;
  76409. private _vertexCount;
  76410. private _uniqueId;
  76411. private _tempInfluences;
  76412. /**
  76413. * Creates a new MorphTargetManager
  76414. * @param scene defines the current scene
  76415. */
  76416. constructor(scene?: Nullable<Scene>);
  76417. /**
  76418. * Gets the unique ID of this manager
  76419. */
  76420. readonly uniqueId: number;
  76421. /**
  76422. * Gets the number of vertices handled by this manager
  76423. */
  76424. readonly vertexCount: number;
  76425. /**
  76426. * Gets a boolean indicating if this manager supports morphing of normals
  76427. */
  76428. readonly supportsNormals: boolean;
  76429. /**
  76430. * Gets a boolean indicating if this manager supports morphing of tangents
  76431. */
  76432. readonly supportsTangents: boolean;
  76433. /**
  76434. * Gets the number of targets stored in this manager
  76435. */
  76436. readonly numTargets: number;
  76437. /**
  76438. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76439. */
  76440. readonly numInfluencers: number;
  76441. /**
  76442. * Gets the list of influences (one per target)
  76443. */
  76444. readonly influences: Float32Array;
  76445. /**
  76446. * Gets the active target at specified index. An active target is a target with an influence > 0
  76447. * @param index defines the index to check
  76448. * @returns the requested target
  76449. */
  76450. getActiveTarget(index: number): MorphTarget;
  76451. /**
  76452. * Gets the target at specified index
  76453. * @param index defines the index to check
  76454. * @returns the requested target
  76455. */
  76456. getTarget(index: number): MorphTarget;
  76457. /**
  76458. * Add a new target to this manager
  76459. * @param target defines the target to add
  76460. */
  76461. addTarget(target: MorphTarget): void;
  76462. /**
  76463. * Removes a target from the manager
  76464. * @param target defines the target to remove
  76465. */
  76466. removeTarget(target: MorphTarget): void;
  76467. /**
  76468. * Serializes the current manager into a Serialization object
  76469. * @returns the serialized object
  76470. */
  76471. serialize(): any;
  76472. private _syncActiveTargets;
  76473. /**
  76474. * Syncrhonize the targets with all the meshes using this morph target manager
  76475. */
  76476. synchronize(): void;
  76477. /**
  76478. * Creates a new MorphTargetManager from serialized data
  76479. * @param serializationObject defines the serialized data
  76480. * @param scene defines the hosting scene
  76481. * @returns the new MorphTargetManager
  76482. */
  76483. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76484. }
  76485. }
  76486. declare module BABYLON {
  76487. /**
  76488. * Mesh representing the gorund
  76489. */
  76490. export class GroundMesh extends Mesh {
  76491. /** If octree should be generated */
  76492. generateOctree: boolean;
  76493. private _heightQuads;
  76494. /** @hidden */
  76495. _subdivisionsX: number;
  76496. /** @hidden */
  76497. _subdivisionsY: number;
  76498. /** @hidden */
  76499. _width: number;
  76500. /** @hidden */
  76501. _height: number;
  76502. /** @hidden */
  76503. _minX: number;
  76504. /** @hidden */
  76505. _maxX: number;
  76506. /** @hidden */
  76507. _minZ: number;
  76508. /** @hidden */
  76509. _maxZ: number;
  76510. constructor(name: string, scene: Scene);
  76511. /**
  76512. * "GroundMesh"
  76513. * @returns "GroundMesh"
  76514. */
  76515. getClassName(): string;
  76516. /**
  76517. * The minimum of x and y subdivisions
  76518. */
  76519. readonly subdivisions: number;
  76520. /**
  76521. * X subdivisions
  76522. */
  76523. readonly subdivisionsX: number;
  76524. /**
  76525. * Y subdivisions
  76526. */
  76527. readonly subdivisionsY: number;
  76528. /**
  76529. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76530. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76531. * @param chunksCount the number of subdivisions for x and y
  76532. * @param octreeBlocksSize (Default: 32)
  76533. */
  76534. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76535. /**
  76536. * Returns a height (y) value in the Worl system :
  76537. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76538. * @param x x coordinate
  76539. * @param z z coordinate
  76540. * @returns the ground y position if (x, z) are outside the ground surface.
  76541. */
  76542. getHeightAtCoordinates(x: number, z: number): number;
  76543. /**
  76544. * Returns a normalized vector (Vector3) orthogonal to the ground
  76545. * at the ground coordinates (x, z) expressed in the World system.
  76546. * @param x x coordinate
  76547. * @param z z coordinate
  76548. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76549. */
  76550. getNormalAtCoordinates(x: number, z: number): Vector3;
  76551. /**
  76552. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76553. * at the ground coordinates (x, z) expressed in the World system.
  76554. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76555. * @param x x coordinate
  76556. * @param z z coordinate
  76557. * @param ref vector to store the result
  76558. * @returns the GroundMesh.
  76559. */
  76560. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76561. /**
  76562. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76563. * if the ground has been updated.
  76564. * This can be used in the render loop.
  76565. * @returns the GroundMesh.
  76566. */
  76567. updateCoordinateHeights(): GroundMesh;
  76568. private _getFacetAt;
  76569. private _initHeightQuads;
  76570. private _computeHeightQuads;
  76571. /**
  76572. * Serializes this ground mesh
  76573. * @param serializationObject object to write serialization to
  76574. */
  76575. serialize(serializationObject: any): void;
  76576. /**
  76577. * Parses a serialized ground mesh
  76578. * @param parsedMesh the serialized mesh
  76579. * @param scene the scene to create the ground mesh in
  76580. * @returns the created ground mesh
  76581. */
  76582. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76583. }
  76584. }
  76585. declare module BABYLON {
  76586. /**
  76587. * Interface for Physics-Joint data
  76588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76589. */
  76590. export interface PhysicsJointData {
  76591. /**
  76592. * The main pivot of the joint
  76593. */
  76594. mainPivot?: Vector3;
  76595. /**
  76596. * The connected pivot of the joint
  76597. */
  76598. connectedPivot?: Vector3;
  76599. /**
  76600. * The main axis of the joint
  76601. */
  76602. mainAxis?: Vector3;
  76603. /**
  76604. * The connected axis of the joint
  76605. */
  76606. connectedAxis?: Vector3;
  76607. /**
  76608. * The collision of the joint
  76609. */
  76610. collision?: boolean;
  76611. /**
  76612. * Native Oimo/Cannon/Energy data
  76613. */
  76614. nativeParams?: any;
  76615. }
  76616. /**
  76617. * This is a holder class for the physics joint created by the physics plugin
  76618. * It holds a set of functions to control the underlying joint
  76619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76620. */
  76621. export class PhysicsJoint {
  76622. /**
  76623. * The type of the physics joint
  76624. */
  76625. type: number;
  76626. /**
  76627. * The data for the physics joint
  76628. */
  76629. jointData: PhysicsJointData;
  76630. private _physicsJoint;
  76631. protected _physicsPlugin: IPhysicsEnginePlugin;
  76632. /**
  76633. * Initializes the physics joint
  76634. * @param type The type of the physics joint
  76635. * @param jointData The data for the physics joint
  76636. */
  76637. constructor(
  76638. /**
  76639. * The type of the physics joint
  76640. */
  76641. type: number,
  76642. /**
  76643. * The data for the physics joint
  76644. */
  76645. jointData: PhysicsJointData);
  76646. /**
  76647. * Gets the physics joint
  76648. */
  76649. /**
  76650. * Sets the physics joint
  76651. */
  76652. physicsJoint: any;
  76653. /**
  76654. * Sets the physics plugin
  76655. */
  76656. physicsPlugin: IPhysicsEnginePlugin;
  76657. /**
  76658. * Execute a function that is physics-plugin specific.
  76659. * @param {Function} func the function that will be executed.
  76660. * It accepts two parameters: the physics world and the physics joint
  76661. */
  76662. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76663. /**
  76664. * Distance-Joint type
  76665. */
  76666. static DistanceJoint: number;
  76667. /**
  76668. * Hinge-Joint type
  76669. */
  76670. static HingeJoint: number;
  76671. /**
  76672. * Ball-and-Socket joint type
  76673. */
  76674. static BallAndSocketJoint: number;
  76675. /**
  76676. * Wheel-Joint type
  76677. */
  76678. static WheelJoint: number;
  76679. /**
  76680. * Slider-Joint type
  76681. */
  76682. static SliderJoint: number;
  76683. /**
  76684. * Prismatic-Joint type
  76685. */
  76686. static PrismaticJoint: number;
  76687. /**
  76688. * Universal-Joint type
  76689. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76690. */
  76691. static UniversalJoint: number;
  76692. /**
  76693. * Hinge-Joint 2 type
  76694. */
  76695. static Hinge2Joint: number;
  76696. /**
  76697. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76698. */
  76699. static PointToPointJoint: number;
  76700. /**
  76701. * Spring-Joint type
  76702. */
  76703. static SpringJoint: number;
  76704. /**
  76705. * Lock-Joint type
  76706. */
  76707. static LockJoint: number;
  76708. }
  76709. /**
  76710. * A class representing a physics distance joint
  76711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76712. */
  76713. export class DistanceJoint extends PhysicsJoint {
  76714. /**
  76715. *
  76716. * @param jointData The data for the Distance-Joint
  76717. */
  76718. constructor(jointData: DistanceJointData);
  76719. /**
  76720. * Update the predefined distance.
  76721. * @param maxDistance The maximum preferred distance
  76722. * @param minDistance The minimum preferred distance
  76723. */
  76724. updateDistance(maxDistance: number, minDistance?: number): void;
  76725. }
  76726. /**
  76727. * Represents a Motor-Enabled Joint
  76728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76729. */
  76730. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76731. /**
  76732. * Initializes the Motor-Enabled Joint
  76733. * @param type The type of the joint
  76734. * @param jointData The physica joint data for the joint
  76735. */
  76736. constructor(type: number, jointData: PhysicsJointData);
  76737. /**
  76738. * Set the motor values.
  76739. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76740. * @param force the force to apply
  76741. * @param maxForce max force for this motor.
  76742. */
  76743. setMotor(force?: number, maxForce?: number): void;
  76744. /**
  76745. * Set the motor's limits.
  76746. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76747. * @param upperLimit The upper limit of the motor
  76748. * @param lowerLimit The lower limit of the motor
  76749. */
  76750. setLimit(upperLimit: number, lowerLimit?: number): void;
  76751. }
  76752. /**
  76753. * This class represents a single physics Hinge-Joint
  76754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76755. */
  76756. export class HingeJoint extends MotorEnabledJoint {
  76757. /**
  76758. * Initializes the Hinge-Joint
  76759. * @param jointData The joint data for the Hinge-Joint
  76760. */
  76761. constructor(jointData: PhysicsJointData);
  76762. /**
  76763. * Set the motor values.
  76764. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76765. * @param {number} force the force to apply
  76766. * @param {number} maxForce max force for this motor.
  76767. */
  76768. setMotor(force?: number, maxForce?: number): void;
  76769. /**
  76770. * Set the motor's limits.
  76771. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76772. * @param upperLimit The upper limit of the motor
  76773. * @param lowerLimit The lower limit of the motor
  76774. */
  76775. setLimit(upperLimit: number, lowerLimit?: number): void;
  76776. }
  76777. /**
  76778. * This class represents a dual hinge physics joint (same as wheel joint)
  76779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76780. */
  76781. export class Hinge2Joint extends MotorEnabledJoint {
  76782. /**
  76783. * Initializes the Hinge2-Joint
  76784. * @param jointData The joint data for the Hinge2-Joint
  76785. */
  76786. constructor(jointData: PhysicsJointData);
  76787. /**
  76788. * Set the motor values.
  76789. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76790. * @param {number} targetSpeed the speed the motor is to reach
  76791. * @param {number} maxForce max force for this motor.
  76792. * @param {motorIndex} the motor's index, 0 or 1.
  76793. */
  76794. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76795. /**
  76796. * Set the motor limits.
  76797. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76798. * @param {number} upperLimit the upper limit
  76799. * @param {number} lowerLimit lower limit
  76800. * @param {motorIndex} the motor's index, 0 or 1.
  76801. */
  76802. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76803. }
  76804. /**
  76805. * Interface for a motor enabled joint
  76806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76807. */
  76808. export interface IMotorEnabledJoint {
  76809. /**
  76810. * Physics joint
  76811. */
  76812. physicsJoint: any;
  76813. /**
  76814. * Sets the motor of the motor-enabled joint
  76815. * @param force The force of the motor
  76816. * @param maxForce The maximum force of the motor
  76817. * @param motorIndex The index of the motor
  76818. */
  76819. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76820. /**
  76821. * Sets the limit of the motor
  76822. * @param upperLimit The upper limit of the motor
  76823. * @param lowerLimit The lower limit of the motor
  76824. * @param motorIndex The index of the motor
  76825. */
  76826. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76827. }
  76828. /**
  76829. * Joint data for a Distance-Joint
  76830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76831. */
  76832. export interface DistanceJointData extends PhysicsJointData {
  76833. /**
  76834. * Max distance the 2 joint objects can be apart
  76835. */
  76836. maxDistance: number;
  76837. }
  76838. /**
  76839. * Joint data from a spring joint
  76840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76841. */
  76842. export interface SpringJointData extends PhysicsJointData {
  76843. /**
  76844. * Length of the spring
  76845. */
  76846. length: number;
  76847. /**
  76848. * Stiffness of the spring
  76849. */
  76850. stiffness: number;
  76851. /**
  76852. * Damping of the spring
  76853. */
  76854. damping: number;
  76855. /** this callback will be called when applying the force to the impostors. */
  76856. forceApplicationCallback: () => void;
  76857. }
  76858. }
  76859. declare module BABYLON {
  76860. /**
  76861. * Interface used to describe a physics joint
  76862. */
  76863. export interface PhysicsImpostorJoint {
  76864. /** Defines the main impostor to which the joint is linked */
  76865. mainImpostor: PhysicsImpostor;
  76866. /** Defines the impostor that is connected to the main impostor using this joint */
  76867. connectedImpostor: PhysicsImpostor;
  76868. /** Defines the joint itself */
  76869. joint: PhysicsJoint;
  76870. }
  76871. /** @hidden */
  76872. export interface IPhysicsEnginePlugin {
  76873. world: any;
  76874. name: string;
  76875. setGravity(gravity: Vector3): void;
  76876. setTimeStep(timeStep: number): void;
  76877. getTimeStep(): number;
  76878. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76879. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76880. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76881. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76882. removePhysicsBody(impostor: PhysicsImpostor): void;
  76883. generateJoint(joint: PhysicsImpostorJoint): void;
  76884. removeJoint(joint: PhysicsImpostorJoint): void;
  76885. isSupported(): boolean;
  76886. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76887. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76888. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76889. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76890. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76891. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76892. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76893. getBodyMass(impostor: PhysicsImpostor): number;
  76894. getBodyFriction(impostor: PhysicsImpostor): number;
  76895. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76896. getBodyRestitution(impostor: PhysicsImpostor): number;
  76897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76898. sleepBody(impostor: PhysicsImpostor): void;
  76899. wakeUpBody(impostor: PhysicsImpostor): void;
  76900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76901. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76902. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76903. getRadius(impostor: PhysicsImpostor): number;
  76904. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76905. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76906. dispose(): void;
  76907. }
  76908. /**
  76909. * Interface used to define a physics engine
  76910. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76911. */
  76912. export interface IPhysicsEngine {
  76913. /**
  76914. * Gets the gravity vector used by the simulation
  76915. */
  76916. gravity: Vector3;
  76917. /**
  76918. * Sets the gravity vector used by the simulation
  76919. * @param gravity defines the gravity vector to use
  76920. */
  76921. setGravity(gravity: Vector3): void;
  76922. /**
  76923. * Set the time step of the physics engine.
  76924. * Default is 1/60.
  76925. * To slow it down, enter 1/600 for example.
  76926. * To speed it up, 1/30
  76927. * @param newTimeStep the new timestep to apply to this world.
  76928. */
  76929. setTimeStep(newTimeStep: number): void;
  76930. /**
  76931. * Get the time step of the physics engine.
  76932. * @returns the current time step
  76933. */
  76934. getTimeStep(): number;
  76935. /**
  76936. * Release all resources
  76937. */
  76938. dispose(): void;
  76939. /**
  76940. * Gets the name of the current physics plugin
  76941. * @returns the name of the plugin
  76942. */
  76943. getPhysicsPluginName(): string;
  76944. /**
  76945. * Adding a new impostor for the impostor tracking.
  76946. * This will be done by the impostor itself.
  76947. * @param impostor the impostor to add
  76948. */
  76949. addImpostor(impostor: PhysicsImpostor): void;
  76950. /**
  76951. * Remove an impostor from the engine.
  76952. * This impostor and its mesh will not longer be updated by the physics engine.
  76953. * @param impostor the impostor to remove
  76954. */
  76955. removeImpostor(impostor: PhysicsImpostor): void;
  76956. /**
  76957. * Add a joint to the physics engine
  76958. * @param mainImpostor defines the main impostor to which the joint is added.
  76959. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76960. * @param joint defines the joint that will connect both impostors.
  76961. */
  76962. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76963. /**
  76964. * Removes a joint from the simulation
  76965. * @param mainImpostor defines the impostor used with the joint
  76966. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76967. * @param joint defines the joint to remove
  76968. */
  76969. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76970. /**
  76971. * Gets the current plugin used to run the simulation
  76972. * @returns current plugin
  76973. */
  76974. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76975. /**
  76976. * Gets the list of physic impostors
  76977. * @returns an array of PhysicsImpostor
  76978. */
  76979. getImpostors(): Array<PhysicsImpostor>;
  76980. /**
  76981. * Gets the impostor for a physics enabled object
  76982. * @param object defines the object impersonated by the impostor
  76983. * @returns the PhysicsImpostor or null if not found
  76984. */
  76985. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76986. /**
  76987. * Gets the impostor for a physics body object
  76988. * @param body defines physics body used by the impostor
  76989. * @returns the PhysicsImpostor or null if not found
  76990. */
  76991. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76992. /**
  76993. * Called by the scene. No need to call it.
  76994. * @param delta defines the timespam between frames
  76995. */
  76996. _step(delta: number): void;
  76997. }
  76998. }
  76999. declare module BABYLON {
  77000. /**
  77001. * The interface for the physics imposter parameters
  77002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77003. */
  77004. export interface PhysicsImpostorParameters {
  77005. /**
  77006. * The mass of the physics imposter
  77007. */
  77008. mass: number;
  77009. /**
  77010. * The friction of the physics imposter
  77011. */
  77012. friction?: number;
  77013. /**
  77014. * The coefficient of restitution of the physics imposter
  77015. */
  77016. restitution?: number;
  77017. /**
  77018. * The native options of the physics imposter
  77019. */
  77020. nativeOptions?: any;
  77021. /**
  77022. * Specifies if the parent should be ignored
  77023. */
  77024. ignoreParent?: boolean;
  77025. /**
  77026. * Specifies if bi-directional transformations should be disabled
  77027. */
  77028. disableBidirectionalTransformation?: boolean;
  77029. }
  77030. /**
  77031. * Interface for a physics-enabled object
  77032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77033. */
  77034. export interface IPhysicsEnabledObject {
  77035. /**
  77036. * The position of the physics-enabled object
  77037. */
  77038. position: Vector3;
  77039. /**
  77040. * The rotation of the physics-enabled object
  77041. */
  77042. rotationQuaternion: Nullable<Quaternion>;
  77043. /**
  77044. * The scale of the physics-enabled object
  77045. */
  77046. scaling: Vector3;
  77047. /**
  77048. * The rotation of the physics-enabled object
  77049. */
  77050. rotation?: Vector3;
  77051. /**
  77052. * The parent of the physics-enabled object
  77053. */
  77054. parent?: any;
  77055. /**
  77056. * The bounding info of the physics-enabled object
  77057. * @returns The bounding info of the physics-enabled object
  77058. */
  77059. getBoundingInfo(): BoundingInfo;
  77060. /**
  77061. * Computes the world matrix
  77062. * @param force Specifies if the world matrix should be computed by force
  77063. * @returns A world matrix
  77064. */
  77065. computeWorldMatrix(force: boolean): Matrix;
  77066. /**
  77067. * Gets the world matrix
  77068. * @returns A world matrix
  77069. */
  77070. getWorldMatrix?(): Matrix;
  77071. /**
  77072. * Gets the child meshes
  77073. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77074. * @returns An array of abstract meshes
  77075. */
  77076. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77077. /**
  77078. * Gets the vertex data
  77079. * @param kind The type of vertex data
  77080. * @returns A nullable array of numbers, or a float32 array
  77081. */
  77082. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77083. /**
  77084. * Gets the indices from the mesh
  77085. * @returns A nullable array of index arrays
  77086. */
  77087. getIndices?(): Nullable<IndicesArray>;
  77088. /**
  77089. * Gets the scene from the mesh
  77090. * @returns the indices array or null
  77091. */
  77092. getScene?(): Scene;
  77093. /**
  77094. * Gets the absolute position from the mesh
  77095. * @returns the absolute position
  77096. */
  77097. getAbsolutePosition(): Vector3;
  77098. /**
  77099. * Gets the absolute pivot point from the mesh
  77100. * @returns the absolute pivot point
  77101. */
  77102. getAbsolutePivotPoint(): Vector3;
  77103. /**
  77104. * Rotates the mesh
  77105. * @param axis The axis of rotation
  77106. * @param amount The amount of rotation
  77107. * @param space The space of the rotation
  77108. * @returns The rotation transform node
  77109. */
  77110. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77111. /**
  77112. * Translates the mesh
  77113. * @param axis The axis of translation
  77114. * @param distance The distance of translation
  77115. * @param space The space of the translation
  77116. * @returns The transform node
  77117. */
  77118. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77119. /**
  77120. * Sets the absolute position of the mesh
  77121. * @param absolutePosition The absolute position of the mesh
  77122. * @returns The transform node
  77123. */
  77124. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77125. /**
  77126. * Gets the class name of the mesh
  77127. * @returns The class name
  77128. */
  77129. getClassName(): string;
  77130. }
  77131. /**
  77132. * Represents a physics imposter
  77133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77134. */
  77135. export class PhysicsImpostor {
  77136. /**
  77137. * The physics-enabled object used as the physics imposter
  77138. */
  77139. object: IPhysicsEnabledObject;
  77140. /**
  77141. * The type of the physics imposter
  77142. */
  77143. type: number;
  77144. private _options;
  77145. private _scene?;
  77146. /**
  77147. * The default object size of the imposter
  77148. */
  77149. static DEFAULT_OBJECT_SIZE: Vector3;
  77150. /**
  77151. * The identity quaternion of the imposter
  77152. */
  77153. static IDENTITY_QUATERNION: Quaternion;
  77154. /** @hidden */
  77155. _pluginData: any;
  77156. private _physicsEngine;
  77157. private _physicsBody;
  77158. private _bodyUpdateRequired;
  77159. private _onBeforePhysicsStepCallbacks;
  77160. private _onAfterPhysicsStepCallbacks;
  77161. /** @hidden */
  77162. _onPhysicsCollideCallbacks: Array<{
  77163. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77164. otherImpostors: Array<PhysicsImpostor>;
  77165. }>;
  77166. private _deltaPosition;
  77167. private _deltaRotation;
  77168. private _deltaRotationConjugated;
  77169. private _parent;
  77170. private _isDisposed;
  77171. private static _tmpVecs;
  77172. private static _tmpQuat;
  77173. /**
  77174. * Specifies if the physics imposter is disposed
  77175. */
  77176. readonly isDisposed: boolean;
  77177. /**
  77178. * Gets the mass of the physics imposter
  77179. */
  77180. mass: number;
  77181. /**
  77182. * Gets the coefficient of friction
  77183. */
  77184. /**
  77185. * Sets the coefficient of friction
  77186. */
  77187. friction: number;
  77188. /**
  77189. * Gets the coefficient of restitution
  77190. */
  77191. /**
  77192. * Sets the coefficient of restitution
  77193. */
  77194. restitution: number;
  77195. /**
  77196. * The unique id of the physics imposter
  77197. * set by the physics engine when adding this impostor to the array
  77198. */
  77199. uniqueId: number;
  77200. private _joints;
  77201. /**
  77202. * Initializes the physics imposter
  77203. * @param object The physics-enabled object used as the physics imposter
  77204. * @param type The type of the physics imposter
  77205. * @param _options The options for the physics imposter
  77206. * @param _scene The Babylon scene
  77207. */
  77208. constructor(
  77209. /**
  77210. * The physics-enabled object used as the physics imposter
  77211. */
  77212. object: IPhysicsEnabledObject,
  77213. /**
  77214. * The type of the physics imposter
  77215. */
  77216. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77217. /**
  77218. * This function will completly initialize this impostor.
  77219. * It will create a new body - but only if this mesh has no parent.
  77220. * If it has, this impostor will not be used other than to define the impostor
  77221. * of the child mesh.
  77222. * @hidden
  77223. */
  77224. _init(): void;
  77225. private _getPhysicsParent;
  77226. /**
  77227. * Should a new body be generated.
  77228. * @returns boolean specifying if body initialization is required
  77229. */
  77230. isBodyInitRequired(): boolean;
  77231. /**
  77232. * Sets the updated scaling
  77233. * @param updated Specifies if the scaling is updated
  77234. */
  77235. setScalingUpdated(): void;
  77236. /**
  77237. * Force a regeneration of this or the parent's impostor's body.
  77238. * Use under cautious - This will remove all joints already implemented.
  77239. */
  77240. forceUpdate(): void;
  77241. /**
  77242. * Gets the body that holds this impostor. Either its own, or its parent.
  77243. */
  77244. /**
  77245. * Set the physics body. Used mainly by the physics engine/plugin
  77246. */
  77247. physicsBody: any;
  77248. /**
  77249. * Get the parent of the physics imposter
  77250. * @returns Physics imposter or null
  77251. */
  77252. /**
  77253. * Sets the parent of the physics imposter
  77254. */
  77255. parent: Nullable<PhysicsImpostor>;
  77256. /**
  77257. * Resets the update flags
  77258. */
  77259. resetUpdateFlags(): void;
  77260. /**
  77261. * Gets the object extend size
  77262. * @returns the object extend size
  77263. */
  77264. getObjectExtendSize(): Vector3;
  77265. /**
  77266. * Gets the object center
  77267. * @returns The object center
  77268. */
  77269. getObjectCenter(): Vector3;
  77270. /**
  77271. * Get a specific parametes from the options parameter
  77272. * @param paramName The object parameter name
  77273. * @returns The object parameter
  77274. */
  77275. getParam(paramName: string): any;
  77276. /**
  77277. * Sets a specific parameter in the options given to the physics plugin
  77278. * @param paramName The parameter name
  77279. * @param value The value of the parameter
  77280. */
  77281. setParam(paramName: string, value: number): void;
  77282. /**
  77283. * Specifically change the body's mass option. Won't recreate the physics body object
  77284. * @param mass The mass of the physics imposter
  77285. */
  77286. setMass(mass: number): void;
  77287. /**
  77288. * Gets the linear velocity
  77289. * @returns linear velocity or null
  77290. */
  77291. getLinearVelocity(): Nullable<Vector3>;
  77292. /**
  77293. * Sets the linear velocity
  77294. * @param velocity linear velocity or null
  77295. */
  77296. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77297. /**
  77298. * Gets the angular velocity
  77299. * @returns angular velocity or null
  77300. */
  77301. getAngularVelocity(): Nullable<Vector3>;
  77302. /**
  77303. * Sets the angular velocity
  77304. * @param velocity The velocity or null
  77305. */
  77306. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77307. /**
  77308. * Execute a function with the physics plugin native code
  77309. * Provide a function the will have two variables - the world object and the physics body object
  77310. * @param func The function to execute with the physics plugin native code
  77311. */
  77312. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77313. /**
  77314. * Register a function that will be executed before the physics world is stepping forward
  77315. * @param func The function to execute before the physics world is stepped forward
  77316. */
  77317. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77318. /**
  77319. * Unregister a function that will be executed before the physics world is stepping forward
  77320. * @param func The function to execute before the physics world is stepped forward
  77321. */
  77322. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77323. /**
  77324. * Register a function that will be executed after the physics step
  77325. * @param func The function to execute after physics step
  77326. */
  77327. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77328. /**
  77329. * Unregisters a function that will be executed after the physics step
  77330. * @param func The function to execute after physics step
  77331. */
  77332. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77333. /**
  77334. * register a function that will be executed when this impostor collides against a different body
  77335. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77336. * @param func Callback that is executed on collision
  77337. */
  77338. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77339. /**
  77340. * Unregisters the physics imposter on contact
  77341. * @param collideAgainst The physics object to collide against
  77342. * @param func Callback to execute on collision
  77343. */
  77344. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77345. private _tmpQuat;
  77346. private _tmpQuat2;
  77347. /**
  77348. * Get the parent rotation
  77349. * @returns The parent rotation
  77350. */
  77351. getParentsRotation(): Quaternion;
  77352. /**
  77353. * this function is executed by the physics engine.
  77354. */
  77355. beforeStep: () => void;
  77356. /**
  77357. * this function is executed by the physics engine
  77358. */
  77359. afterStep: () => void;
  77360. /**
  77361. * Legacy collision detection event support
  77362. */
  77363. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77364. /**
  77365. * event and body object due to cannon's event-based architecture.
  77366. */
  77367. onCollide: (e: {
  77368. body: any;
  77369. }) => void;
  77370. /**
  77371. * Apply a force
  77372. * @param force The force to apply
  77373. * @param contactPoint The contact point for the force
  77374. * @returns The physics imposter
  77375. */
  77376. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77377. /**
  77378. * Apply an impulse
  77379. * @param force The impulse force
  77380. * @param contactPoint The contact point for the impulse force
  77381. * @returns The physics imposter
  77382. */
  77383. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77384. /**
  77385. * A help function to create a joint
  77386. * @param otherImpostor A physics imposter used to create a joint
  77387. * @param jointType The type of joint
  77388. * @param jointData The data for the joint
  77389. * @returns The physics imposter
  77390. */
  77391. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77392. /**
  77393. * Add a joint to this impostor with a different impostor
  77394. * @param otherImpostor A physics imposter used to add a joint
  77395. * @param joint The joint to add
  77396. * @returns The physics imposter
  77397. */
  77398. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77399. /**
  77400. * Will keep this body still, in a sleep mode.
  77401. * @returns the physics imposter
  77402. */
  77403. sleep(): PhysicsImpostor;
  77404. /**
  77405. * Wake the body up.
  77406. * @returns The physics imposter
  77407. */
  77408. wakeUp(): PhysicsImpostor;
  77409. /**
  77410. * Clones the physics imposter
  77411. * @param newObject The physics imposter clones to this physics-enabled object
  77412. * @returns A nullable physics imposter
  77413. */
  77414. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77415. /**
  77416. * Disposes the physics imposter
  77417. */
  77418. dispose(): void;
  77419. /**
  77420. * Sets the delta position
  77421. * @param position The delta position amount
  77422. */
  77423. setDeltaPosition(position: Vector3): void;
  77424. /**
  77425. * Sets the delta rotation
  77426. * @param rotation The delta rotation amount
  77427. */
  77428. setDeltaRotation(rotation: Quaternion): void;
  77429. /**
  77430. * Gets the box size of the physics imposter and stores the result in the input parameter
  77431. * @param result Stores the box size
  77432. * @returns The physics imposter
  77433. */
  77434. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77435. /**
  77436. * Gets the radius of the physics imposter
  77437. * @returns Radius of the physics imposter
  77438. */
  77439. getRadius(): number;
  77440. /**
  77441. * Sync a bone with this impostor
  77442. * @param bone The bone to sync to the impostor.
  77443. * @param boneMesh The mesh that the bone is influencing.
  77444. * @param jointPivot The pivot of the joint / bone in local space.
  77445. * @param distToJoint Optional distance from the impostor to the joint.
  77446. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77447. */
  77448. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77449. /**
  77450. * Sync impostor to a bone
  77451. * @param bone The bone that the impostor will be synced to.
  77452. * @param boneMesh The mesh that the bone is influencing.
  77453. * @param jointPivot The pivot of the joint / bone in local space.
  77454. * @param distToJoint Optional distance from the impostor to the joint.
  77455. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77456. * @param boneAxis Optional vector3 axis the bone is aligned with
  77457. */
  77458. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77459. /**
  77460. * No-Imposter type
  77461. */
  77462. static NoImpostor: number;
  77463. /**
  77464. * Sphere-Imposter type
  77465. */
  77466. static SphereImpostor: number;
  77467. /**
  77468. * Box-Imposter type
  77469. */
  77470. static BoxImpostor: number;
  77471. /**
  77472. * Plane-Imposter type
  77473. */
  77474. static PlaneImpostor: number;
  77475. /**
  77476. * Mesh-imposter type
  77477. */
  77478. static MeshImpostor: number;
  77479. /**
  77480. * Cylinder-Imposter type
  77481. */
  77482. static CylinderImpostor: number;
  77483. /**
  77484. * Particle-Imposter type
  77485. */
  77486. static ParticleImpostor: number;
  77487. /**
  77488. * Heightmap-Imposter type
  77489. */
  77490. static HeightmapImpostor: number;
  77491. }
  77492. }
  77493. declare module BABYLON {
  77494. /**
  77495. * Class used to represent a specific level of detail of a mesh
  77496. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77497. */
  77498. export class MeshLODLevel {
  77499. /** Defines the distance where this level should star being displayed */
  77500. distance: number;
  77501. /** Defines the mesh to use to render this level */
  77502. mesh: Nullable<Mesh>;
  77503. /**
  77504. * Creates a new LOD level
  77505. * @param distance defines the distance where this level should star being displayed
  77506. * @param mesh defines the mesh to use to render this level
  77507. */
  77508. constructor(
  77509. /** Defines the distance where this level should star being displayed */
  77510. distance: number,
  77511. /** Defines the mesh to use to render this level */
  77512. mesh: Nullable<Mesh>);
  77513. }
  77514. /**
  77515. * @hidden
  77516. **/
  77517. export class _CreationDataStorage {
  77518. closePath?: boolean;
  77519. closeArray?: boolean;
  77520. idx: number[];
  77521. dashSize: number;
  77522. gapSize: number;
  77523. path3D: Path3D;
  77524. pathArray: Vector3[][];
  77525. arc: number;
  77526. radius: number;
  77527. cap: number;
  77528. tessellation: number;
  77529. }
  77530. /**
  77531. * @hidden
  77532. **/
  77533. class _InstanceDataStorage {
  77534. visibleInstances: any;
  77535. renderIdForInstances: number[];
  77536. batchCache: _InstancesBatch;
  77537. instancesBufferSize: number;
  77538. instancesBuffer: Nullable<Buffer>;
  77539. instancesData: Float32Array;
  77540. overridenInstanceCount: number;
  77541. }
  77542. /**
  77543. * @hidden
  77544. **/
  77545. export class _InstancesBatch {
  77546. mustReturn: boolean;
  77547. visibleInstances: Nullable<InstancedMesh[]>[];
  77548. renderSelf: boolean[];
  77549. }
  77550. /**
  77551. * Class used to represent renderable models
  77552. */
  77553. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77554. /**
  77555. * Mesh side orientation : usually the external or front surface
  77556. */
  77557. static readonly FRONTSIDE: number;
  77558. /**
  77559. * Mesh side orientation : usually the internal or back surface
  77560. */
  77561. static readonly BACKSIDE: number;
  77562. /**
  77563. * Mesh side orientation : both internal and external or front and back surfaces
  77564. */
  77565. static readonly DOUBLESIDE: number;
  77566. /**
  77567. * Mesh side orientation : by default, `FRONTSIDE`
  77568. */
  77569. static readonly DEFAULTSIDE: number;
  77570. /**
  77571. * Mesh cap setting : no cap
  77572. */
  77573. static readonly NO_CAP: number;
  77574. /**
  77575. * Mesh cap setting : one cap at the beginning of the mesh
  77576. */
  77577. static readonly CAP_START: number;
  77578. /**
  77579. * Mesh cap setting : one cap at the end of the mesh
  77580. */
  77581. static readonly CAP_END: number;
  77582. /**
  77583. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77584. */
  77585. static readonly CAP_ALL: number;
  77586. /**
  77587. * Gets the default side orientation.
  77588. * @param orientation the orientation to value to attempt to get
  77589. * @returns the default orientation
  77590. * @hidden
  77591. */
  77592. static _GetDefaultSideOrientation(orientation?: number): number;
  77593. private _onBeforeRenderObservable;
  77594. private _onBeforeBindObservable;
  77595. private _onAfterRenderObservable;
  77596. private _onBeforeDrawObservable;
  77597. /**
  77598. * An event triggered before rendering the mesh
  77599. */
  77600. readonly onBeforeRenderObservable: Observable<Mesh>;
  77601. /**
  77602. * An event triggered before binding the mesh
  77603. */
  77604. readonly onBeforeBindObservable: Observable<Mesh>;
  77605. /**
  77606. * An event triggered after rendering the mesh
  77607. */
  77608. readonly onAfterRenderObservable: Observable<Mesh>;
  77609. /**
  77610. * An event triggered before drawing the mesh
  77611. */
  77612. readonly onBeforeDrawObservable: Observable<Mesh>;
  77613. private _onBeforeDrawObserver;
  77614. /**
  77615. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77616. */
  77617. onBeforeDraw: () => void;
  77618. /**
  77619. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77620. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77621. */
  77622. delayLoadState: number;
  77623. /**
  77624. * Gets the list of instances created from this mesh
  77625. * it is not supposed to be modified manually.
  77626. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77627. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77628. */
  77629. instances: InstancedMesh[];
  77630. /**
  77631. * Gets the file containing delay loading data for this mesh
  77632. */
  77633. delayLoadingFile: string;
  77634. /** @hidden */
  77635. _binaryInfo: any;
  77636. private _LODLevels;
  77637. /**
  77638. * User defined function used to change how LOD level selection is done
  77639. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77640. */
  77641. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77642. private _morphTargetManager;
  77643. /**
  77644. * Gets or sets the morph target manager
  77645. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77646. */
  77647. morphTargetManager: Nullable<MorphTargetManager>;
  77648. /** @hidden */
  77649. _creationDataStorage: Nullable<_CreationDataStorage>;
  77650. /** @hidden */
  77651. _geometry: Nullable<Geometry>;
  77652. /** @hidden */
  77653. _delayInfo: Array<string>;
  77654. /** @hidden */
  77655. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77656. /** @hidden */
  77657. _instanceDataStorage: _InstanceDataStorage;
  77658. private _effectiveMaterial;
  77659. /** @hidden */
  77660. _shouldGenerateFlatShading: boolean;
  77661. private _preActivateId;
  77662. /** @hidden */
  77663. _originalBuilderSideOrientation: number;
  77664. /**
  77665. * Use this property to change the original side orientation defined at construction time
  77666. */
  77667. overrideMaterialSideOrientation: Nullable<number>;
  77668. private _areNormalsFrozen;
  77669. private _sourcePositions;
  77670. private _sourceNormals;
  77671. private _source;
  77672. private meshMap;
  77673. /**
  77674. * Gets the source mesh (the one used to clone this one from)
  77675. */
  77676. readonly source: Nullable<Mesh>;
  77677. /**
  77678. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77679. */
  77680. isUnIndexed: boolean;
  77681. /**
  77682. * @constructor
  77683. * @param name The value used by scene.getMeshByName() to do a lookup.
  77684. * @param scene The scene to add this mesh to.
  77685. * @param parent The parent of this mesh, if it has one
  77686. * @param source An optional Mesh from which geometry is shared, cloned.
  77687. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77688. * When false, achieved by calling a clone(), also passing False.
  77689. * This will make creation of children, recursive.
  77690. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77691. */
  77692. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77693. /**
  77694. * Gets the class name
  77695. * @returns the string "Mesh".
  77696. */
  77697. getClassName(): string;
  77698. /** @hidden */
  77699. readonly _isMesh: boolean;
  77700. /**
  77701. * Returns a description of this mesh
  77702. * @param fullDetails define if full details about this mesh must be used
  77703. * @returns a descriptive string representing this mesh
  77704. */
  77705. toString(fullDetails?: boolean): string;
  77706. /** @hidden */
  77707. _unBindEffect(): void;
  77708. /**
  77709. * Gets a boolean indicating if this mesh has LOD
  77710. */
  77711. readonly hasLODLevels: boolean;
  77712. /**
  77713. * Gets the list of MeshLODLevel associated with the current mesh
  77714. * @returns an array of MeshLODLevel
  77715. */
  77716. getLODLevels(): MeshLODLevel[];
  77717. private _sortLODLevels;
  77718. /**
  77719. * Add a mesh as LOD level triggered at the given distance.
  77720. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77721. * @param distance The distance from the center of the object to show this level
  77722. * @param mesh The mesh to be added as LOD level (can be null)
  77723. * @return This mesh (for chaining)
  77724. */
  77725. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77726. /**
  77727. * Returns the LOD level mesh at the passed distance or null if not found.
  77728. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77729. * @param distance The distance from the center of the object to show this level
  77730. * @returns a Mesh or `null`
  77731. */
  77732. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77733. /**
  77734. * Remove a mesh from the LOD array
  77735. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77736. * @param mesh defines the mesh to be removed
  77737. * @return This mesh (for chaining)
  77738. */
  77739. removeLODLevel(mesh: Mesh): Mesh;
  77740. /**
  77741. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77742. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77743. * @param camera defines the camera to use to compute distance
  77744. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77745. * @return This mesh (for chaining)
  77746. */
  77747. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77748. /**
  77749. * Gets the mesh internal Geometry object
  77750. */
  77751. readonly geometry: Nullable<Geometry>;
  77752. /**
  77753. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77754. * @returns the total number of vertices
  77755. */
  77756. getTotalVertices(): number;
  77757. /**
  77758. * Returns the content of an associated vertex buffer
  77759. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77760. * - VertexBuffer.PositionKind
  77761. * - VertexBuffer.UVKind
  77762. * - VertexBuffer.UV2Kind
  77763. * - VertexBuffer.UV3Kind
  77764. * - VertexBuffer.UV4Kind
  77765. * - VertexBuffer.UV5Kind
  77766. * - VertexBuffer.UV6Kind
  77767. * - VertexBuffer.ColorKind
  77768. * - VertexBuffer.MatricesIndicesKind
  77769. * - VertexBuffer.MatricesIndicesExtraKind
  77770. * - VertexBuffer.MatricesWeightsKind
  77771. * - VertexBuffer.MatricesWeightsExtraKind
  77772. * @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
  77773. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77774. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77775. */
  77776. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77777. /**
  77778. * Returns the mesh VertexBuffer object from the requested `kind`
  77779. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77780. * - VertexBuffer.PositionKind
  77781. * - VertexBuffer.UVKind
  77782. * - VertexBuffer.UV2Kind
  77783. * - VertexBuffer.UV3Kind
  77784. * - VertexBuffer.UV4Kind
  77785. * - VertexBuffer.UV5Kind
  77786. * - VertexBuffer.UV6Kind
  77787. * - VertexBuffer.ColorKind
  77788. * - VertexBuffer.MatricesIndicesKind
  77789. * - VertexBuffer.MatricesIndicesExtraKind
  77790. * - VertexBuffer.MatricesWeightsKind
  77791. * - VertexBuffer.MatricesWeightsExtraKind
  77792. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77793. */
  77794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77795. /**
  77796. * Tests if a specific vertex buffer is associated with this mesh
  77797. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77798. * - VertexBuffer.PositionKind
  77799. * - VertexBuffer.UVKind
  77800. * - VertexBuffer.UV2Kind
  77801. * - VertexBuffer.UV3Kind
  77802. * - VertexBuffer.UV4Kind
  77803. * - VertexBuffer.UV5Kind
  77804. * - VertexBuffer.UV6Kind
  77805. * - VertexBuffer.ColorKind
  77806. * - VertexBuffer.MatricesIndicesKind
  77807. * - VertexBuffer.MatricesIndicesExtraKind
  77808. * - VertexBuffer.MatricesWeightsKind
  77809. * - VertexBuffer.MatricesWeightsExtraKind
  77810. * @returns a boolean
  77811. */
  77812. isVerticesDataPresent(kind: string): boolean;
  77813. /**
  77814. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77815. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77816. * - VertexBuffer.PositionKind
  77817. * - VertexBuffer.UVKind
  77818. * - VertexBuffer.UV2Kind
  77819. * - VertexBuffer.UV3Kind
  77820. * - VertexBuffer.UV4Kind
  77821. * - VertexBuffer.UV5Kind
  77822. * - VertexBuffer.UV6Kind
  77823. * - VertexBuffer.ColorKind
  77824. * - VertexBuffer.MatricesIndicesKind
  77825. * - VertexBuffer.MatricesIndicesExtraKind
  77826. * - VertexBuffer.MatricesWeightsKind
  77827. * - VertexBuffer.MatricesWeightsExtraKind
  77828. * @returns a boolean
  77829. */
  77830. isVertexBufferUpdatable(kind: string): boolean;
  77831. /**
  77832. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77833. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77834. * - VertexBuffer.PositionKind
  77835. * - VertexBuffer.UVKind
  77836. * - VertexBuffer.UV2Kind
  77837. * - VertexBuffer.UV3Kind
  77838. * - VertexBuffer.UV4Kind
  77839. * - VertexBuffer.UV5Kind
  77840. * - VertexBuffer.UV6Kind
  77841. * - VertexBuffer.ColorKind
  77842. * - VertexBuffer.MatricesIndicesKind
  77843. * - VertexBuffer.MatricesIndicesExtraKind
  77844. * - VertexBuffer.MatricesWeightsKind
  77845. * - VertexBuffer.MatricesWeightsExtraKind
  77846. * @returns an array of strings
  77847. */
  77848. getVerticesDataKinds(): string[];
  77849. /**
  77850. * Returns a positive integer : the total number of indices in this mesh geometry.
  77851. * @returns the numner of indices or zero if the mesh has no geometry.
  77852. */
  77853. getTotalIndices(): number;
  77854. /**
  77855. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77856. * @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.
  77857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77858. * @returns the indices array or an empty array if the mesh has no geometry
  77859. */
  77860. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77861. readonly isBlocked: boolean;
  77862. /**
  77863. * Determine if the current mesh is ready to be rendered
  77864. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77865. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77866. * @returns true if all associated assets are ready (material, textures, shaders)
  77867. */
  77868. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77869. /**
  77870. * 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.
  77871. */
  77872. readonly areNormalsFrozen: boolean;
  77873. /**
  77874. * 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.
  77875. * @returns the current mesh
  77876. */
  77877. freezeNormals(): Mesh;
  77878. /**
  77879. * 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
  77880. * @returns the current mesh
  77881. */
  77882. unfreezeNormals(): Mesh;
  77883. /**
  77884. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77885. */
  77886. overridenInstanceCount: number;
  77887. /** @hidden */
  77888. _preActivate(): Mesh;
  77889. /** @hidden */
  77890. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77891. /** @hidden */
  77892. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77893. /**
  77894. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77895. * This means the mesh underlying bounding box and sphere are recomputed.
  77896. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77897. * @returns the current mesh
  77898. */
  77899. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77900. /** @hidden */
  77901. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77902. /**
  77903. * This function will subdivide the mesh into multiple submeshes
  77904. * @param count defines the expected number of submeshes
  77905. */
  77906. subdivide(count: number): void;
  77907. /**
  77908. * Copy a FloatArray into a specific associated vertex buffer
  77909. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77910. * - VertexBuffer.PositionKind
  77911. * - VertexBuffer.UVKind
  77912. * - VertexBuffer.UV2Kind
  77913. * - VertexBuffer.UV3Kind
  77914. * - VertexBuffer.UV4Kind
  77915. * - VertexBuffer.UV5Kind
  77916. * - VertexBuffer.UV6Kind
  77917. * - VertexBuffer.ColorKind
  77918. * - VertexBuffer.MatricesIndicesKind
  77919. * - VertexBuffer.MatricesIndicesExtraKind
  77920. * - VertexBuffer.MatricesWeightsKind
  77921. * - VertexBuffer.MatricesWeightsExtraKind
  77922. * @param data defines the data source
  77923. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77924. * @param stride defines the data stride size (can be null)
  77925. * @returns the current mesh
  77926. */
  77927. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77928. /**
  77929. * Flags an associated vertex buffer as updatable
  77930. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77931. * - VertexBuffer.PositionKind
  77932. * - VertexBuffer.UVKind
  77933. * - VertexBuffer.UV2Kind
  77934. * - VertexBuffer.UV3Kind
  77935. * - VertexBuffer.UV4Kind
  77936. * - VertexBuffer.UV5Kind
  77937. * - VertexBuffer.UV6Kind
  77938. * - VertexBuffer.ColorKind
  77939. * - VertexBuffer.MatricesIndicesKind
  77940. * - VertexBuffer.MatricesIndicesExtraKind
  77941. * - VertexBuffer.MatricesWeightsKind
  77942. * - VertexBuffer.MatricesWeightsExtraKind
  77943. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77944. */
  77945. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77946. /**
  77947. * Sets the mesh global Vertex Buffer
  77948. * @param buffer defines the buffer to use
  77949. * @returns the current mesh
  77950. */
  77951. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77952. /**
  77953. * Update a specific associated vertex buffer
  77954. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77955. * - VertexBuffer.PositionKind
  77956. * - VertexBuffer.UVKind
  77957. * - VertexBuffer.UV2Kind
  77958. * - VertexBuffer.UV3Kind
  77959. * - VertexBuffer.UV4Kind
  77960. * - VertexBuffer.UV5Kind
  77961. * - VertexBuffer.UV6Kind
  77962. * - VertexBuffer.ColorKind
  77963. * - VertexBuffer.MatricesIndicesKind
  77964. * - VertexBuffer.MatricesIndicesExtraKind
  77965. * - VertexBuffer.MatricesWeightsKind
  77966. * - VertexBuffer.MatricesWeightsExtraKind
  77967. * @param data defines the data source
  77968. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77969. * @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)
  77970. * @returns the current mesh
  77971. */
  77972. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77973. /**
  77974. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77975. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77976. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77977. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77978. * @returns the current mesh
  77979. */
  77980. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77981. /**
  77982. * Creates a un-shared specific occurence of the geometry for the mesh.
  77983. * @returns the current mesh
  77984. */
  77985. makeGeometryUnique(): Mesh;
  77986. /**
  77987. * Set the index buffer of this mesh
  77988. * @param indices defines the source data
  77989. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77990. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77991. * @returns the current mesh
  77992. */
  77993. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77994. /**
  77995. * Update the current index buffer
  77996. * @param indices defines the source data
  77997. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77998. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  77999. * @returns the current mesh
  78000. */
  78001. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  78002. /**
  78003. * Invert the geometry to move from a right handed system to a left handed one.
  78004. * @returns the current mesh
  78005. */
  78006. toLeftHanded(): Mesh;
  78007. /** @hidden */
  78008. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  78009. /** @hidden */
  78010. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  78011. /**
  78012. * Registers for this mesh a javascript function called just before the rendering process
  78013. * @param func defines the function to call before rendering this mesh
  78014. * @returns the current mesh
  78015. */
  78016. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78017. /**
  78018. * Disposes a previously registered javascript function called before the rendering
  78019. * @param func defines the function to remove
  78020. * @returns the current mesh
  78021. */
  78022. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78023. /**
  78024. * Registers for this mesh a javascript function called just after the rendering is complete
  78025. * @param func defines the function to call after rendering this mesh
  78026. * @returns the current mesh
  78027. */
  78028. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78029. /**
  78030. * Disposes a previously registered javascript function called after the rendering.
  78031. * @param func defines the function to remove
  78032. * @returns the current mesh
  78033. */
  78034. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78035. /** @hidden */
  78036. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78037. /** @hidden */
  78038. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78039. /** @hidden */
  78040. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78041. /**
  78042. * 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
  78043. * @param subMesh defines the subMesh to render
  78044. * @param enableAlphaMode defines if alpha mode can be changed
  78045. * @returns the current mesh
  78046. */
  78047. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78048. private _onBeforeDraw;
  78049. /**
  78050. * Renormalize the mesh and patch it up if there are no weights
  78051. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78052. * However in the case of zero weights then we set just a single influence to 1.
  78053. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78054. */
  78055. cleanMatrixWeights(): void;
  78056. private normalizeSkinFourWeights;
  78057. private normalizeSkinWeightsAndExtra;
  78058. /**
  78059. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78060. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78061. * the user know there was an issue with importing the mesh
  78062. * @returns a validation object with skinned, valid and report string
  78063. */
  78064. validateSkinning(): {
  78065. skinned: boolean;
  78066. valid: boolean;
  78067. report: string;
  78068. };
  78069. /** @hidden */
  78070. _checkDelayState(): Mesh;
  78071. private _queueLoad;
  78072. /**
  78073. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78074. * A mesh is in the frustum if its bounding box intersects the frustum
  78075. * @param frustumPlanes defines the frustum to test
  78076. * @returns true if the mesh is in the frustum planes
  78077. */
  78078. isInFrustum(frustumPlanes: Plane[]): boolean;
  78079. /**
  78080. * Sets the mesh material by the material or multiMaterial `id` property
  78081. * @param id is a string identifying the material or the multiMaterial
  78082. * @returns the current mesh
  78083. */
  78084. setMaterialByID(id: string): Mesh;
  78085. /**
  78086. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78087. * @returns an array of IAnimatable
  78088. */
  78089. getAnimatables(): IAnimatable[];
  78090. /**
  78091. * Modifies the mesh geometry according to the passed transformation matrix.
  78092. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78093. * The mesh normals are modified using the same transformation.
  78094. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78095. * @param transform defines the transform matrix to use
  78096. * @see http://doc.babylonjs.com/resources/baking_transformations
  78097. * @returns the current mesh
  78098. */
  78099. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78100. /**
  78101. * Modifies the mesh geometry according to its own current World Matrix.
  78102. * The mesh World Matrix is then reset.
  78103. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78104. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78105. * @see http://doc.babylonjs.com/resources/baking_transformations
  78106. * @returns the current mesh
  78107. */
  78108. bakeCurrentTransformIntoVertices(): Mesh;
  78109. /** @hidden */
  78110. readonly _positions: Nullable<Vector3[]>;
  78111. /** @hidden */
  78112. _resetPointsArrayCache(): Mesh;
  78113. /** @hidden */
  78114. _generatePointsArray(): boolean;
  78115. /**
  78116. * Returns a new Mesh object generated from the current mesh properties.
  78117. * This method must not get confused with createInstance()
  78118. * @param name is a string, the name given to the new mesh
  78119. * @param newParent can be any Node object (default `null`)
  78120. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78121. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78122. * @returns a new mesh
  78123. */
  78124. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78125. /**
  78126. * Releases resources associated with this mesh.
  78127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78129. */
  78130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78131. /**
  78132. * Modifies the mesh geometry according to a displacement map.
  78133. * 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.
  78134. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78135. * @param url is a string, the URL from the image file is to be downloaded.
  78136. * @param minHeight is the lower limit of the displacement.
  78137. * @param maxHeight is the upper limit of the displacement.
  78138. * @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.
  78139. * @param uvOffset is an optional vector2 used to offset UV.
  78140. * @param uvScale is an optional vector2 used to scale UV.
  78141. * @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.
  78142. * @returns the Mesh.
  78143. */
  78144. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78145. /**
  78146. * Modifies the mesh geometry according to a displacementMap buffer.
  78147. * 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.
  78148. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78149. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78150. * @param heightMapWidth is the width of the buffer image.
  78151. * @param heightMapHeight is the height of the buffer image.
  78152. * @param minHeight is the lower limit of the displacement.
  78153. * @param maxHeight is the upper limit of the displacement.
  78154. * @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.
  78155. * @param uvOffset is an optional vector2 used to offset UV.
  78156. * @param uvScale is an optional vector2 used to scale UV.
  78157. * @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.
  78158. * @returns the Mesh.
  78159. */
  78160. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78161. /**
  78162. * Modify the mesh to get a flat shading rendering.
  78163. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78164. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78165. * @returns current mesh
  78166. */
  78167. convertToFlatShadedMesh(): Mesh;
  78168. /**
  78169. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78170. * In other words, more vertices, no more indices and a single bigger VBO.
  78171. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78172. * @returns current mesh
  78173. */
  78174. convertToUnIndexedMesh(): Mesh;
  78175. /**
  78176. * Inverses facet orientations.
  78177. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78178. * @param flipNormals will also inverts the normals
  78179. * @returns current mesh
  78180. */
  78181. flipFaces(flipNormals?: boolean): Mesh;
  78182. /** @hidden */
  78183. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78184. /** @hidden */
  78185. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78186. /**
  78187. * Creates a new InstancedMesh object from the mesh model.
  78188. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78189. * @param name defines the name of the new instance
  78190. * @returns a new InstancedMesh
  78191. */
  78192. createInstance(name: string): InstancedMesh;
  78193. /**
  78194. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78195. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78196. * @returns the current mesh
  78197. */
  78198. synchronizeInstances(): Mesh;
  78199. /**
  78200. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78201. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78202. * This should be used together with the simplification to avoid disappearing triangles.
  78203. * @param successCallback an optional success callback to be called after the optimization finished.
  78204. * @returns the current mesh
  78205. */
  78206. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78207. /**
  78208. * Serialize current mesh
  78209. * @param serializationObject defines the object which will receive the serialization data
  78210. */
  78211. serialize(serializationObject: any): void;
  78212. /** @hidden */
  78213. _syncGeometryWithMorphTargetManager(): void;
  78214. /** @hidden */
  78215. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78216. /**
  78217. * Returns a new Mesh object parsed from the source provided.
  78218. * @param parsedMesh is the source
  78219. * @param scene defines the hosting scene
  78220. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78221. * @returns a new Mesh
  78222. */
  78223. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78224. /**
  78225. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78226. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78227. * @param name defines the name of the mesh to create
  78228. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78229. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78230. * @param closePath creates a seam between the first and the last points of each path of the path array
  78231. * @param offset is taken in account only if the `pathArray` is containing a single path
  78232. * @param scene defines the hosting scene
  78233. * @param updatable defines if the mesh must be flagged as updatable
  78234. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78235. * @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)
  78236. * @returns a new Mesh
  78237. */
  78238. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78239. /**
  78240. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78241. * @param name defines the name of the mesh to create
  78242. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78243. * @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
  78244. * @param scene defines the hosting scene
  78245. * @param updatable defines if the mesh must be flagged as updatable
  78246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78247. * @returns a new Mesh
  78248. */
  78249. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78250. /**
  78251. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78252. * @param name defines the name of the mesh to create
  78253. * @param size sets the size (float) of each box side (default 1)
  78254. * @param scene defines the hosting scene
  78255. * @param updatable defines if the mesh must be flagged as updatable
  78256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78257. * @returns a new Mesh
  78258. */
  78259. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78260. /**
  78261. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78262. * @param name defines the name of the mesh to create
  78263. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78264. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78265. * @param scene defines the hosting scene
  78266. * @param updatable defines if the mesh must be flagged as updatable
  78267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78268. * @returns a new Mesh
  78269. */
  78270. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78271. /**
  78272. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78273. * @param name defines the name of the mesh to create
  78274. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78275. * @param diameterTop set the top cap diameter (floats, default 1)
  78276. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78277. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78278. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78279. * @param scene defines the hosting scene
  78280. * @param updatable defines if the mesh must be flagged as updatable
  78281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78282. * @returns a new Mesh
  78283. */
  78284. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78285. /**
  78286. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78287. * @param name defines the name of the mesh to create
  78288. * @param diameter sets the diameter size (float) of the torus (default 1)
  78289. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78290. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78291. * @param scene defines the hosting scene
  78292. * @param updatable defines if the mesh must be flagged as updatable
  78293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78294. * @returns a new Mesh
  78295. */
  78296. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78297. /**
  78298. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78299. * @param name defines the name of the mesh to create
  78300. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78301. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78302. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78303. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78304. * @param p the number of windings on X axis (positive integers, default 2)
  78305. * @param q the number of windings on Y axis (positive integers, default 3)
  78306. * @param scene defines the hosting scene
  78307. * @param updatable defines if the mesh must be flagged as updatable
  78308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78309. * @returns a new Mesh
  78310. */
  78311. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78312. /**
  78313. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78314. * @param name defines the name of the mesh to create
  78315. * @param points is an array successive Vector3
  78316. * @param scene defines the hosting scene
  78317. * @param updatable defines if the mesh must be flagged as updatable
  78318. * @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).
  78319. * @returns a new Mesh
  78320. */
  78321. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78322. /**
  78323. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78324. * @param name defines the name of the mesh to create
  78325. * @param points is an array successive Vector3
  78326. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78327. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78328. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78329. * @param scene defines the hosting scene
  78330. * @param updatable defines if the mesh must be flagged as updatable
  78331. * @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)
  78332. * @returns a new Mesh
  78333. */
  78334. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78335. /**
  78336. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78337. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78338. * 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.
  78339. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78340. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78341. * Remember you can only change the shape positions, not their number when updating a polygon.
  78342. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78343. * @param name defines the name of the mesh to create
  78344. * @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
  78345. * @param scene defines the hosting scene
  78346. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78347. * @param updatable defines if the mesh must be flagged as updatable
  78348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78349. * @param earcutInjection can be used to inject your own earcut reference
  78350. * @returns a new Mesh
  78351. */
  78352. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78353. /**
  78354. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78356. * @param name defines the name of the mesh to create
  78357. * @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
  78358. * @param depth defines the height of extrusion
  78359. * @param scene defines the hosting scene
  78360. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78361. * @param updatable defines if the mesh must be flagged as updatable
  78362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78363. * @param earcutInjection can be used to inject your own earcut reference
  78364. * @returns a new Mesh
  78365. */
  78366. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78367. /**
  78368. * Creates an extruded shape mesh.
  78369. * 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
  78370. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78371. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78372. * @param name defines the name of the mesh to create
  78373. * @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
  78374. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78375. * @param scale is the value to scale the shape
  78376. * @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
  78377. * @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
  78378. * @param scene defines the hosting scene
  78379. * @param updatable defines if the mesh must be flagged as updatable
  78380. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78381. * @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)
  78382. * @returns a new Mesh
  78383. */
  78384. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78385. /**
  78386. * Creates an custom extruded shape mesh.
  78387. * The custom extrusion is a parametric shape.
  78388. * It has no predefined shape. Its final shape will depend on the input parameters.
  78389. * Please consider using the same method from the MeshBuilder class instead
  78390. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78391. * @param name defines the name of the mesh to create
  78392. * @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
  78393. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78394. * @param scaleFunction is a custom Javascript function called on each path point
  78395. * @param rotationFunction is a custom Javascript function called on each path point
  78396. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78397. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78398. * @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
  78399. * @param scene defines the hosting scene
  78400. * @param updatable defines if the mesh must be flagged as updatable
  78401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78402. * @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)
  78403. * @returns a new Mesh
  78404. */
  78405. 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;
  78406. /**
  78407. * Creates lathe mesh.
  78408. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78409. * Please consider using the same method from the MeshBuilder class instead
  78410. * @param name defines the name of the mesh to create
  78411. * @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
  78412. * @param radius is the radius value of the lathe
  78413. * @param tessellation is the side number of the lathe.
  78414. * @param scene defines the hosting scene
  78415. * @param updatable defines if the mesh must be flagged as updatable
  78416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78417. * @returns a new Mesh
  78418. */
  78419. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78420. /**
  78421. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78422. * @param name defines the name of the mesh to create
  78423. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78424. * @param scene defines the hosting scene
  78425. * @param updatable defines if the mesh must be flagged as updatable
  78426. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78427. * @returns a new Mesh
  78428. */
  78429. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78430. /**
  78431. * Creates a ground mesh.
  78432. * Please consider using the same method from the MeshBuilder class instead
  78433. * @param name defines the name of the mesh to create
  78434. * @param width set the width of the ground
  78435. * @param height set the height of the ground
  78436. * @param subdivisions sets the number of subdivisions per side
  78437. * @param scene defines the hosting scene
  78438. * @param updatable defines if the mesh must be flagged as updatable
  78439. * @returns a new Mesh
  78440. */
  78441. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78442. /**
  78443. * Creates a tiled ground mesh.
  78444. * Please consider using the same method from the MeshBuilder class instead
  78445. * @param name defines the name of the mesh to create
  78446. * @param xmin set the ground minimum X coordinate
  78447. * @param zmin set the ground minimum Y coordinate
  78448. * @param xmax set the ground maximum X coordinate
  78449. * @param zmax set the ground maximum Z coordinate
  78450. * @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
  78451. * @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
  78452. * @param scene defines the hosting scene
  78453. * @param updatable defines if the mesh must be flagged as updatable
  78454. * @returns a new Mesh
  78455. */
  78456. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78457. w: number;
  78458. h: number;
  78459. }, precision: {
  78460. w: number;
  78461. h: number;
  78462. }, scene: Scene, updatable?: boolean): Mesh;
  78463. /**
  78464. * Creates a ground mesh from a height map.
  78465. * Please consider using the same method from the MeshBuilder class instead
  78466. * @see http://doc.babylonjs.com/babylon101/height_map
  78467. * @param name defines the name of the mesh to create
  78468. * @param url sets the URL of the height map image resource
  78469. * @param width set the ground width size
  78470. * @param height set the ground height size
  78471. * @param subdivisions sets the number of subdivision per side
  78472. * @param minHeight is the minimum altitude on the ground
  78473. * @param maxHeight is the maximum altitude on the ground
  78474. * @param scene defines the hosting scene
  78475. * @param updatable defines if the mesh must be flagged as updatable
  78476. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78477. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78478. * @returns a new Mesh
  78479. */
  78480. 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;
  78481. /**
  78482. * Creates a tube mesh.
  78483. * The tube is a parametric shape.
  78484. * It has no predefined shape. Its final shape will depend on the input parameters.
  78485. * Please consider using the same method from the MeshBuilder class instead
  78486. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78487. * @param name defines the name of the mesh to create
  78488. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78489. * @param radius sets the tube radius size
  78490. * @param tessellation is the number of sides on the tubular surface
  78491. * @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
  78492. * @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
  78493. * @param scene defines the hosting scene
  78494. * @param updatable defines if the mesh must be flagged as updatable
  78495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78496. * @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)
  78497. * @returns a new Mesh
  78498. */
  78499. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78500. (i: number, distance: number): number;
  78501. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78502. /**
  78503. * Creates a polyhedron mesh.
  78504. * Please consider using the same method from the MeshBuilder class instead.
  78505. * * 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
  78506. * * The parameter `size` (positive float, default 1) sets the polygon size
  78507. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78508. * * 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`
  78509. * * 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
  78510. * * 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)`)
  78511. * * 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
  78512. * * 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
  78513. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78514. * * If you create a double-sided mesh, you can choose what parts of 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
  78515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78516. * @param name defines the name of the mesh to create
  78517. * @param options defines the options used to create the mesh
  78518. * @param scene defines the hosting scene
  78519. * @returns a new Mesh
  78520. */
  78521. static CreatePolyhedron(name: string, options: {
  78522. type?: number;
  78523. size?: number;
  78524. sizeX?: number;
  78525. sizeY?: number;
  78526. sizeZ?: number;
  78527. custom?: any;
  78528. faceUV?: Vector4[];
  78529. faceColors?: Color4[];
  78530. updatable?: boolean;
  78531. sideOrientation?: number;
  78532. }, scene: Scene): Mesh;
  78533. /**
  78534. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78535. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78536. * * 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`)
  78537. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78538. * * 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
  78539. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78540. * * If you create a double-sided mesh, you can choose what parts of 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
  78541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78542. * @param name defines the name of the mesh
  78543. * @param options defines the options used to create the mesh
  78544. * @param scene defines the hosting scene
  78545. * @returns a new Mesh
  78546. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78547. */
  78548. static CreateIcoSphere(name: string, options: {
  78549. radius?: number;
  78550. flat?: boolean;
  78551. subdivisions?: number;
  78552. sideOrientation?: number;
  78553. updatable?: boolean;
  78554. }, scene: Scene): Mesh;
  78555. /**
  78556. * Creates a decal mesh.
  78557. * Please consider using the same method from the MeshBuilder class instead.
  78558. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78559. * @param name defines the name of the mesh
  78560. * @param sourceMesh defines the mesh receiving the decal
  78561. * @param position sets the position of the decal in world coordinates
  78562. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78563. * @param size sets the decal scaling
  78564. * @param angle sets the angle to rotate the decal
  78565. * @returns a new Mesh
  78566. */
  78567. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78568. /**
  78569. * Prepare internal position array for software CPU skinning
  78570. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78571. */
  78572. setPositionsForCPUSkinning(): Float32Array;
  78573. /**
  78574. * Prepare internal normal array for software CPU skinning
  78575. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78576. */
  78577. setNormalsForCPUSkinning(): Float32Array;
  78578. /**
  78579. * Updates the vertex buffer by applying transformation from the bones
  78580. * @param skeleton defines the skeleton to apply to current mesh
  78581. * @returns the current mesh
  78582. */
  78583. applySkeleton(skeleton: Skeleton): Mesh;
  78584. /**
  78585. * 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
  78586. * @param meshes defines the list of meshes to scan
  78587. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78588. */
  78589. static MinMax(meshes: AbstractMesh[]): {
  78590. min: Vector3;
  78591. max: Vector3;
  78592. };
  78593. /**
  78594. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78595. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78596. * @returns a vector3
  78597. */
  78598. static Center(meshesOrMinMaxVector: {
  78599. min: Vector3;
  78600. max: Vector3;
  78601. } | AbstractMesh[]): Vector3;
  78602. /**
  78603. * Merge the array of meshes into a single mesh for performance reasons.
  78604. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78605. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78606. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78607. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78608. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78609. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78610. * @returns a new mesh
  78611. */
  78612. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78613. /** @hidden */
  78614. addInstance(instance: InstancedMesh): void;
  78615. /** @hidden */
  78616. removeInstance(instance: InstancedMesh): void;
  78617. }
  78618. }
  78619. declare module BABYLON {
  78620. /**
  78621. * Base class for the main features of a material in Babylon.js
  78622. */
  78623. export class Material implements IAnimatable {
  78624. /**
  78625. * Returns the triangle fill mode
  78626. */
  78627. static readonly TriangleFillMode: number;
  78628. /**
  78629. * Returns the wireframe mode
  78630. */
  78631. static readonly WireFrameFillMode: number;
  78632. /**
  78633. * Returns the point fill mode
  78634. */
  78635. static readonly PointFillMode: number;
  78636. /**
  78637. * Returns the point list draw mode
  78638. */
  78639. static readonly PointListDrawMode: number;
  78640. /**
  78641. * Returns the line list draw mode
  78642. */
  78643. static readonly LineListDrawMode: number;
  78644. /**
  78645. * Returns the line loop draw mode
  78646. */
  78647. static readonly LineLoopDrawMode: number;
  78648. /**
  78649. * Returns the line strip draw mode
  78650. */
  78651. static readonly LineStripDrawMode: number;
  78652. /**
  78653. * Returns the triangle strip draw mode
  78654. */
  78655. static readonly TriangleStripDrawMode: number;
  78656. /**
  78657. * Returns the triangle fan draw mode
  78658. */
  78659. static readonly TriangleFanDrawMode: number;
  78660. /**
  78661. * Stores the clock-wise side orientation
  78662. */
  78663. static readonly ClockWiseSideOrientation: number;
  78664. /**
  78665. * Stores the counter clock-wise side orientation
  78666. */
  78667. static readonly CounterClockWiseSideOrientation: number;
  78668. /**
  78669. * The dirty texture flag value
  78670. */
  78671. static readonly TextureDirtyFlag: number;
  78672. /**
  78673. * The dirty light flag value
  78674. */
  78675. static readonly LightDirtyFlag: number;
  78676. /**
  78677. * The dirty fresnel flag value
  78678. */
  78679. static readonly FresnelDirtyFlag: number;
  78680. /**
  78681. * The dirty attribute flag value
  78682. */
  78683. static readonly AttributesDirtyFlag: number;
  78684. /**
  78685. * The dirty misc flag value
  78686. */
  78687. static readonly MiscDirtyFlag: number;
  78688. /**
  78689. * The all dirty flag value
  78690. */
  78691. static readonly AllDirtyFlag: number;
  78692. /**
  78693. * The ID of the material
  78694. */
  78695. id: string;
  78696. /**
  78697. * Gets or sets the unique id of the material
  78698. */
  78699. uniqueId: number;
  78700. /**
  78701. * The name of the material
  78702. */
  78703. name: string;
  78704. /**
  78705. * Gets or sets user defined metadata
  78706. */
  78707. metadata: any;
  78708. /**
  78709. * For internal use only. Please do not use.
  78710. */
  78711. reservedDataStore: any;
  78712. /**
  78713. * Specifies if the ready state should be checked on each call
  78714. */
  78715. checkReadyOnEveryCall: boolean;
  78716. /**
  78717. * Specifies if the ready state should be checked once
  78718. */
  78719. checkReadyOnlyOnce: boolean;
  78720. /**
  78721. * The state of the material
  78722. */
  78723. state: string;
  78724. /**
  78725. * The alpha value of the material
  78726. */
  78727. protected _alpha: number;
  78728. /**
  78729. * Sets the alpha value of the material
  78730. */
  78731. /**
  78732. * Gets the alpha value of the material
  78733. */
  78734. alpha: number;
  78735. /**
  78736. * Specifies if back face culling is enabled
  78737. */
  78738. protected _backFaceCulling: boolean;
  78739. /**
  78740. * Sets the back-face culling state
  78741. */
  78742. /**
  78743. * Gets the back-face culling state
  78744. */
  78745. backFaceCulling: boolean;
  78746. /**
  78747. * Stores the value for side orientation
  78748. */
  78749. sideOrientation: number;
  78750. /**
  78751. * Callback triggered when the material is compiled
  78752. */
  78753. onCompiled: (effect: Effect) => void;
  78754. /**
  78755. * Callback triggered when an error occurs
  78756. */
  78757. onError: (effect: Effect, errors: string) => void;
  78758. /**
  78759. * Callback triggered to get the render target textures
  78760. */
  78761. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78762. /**
  78763. * Gets a boolean indicating that current material needs to register RTT
  78764. */
  78765. readonly hasRenderTargetTextures: boolean;
  78766. /**
  78767. * Specifies if the material should be serialized
  78768. */
  78769. doNotSerialize: boolean;
  78770. /**
  78771. * @hidden
  78772. */
  78773. _storeEffectOnSubMeshes: boolean;
  78774. /**
  78775. * Stores the animations for the material
  78776. */
  78777. animations: Array<Animation>;
  78778. /**
  78779. * An event triggered when the material is disposed
  78780. */
  78781. onDisposeObservable: Observable<Material>;
  78782. /**
  78783. * An observer which watches for dispose events
  78784. */
  78785. private _onDisposeObserver;
  78786. private _onUnBindObservable;
  78787. /**
  78788. * Called during a dispose event
  78789. */
  78790. onDispose: () => void;
  78791. private _onBindObservable;
  78792. /**
  78793. * An event triggered when the material is bound
  78794. */
  78795. readonly onBindObservable: Observable<AbstractMesh>;
  78796. /**
  78797. * An observer which watches for bind events
  78798. */
  78799. private _onBindObserver;
  78800. /**
  78801. * Called during a bind event
  78802. */
  78803. onBind: (Mesh: AbstractMesh) => void;
  78804. /**
  78805. * An event triggered when the material is unbound
  78806. */
  78807. readonly onUnBindObservable: Observable<Material>;
  78808. /**
  78809. * Stores the value of the alpha mode
  78810. */
  78811. private _alphaMode;
  78812. /**
  78813. * Sets the value of the alpha mode.
  78814. *
  78815. * | Value | Type | Description |
  78816. * | --- | --- | --- |
  78817. * | 0 | ALPHA_DISABLE | |
  78818. * | 1 | ALPHA_ADD | |
  78819. * | 2 | ALPHA_COMBINE | |
  78820. * | 3 | ALPHA_SUBTRACT | |
  78821. * | 4 | ALPHA_MULTIPLY | |
  78822. * | 5 | ALPHA_MAXIMIZED | |
  78823. * | 6 | ALPHA_ONEONE | |
  78824. * | 7 | ALPHA_PREMULTIPLIED | |
  78825. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78826. * | 9 | ALPHA_INTERPOLATE | |
  78827. * | 10 | ALPHA_SCREENMODE | |
  78828. *
  78829. */
  78830. /**
  78831. * Gets the value of the alpha mode
  78832. */
  78833. alphaMode: number;
  78834. /**
  78835. * Stores the state of the need depth pre-pass value
  78836. */
  78837. private _needDepthPrePass;
  78838. /**
  78839. * Sets the need depth pre-pass value
  78840. */
  78841. /**
  78842. * Gets the depth pre-pass value
  78843. */
  78844. needDepthPrePass: boolean;
  78845. /**
  78846. * Specifies if depth writing should be disabled
  78847. */
  78848. disableDepthWrite: boolean;
  78849. /**
  78850. * Specifies if depth writing should be forced
  78851. */
  78852. forceDepthWrite: boolean;
  78853. /**
  78854. * Specifies if there should be a separate pass for culling
  78855. */
  78856. separateCullingPass: boolean;
  78857. /**
  78858. * Stores the state specifing if fog should be enabled
  78859. */
  78860. private _fogEnabled;
  78861. /**
  78862. * Sets the state for enabling fog
  78863. */
  78864. /**
  78865. * Gets the value of the fog enabled state
  78866. */
  78867. fogEnabled: boolean;
  78868. /**
  78869. * Stores the size of points
  78870. */
  78871. pointSize: number;
  78872. /**
  78873. * Stores the z offset value
  78874. */
  78875. zOffset: number;
  78876. /**
  78877. * Gets a value specifying if wireframe mode is enabled
  78878. */
  78879. /**
  78880. * Sets the state of wireframe mode
  78881. */
  78882. wireframe: boolean;
  78883. /**
  78884. * Gets the value specifying if point clouds are enabled
  78885. */
  78886. /**
  78887. * Sets the state of point cloud mode
  78888. */
  78889. pointsCloud: boolean;
  78890. /**
  78891. * Gets the material fill mode
  78892. */
  78893. /**
  78894. * Sets the material fill mode
  78895. */
  78896. fillMode: number;
  78897. /**
  78898. * @hidden
  78899. * Stores the effects for the material
  78900. */
  78901. _effect: Nullable<Effect>;
  78902. /**
  78903. * @hidden
  78904. * Specifies if the material was previously ready
  78905. */
  78906. _wasPreviouslyReady: boolean;
  78907. /**
  78908. * Specifies if uniform buffers should be used
  78909. */
  78910. private _useUBO;
  78911. /**
  78912. * Stores a reference to the scene
  78913. */
  78914. private _scene;
  78915. /**
  78916. * Stores the fill mode state
  78917. */
  78918. private _fillMode;
  78919. /**
  78920. * Specifies if the depth write state should be cached
  78921. */
  78922. private _cachedDepthWriteState;
  78923. /**
  78924. * Stores the uniform buffer
  78925. */
  78926. protected _uniformBuffer: UniformBuffer;
  78927. /** @hidden */
  78928. _indexInSceneMaterialArray: number;
  78929. /** @hidden */
  78930. meshMap: Nullable<{
  78931. [id: string]: AbstractMesh | undefined;
  78932. }>;
  78933. /**
  78934. * Creates a material instance
  78935. * @param name defines the name of the material
  78936. * @param scene defines the scene to reference
  78937. * @param doNotAdd specifies if the material should be added to the scene
  78938. */
  78939. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78940. /**
  78941. * Returns a string representation of the current material
  78942. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78943. * @returns a string with material information
  78944. */
  78945. toString(fullDetails?: boolean): string;
  78946. /**
  78947. * Gets the class name of the material
  78948. * @returns a string with the class name of the material
  78949. */
  78950. getClassName(): string;
  78951. /**
  78952. * Specifies if updates for the material been locked
  78953. */
  78954. readonly isFrozen: boolean;
  78955. /**
  78956. * Locks updates for the material
  78957. */
  78958. freeze(): void;
  78959. /**
  78960. * Unlocks updates for the material
  78961. */
  78962. unfreeze(): void;
  78963. /**
  78964. * Specifies if the material is ready to be used
  78965. * @param mesh defines the mesh to check
  78966. * @param useInstances specifies if instances should be used
  78967. * @returns a boolean indicating if the material is ready to be used
  78968. */
  78969. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78970. /**
  78971. * Specifies that the submesh is ready to be used
  78972. * @param mesh defines the mesh to check
  78973. * @param subMesh defines which submesh to check
  78974. * @param useInstances specifies that instances should be used
  78975. * @returns a boolean indicating that the submesh is ready or not
  78976. */
  78977. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78978. /**
  78979. * Returns the material effect
  78980. * @returns the effect associated with the material
  78981. */
  78982. getEffect(): Nullable<Effect>;
  78983. /**
  78984. * Returns the current scene
  78985. * @returns a Scene
  78986. */
  78987. getScene(): Scene;
  78988. /**
  78989. * Specifies if the material will require alpha blending
  78990. * @returns a boolean specifying if alpha blending is needed
  78991. */
  78992. needAlphaBlending(): boolean;
  78993. /**
  78994. * Specifies if the mesh will require alpha blending
  78995. * @param mesh defines the mesh to check
  78996. * @returns a boolean specifying if alpha blending is needed for the mesh
  78997. */
  78998. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78999. /**
  79000. * Specifies if this material should be rendered in alpha test mode
  79001. * @returns a boolean specifying if an alpha test is needed.
  79002. */
  79003. needAlphaTesting(): boolean;
  79004. /**
  79005. * Gets the texture used for the alpha test
  79006. * @returns the texture to use for alpha testing
  79007. */
  79008. getAlphaTestTexture(): Nullable<BaseTexture>;
  79009. /**
  79010. * Marks the material to indicate that it needs to be re-calculated
  79011. */
  79012. markDirty(): void;
  79013. /** @hidden */
  79014. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  79015. /**
  79016. * Binds the material to the mesh
  79017. * @param world defines the world transformation matrix
  79018. * @param mesh defines the mesh to bind the material to
  79019. */
  79020. bind(world: Matrix, mesh?: Mesh): void;
  79021. /**
  79022. * Binds the submesh to the material
  79023. * @param world defines the world transformation matrix
  79024. * @param mesh defines the mesh containing the submesh
  79025. * @param subMesh defines the submesh to bind the material to
  79026. */
  79027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79028. /**
  79029. * Binds the world matrix to the material
  79030. * @param world defines the world transformation matrix
  79031. */
  79032. bindOnlyWorldMatrix(world: Matrix): void;
  79033. /**
  79034. * Binds the scene's uniform buffer to the effect.
  79035. * @param effect defines the effect to bind to the scene uniform buffer
  79036. * @param sceneUbo defines the uniform buffer storing scene data
  79037. */
  79038. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79039. /**
  79040. * Binds the view matrix to the effect
  79041. * @param effect defines the effect to bind the view matrix to
  79042. */
  79043. bindView(effect: Effect): void;
  79044. /**
  79045. * Binds the view projection matrix to the effect
  79046. * @param effect defines the effect to bind the view projection matrix to
  79047. */
  79048. bindViewProjection(effect: Effect): void;
  79049. /**
  79050. * Specifies if material alpha testing should be turned on for the mesh
  79051. * @param mesh defines the mesh to check
  79052. */
  79053. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79054. /**
  79055. * Processes to execute after binding the material to a mesh
  79056. * @param mesh defines the rendered mesh
  79057. */
  79058. protected _afterBind(mesh?: Mesh): void;
  79059. /**
  79060. * Unbinds the material from the mesh
  79061. */
  79062. unbind(): void;
  79063. /**
  79064. * Gets the active textures from the material
  79065. * @returns an array of textures
  79066. */
  79067. getActiveTextures(): BaseTexture[];
  79068. /**
  79069. * Specifies if the material uses a texture
  79070. * @param texture defines the texture to check against the material
  79071. * @returns a boolean specifying if the material uses the texture
  79072. */
  79073. hasTexture(texture: BaseTexture): boolean;
  79074. /**
  79075. * Makes a duplicate of the material, and gives it a new name
  79076. * @param name defines the new name for the duplicated material
  79077. * @returns the cloned material
  79078. */
  79079. clone(name: string): Nullable<Material>;
  79080. /**
  79081. * Gets the meshes bound to the material
  79082. * @returns an array of meshes bound to the material
  79083. */
  79084. getBindedMeshes(): AbstractMesh[];
  79085. /**
  79086. * Force shader compilation
  79087. * @param mesh defines the mesh associated with this material
  79088. * @param onCompiled defines a function to execute once the material is compiled
  79089. * @param options defines the options to configure the compilation
  79090. */
  79091. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79092. clipPlane: boolean;
  79093. }>): void;
  79094. /**
  79095. * Force shader compilation
  79096. * @param mesh defines the mesh that will use this material
  79097. * @param options defines additional options for compiling the shaders
  79098. * @returns a promise that resolves when the compilation completes
  79099. */
  79100. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79101. clipPlane: boolean;
  79102. }>): Promise<void>;
  79103. private static readonly _ImageProcessingDirtyCallBack;
  79104. private static readonly _TextureDirtyCallBack;
  79105. private static readonly _FresnelDirtyCallBack;
  79106. private static readonly _MiscDirtyCallBack;
  79107. private static readonly _LightsDirtyCallBack;
  79108. private static readonly _AttributeDirtyCallBack;
  79109. private static _FresnelAndMiscDirtyCallBack;
  79110. private static _TextureAndMiscDirtyCallBack;
  79111. private static readonly _DirtyCallbackArray;
  79112. private static readonly _RunDirtyCallBacks;
  79113. /**
  79114. * Marks a define in the material to indicate that it needs to be re-computed
  79115. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79116. */
  79117. markAsDirty(flag: number): void;
  79118. /**
  79119. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79120. * @param func defines a function which checks material defines against the submeshes
  79121. */
  79122. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79123. /**
  79124. * Indicates that image processing needs to be re-calculated for all submeshes
  79125. */
  79126. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79127. /**
  79128. * Indicates that textures need to be re-calculated for all submeshes
  79129. */
  79130. protected _markAllSubMeshesAsTexturesDirty(): void;
  79131. /**
  79132. * Indicates that fresnel needs to be re-calculated for all submeshes
  79133. */
  79134. protected _markAllSubMeshesAsFresnelDirty(): void;
  79135. /**
  79136. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79137. */
  79138. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79139. /**
  79140. * Indicates that lights need to be re-calculated for all submeshes
  79141. */
  79142. protected _markAllSubMeshesAsLightsDirty(): void;
  79143. /**
  79144. * Indicates that attributes need to be re-calculated for all submeshes
  79145. */
  79146. protected _markAllSubMeshesAsAttributesDirty(): void;
  79147. /**
  79148. * Indicates that misc needs to be re-calculated for all submeshes
  79149. */
  79150. protected _markAllSubMeshesAsMiscDirty(): void;
  79151. /**
  79152. * Indicates that textures and misc need to be re-calculated for all submeshes
  79153. */
  79154. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79155. /**
  79156. * Disposes the material
  79157. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79158. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79159. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79160. */
  79161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79162. /** @hidden */
  79163. private releaseVertexArrayObject;
  79164. /**
  79165. * Serializes this material
  79166. * @returns the serialized material object
  79167. */
  79168. serialize(): any;
  79169. /**
  79170. * Creates a material from parsed material data
  79171. * @param parsedMaterial defines parsed material data
  79172. * @param scene defines the hosting scene
  79173. * @param rootUrl defines the root URL to use to load textures
  79174. * @returns a new material
  79175. */
  79176. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79177. }
  79178. }
  79179. declare module BABYLON {
  79180. /**
  79181. * Base class for submeshes
  79182. */
  79183. export class BaseSubMesh {
  79184. /** @hidden */
  79185. _materialDefines: Nullable<MaterialDefines>;
  79186. /** @hidden */
  79187. _materialEffect: Nullable<Effect>;
  79188. /**
  79189. * Gets associated effect
  79190. */
  79191. readonly effect: Nullable<Effect>;
  79192. /**
  79193. * Sets associated effect (effect used to render this submesh)
  79194. * @param effect defines the effect to associate with
  79195. * @param defines defines the set of defines used to compile this effect
  79196. */
  79197. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79198. }
  79199. /**
  79200. * Defines a subdivision inside a mesh
  79201. */
  79202. export class SubMesh extends BaseSubMesh implements ICullable {
  79203. /** the material index to use */
  79204. materialIndex: number;
  79205. /** vertex index start */
  79206. verticesStart: number;
  79207. /** vertices count */
  79208. verticesCount: number;
  79209. /** index start */
  79210. indexStart: number;
  79211. /** indices count */
  79212. indexCount: number;
  79213. /** @hidden */
  79214. _linesIndexCount: number;
  79215. private _mesh;
  79216. private _renderingMesh;
  79217. private _boundingInfo;
  79218. private _linesIndexBuffer;
  79219. /** @hidden */
  79220. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79221. /** @hidden */
  79222. _trianglePlanes: Plane[];
  79223. /** @hidden */
  79224. _lastColliderTransformMatrix: Matrix;
  79225. /** @hidden */
  79226. _renderId: number;
  79227. /** @hidden */
  79228. _alphaIndex: number;
  79229. /** @hidden */
  79230. _distanceToCamera: number;
  79231. /** @hidden */
  79232. _id: number;
  79233. private _currentMaterial;
  79234. /**
  79235. * Add a new submesh to a mesh
  79236. * @param materialIndex defines the material index to use
  79237. * @param verticesStart defines vertex index start
  79238. * @param verticesCount defines vertices count
  79239. * @param indexStart defines index start
  79240. * @param indexCount defines indices count
  79241. * @param mesh defines the parent mesh
  79242. * @param renderingMesh defines an optional rendering mesh
  79243. * @param createBoundingBox defines if bounding box should be created for this submesh
  79244. * @returns the new submesh
  79245. */
  79246. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79247. /**
  79248. * Creates a new submesh
  79249. * @param materialIndex defines the material index to use
  79250. * @param verticesStart defines vertex index start
  79251. * @param verticesCount defines vertices count
  79252. * @param indexStart defines index start
  79253. * @param indexCount defines indices count
  79254. * @param mesh defines the parent mesh
  79255. * @param renderingMesh defines an optional rendering mesh
  79256. * @param createBoundingBox defines if bounding box should be created for this submesh
  79257. */
  79258. constructor(
  79259. /** the material index to use */
  79260. materialIndex: number,
  79261. /** vertex index start */
  79262. verticesStart: number,
  79263. /** vertices count */
  79264. verticesCount: number,
  79265. /** index start */
  79266. indexStart: number,
  79267. /** indices count */
  79268. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79269. /**
  79270. * Returns true if this submesh covers the entire parent mesh
  79271. * @ignorenaming
  79272. */
  79273. readonly IsGlobal: boolean;
  79274. /**
  79275. * Returns the submesh BoudingInfo object
  79276. * @returns current bounding info (or mesh's one if the submesh is global)
  79277. */
  79278. getBoundingInfo(): BoundingInfo;
  79279. /**
  79280. * Sets the submesh BoundingInfo
  79281. * @param boundingInfo defines the new bounding info to use
  79282. * @returns the SubMesh
  79283. */
  79284. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79285. /**
  79286. * Returns the mesh of the current submesh
  79287. * @return the parent mesh
  79288. */
  79289. getMesh(): AbstractMesh;
  79290. /**
  79291. * Returns the rendering mesh of the submesh
  79292. * @returns the rendering mesh (could be different from parent mesh)
  79293. */
  79294. getRenderingMesh(): Mesh;
  79295. /**
  79296. * Returns the submesh material
  79297. * @returns null or the current material
  79298. */
  79299. getMaterial(): Nullable<Material>;
  79300. /**
  79301. * Sets a new updated BoundingInfo object to the submesh
  79302. * @returns the SubMesh
  79303. */
  79304. refreshBoundingInfo(): SubMesh;
  79305. /** @hidden */
  79306. _checkCollision(collider: Collider): boolean;
  79307. /**
  79308. * Updates the submesh BoundingInfo
  79309. * @param world defines the world matrix to use to update the bounding info
  79310. * @returns the submesh
  79311. */
  79312. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79313. /**
  79314. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79315. * @param frustumPlanes defines the frustum planes
  79316. * @returns true if the submesh is intersecting with the frustum
  79317. */
  79318. isInFrustum(frustumPlanes: Plane[]): boolean;
  79319. /**
  79320. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79321. * @param frustumPlanes defines the frustum planes
  79322. * @returns true if the submesh is inside the frustum
  79323. */
  79324. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79325. /**
  79326. * Renders the submesh
  79327. * @param enableAlphaMode defines if alpha needs to be used
  79328. * @returns the submesh
  79329. */
  79330. render(enableAlphaMode: boolean): SubMesh;
  79331. /**
  79332. * @hidden
  79333. */
  79334. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79335. /**
  79336. * Checks if the submesh intersects with a ray
  79337. * @param ray defines the ray to test
  79338. * @returns true is the passed ray intersects the submesh bounding box
  79339. */
  79340. canIntersects(ray: Ray): boolean;
  79341. /**
  79342. * Intersects current submesh with a ray
  79343. * @param ray defines the ray to test
  79344. * @param positions defines mesh's positions array
  79345. * @param indices defines mesh's indices array
  79346. * @param fastCheck defines if only bounding info should be used
  79347. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79348. * @returns intersection info or null if no intersection
  79349. */
  79350. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79351. /** @hidden */
  79352. private _intersectLines;
  79353. /** @hidden */
  79354. private _intersectTriangles;
  79355. /** @hidden */
  79356. _rebuild(): void;
  79357. /**
  79358. * Creates a new submesh from the passed mesh
  79359. * @param newMesh defines the new hosting mesh
  79360. * @param newRenderingMesh defines an optional rendering mesh
  79361. * @returns the new submesh
  79362. */
  79363. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79364. /**
  79365. * Release associated resources
  79366. */
  79367. dispose(): void;
  79368. /**
  79369. * Gets the class name
  79370. * @returns the string "SubMesh".
  79371. */
  79372. getClassName(): string;
  79373. /**
  79374. * Creates a new submesh from indices data
  79375. * @param materialIndex the index of the main mesh material
  79376. * @param startIndex the index where to start the copy in the mesh indices array
  79377. * @param indexCount the number of indices to copy then from the startIndex
  79378. * @param mesh the main mesh to create the submesh from
  79379. * @param renderingMesh the optional rendering mesh
  79380. * @returns a new submesh
  79381. */
  79382. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79383. }
  79384. }
  79385. declare module BABYLON {
  79386. /**
  79387. * Class used to store geometry data (vertex buffers + index buffer)
  79388. */
  79389. export class Geometry implements IGetSetVerticesData {
  79390. /**
  79391. * Gets or sets the ID of the geometry
  79392. */
  79393. id: string;
  79394. /**
  79395. * Gets or sets the unique ID of the geometry
  79396. */
  79397. uniqueId: number;
  79398. /**
  79399. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79400. */
  79401. delayLoadState: number;
  79402. /**
  79403. * Gets the file containing the data to load when running in delay load state
  79404. */
  79405. delayLoadingFile: Nullable<string>;
  79406. /**
  79407. * Callback called when the geometry is updated
  79408. */
  79409. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79410. private _scene;
  79411. private _engine;
  79412. private _meshes;
  79413. private _totalVertices;
  79414. /** @hidden */
  79415. _indices: IndicesArray;
  79416. /** @hidden */
  79417. _vertexBuffers: {
  79418. [key: string]: VertexBuffer;
  79419. };
  79420. private _isDisposed;
  79421. private _extend;
  79422. private _boundingBias;
  79423. /** @hidden */
  79424. _delayInfo: Array<string>;
  79425. private _indexBuffer;
  79426. private _indexBufferIsUpdatable;
  79427. /** @hidden */
  79428. _boundingInfo: Nullable<BoundingInfo>;
  79429. /** @hidden */
  79430. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79431. /** @hidden */
  79432. _softwareSkinningFrameId: number;
  79433. private _vertexArrayObjects;
  79434. private _updatable;
  79435. /** @hidden */
  79436. _positions: Nullable<Vector3[]>;
  79437. /**
  79438. * 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
  79439. */
  79440. /**
  79441. * 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
  79442. */
  79443. boundingBias: Vector2;
  79444. /**
  79445. * Static function used to attach a new empty geometry to a mesh
  79446. * @param mesh defines the mesh to attach the geometry to
  79447. * @returns the new Geometry
  79448. */
  79449. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79450. /**
  79451. * Creates a new geometry
  79452. * @param id defines the unique ID
  79453. * @param scene defines the hosting scene
  79454. * @param vertexData defines the VertexData used to get geometry data
  79455. * @param updatable defines if geometry must be updatable (false by default)
  79456. * @param mesh defines the mesh that will be associated with the geometry
  79457. */
  79458. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79459. /**
  79460. * Gets the current extend of the geometry
  79461. */
  79462. readonly extend: {
  79463. minimum: Vector3;
  79464. maximum: Vector3;
  79465. };
  79466. /**
  79467. * Gets the hosting scene
  79468. * @returns the hosting Scene
  79469. */
  79470. getScene(): Scene;
  79471. /**
  79472. * Gets the hosting engine
  79473. * @returns the hosting Engine
  79474. */
  79475. getEngine(): Engine;
  79476. /**
  79477. * Defines if the geometry is ready to use
  79478. * @returns true if the geometry is ready to be used
  79479. */
  79480. isReady(): boolean;
  79481. /**
  79482. * Gets a value indicating that the geometry should not be serialized
  79483. */
  79484. readonly doNotSerialize: boolean;
  79485. /** @hidden */
  79486. _rebuild(): void;
  79487. /**
  79488. * Affects all geometry data in one call
  79489. * @param vertexData defines the geometry data
  79490. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79491. */
  79492. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79493. /**
  79494. * Set specific vertex data
  79495. * @param kind defines the data kind (Position, normal, etc...)
  79496. * @param data defines the vertex data to use
  79497. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79498. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79499. */
  79500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79501. /**
  79502. * Removes a specific vertex data
  79503. * @param kind defines the data kind (Position, normal, etc...)
  79504. */
  79505. removeVerticesData(kind: string): void;
  79506. /**
  79507. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79508. * @param buffer defines the vertex buffer to use
  79509. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79510. */
  79511. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79512. /**
  79513. * Update a specific vertex buffer
  79514. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79515. * It will do nothing if the buffer is not updatable
  79516. * @param kind defines the data kind (Position, normal, etc...)
  79517. * @param data defines the data to use
  79518. * @param offset defines the offset in the target buffer where to store the data
  79519. * @param useBytes set to true if the offset is in bytes
  79520. */
  79521. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79522. /**
  79523. * Update a specific vertex buffer
  79524. * This function will create a new buffer if the current one is not updatable
  79525. * @param kind defines the data kind (Position, normal, etc...)
  79526. * @param data defines the data to use
  79527. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79528. */
  79529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79530. private _updateBoundingInfo;
  79531. /** @hidden */
  79532. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79533. /**
  79534. * Gets total number of vertices
  79535. * @returns the total number of vertices
  79536. */
  79537. getTotalVertices(): number;
  79538. /**
  79539. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79540. * @param kind defines the data kind (Position, normal, etc...)
  79541. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79542. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79543. * @returns a float array containing vertex data
  79544. */
  79545. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79546. /**
  79547. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79548. * @param kind defines the data kind (Position, normal, etc...)
  79549. * @returns true if the vertex buffer with the specified kind is updatable
  79550. */
  79551. isVertexBufferUpdatable(kind: string): boolean;
  79552. /**
  79553. * Gets a specific vertex buffer
  79554. * @param kind defines the data kind (Position, normal, etc...)
  79555. * @returns a VertexBuffer
  79556. */
  79557. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79558. /**
  79559. * Returns all vertex buffers
  79560. * @return an object holding all vertex buffers indexed by kind
  79561. */
  79562. getVertexBuffers(): Nullable<{
  79563. [key: string]: VertexBuffer;
  79564. }>;
  79565. /**
  79566. * Gets a boolean indicating if specific vertex buffer is present
  79567. * @param kind defines the data kind (Position, normal, etc...)
  79568. * @returns true if data is present
  79569. */
  79570. isVerticesDataPresent(kind: string): boolean;
  79571. /**
  79572. * Gets a list of all attached data kinds (Position, normal, etc...)
  79573. * @returns a list of string containing all kinds
  79574. */
  79575. getVerticesDataKinds(): string[];
  79576. /**
  79577. * Update index buffer
  79578. * @param indices defines the indices to store in the index buffer
  79579. * @param offset defines the offset in the target buffer where to store the data
  79580. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  79581. */
  79582. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79583. /**
  79584. * Creates a new index buffer
  79585. * @param indices defines the indices to store in the index buffer
  79586. * @param totalVertices defines the total number of vertices (could be null)
  79587. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79588. */
  79589. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79590. /**
  79591. * Return the total number of indices
  79592. * @returns the total number of indices
  79593. */
  79594. getTotalIndices(): number;
  79595. /**
  79596. * Gets the index buffer array
  79597. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79598. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79599. * @returns the index buffer array
  79600. */
  79601. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79602. /**
  79603. * Gets the index buffer
  79604. * @return the index buffer
  79605. */
  79606. getIndexBuffer(): Nullable<WebGLBuffer>;
  79607. /** @hidden */
  79608. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79609. /**
  79610. * Release the associated resources for a specific mesh
  79611. * @param mesh defines the source mesh
  79612. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79613. */
  79614. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79615. /**
  79616. * Apply current geometry to a given mesh
  79617. * @param mesh defines the mesh to apply geometry to
  79618. */
  79619. applyToMesh(mesh: Mesh): void;
  79620. private _updateExtend;
  79621. private _applyToMesh;
  79622. private notifyUpdate;
  79623. /**
  79624. * Load the geometry if it was flagged as delay loaded
  79625. * @param scene defines the hosting scene
  79626. * @param onLoaded defines a callback called when the geometry is loaded
  79627. */
  79628. load(scene: Scene, onLoaded?: () => void): void;
  79629. private _queueLoad;
  79630. /**
  79631. * Invert the geometry to move from a right handed system to a left handed one.
  79632. */
  79633. toLeftHanded(): void;
  79634. /** @hidden */
  79635. _resetPointsArrayCache(): void;
  79636. /** @hidden */
  79637. _generatePointsArray(): boolean;
  79638. /**
  79639. * Gets a value indicating if the geometry is disposed
  79640. * @returns true if the geometry was disposed
  79641. */
  79642. isDisposed(): boolean;
  79643. private _disposeVertexArrayObjects;
  79644. /**
  79645. * Free all associated resources
  79646. */
  79647. dispose(): void;
  79648. /**
  79649. * Clone the current geometry into a new geometry
  79650. * @param id defines the unique ID of the new geometry
  79651. * @returns a new geometry object
  79652. */
  79653. copy(id: string): Geometry;
  79654. /**
  79655. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79656. * @return a JSON representation of the current geometry data (without the vertices data)
  79657. */
  79658. serialize(): any;
  79659. private toNumberArray;
  79660. /**
  79661. * Serialize all vertices data into a JSON oject
  79662. * @returns a JSON representation of the current geometry data
  79663. */
  79664. serializeVerticeData(): any;
  79665. /**
  79666. * Extracts a clone of a mesh geometry
  79667. * @param mesh defines the source mesh
  79668. * @param id defines the unique ID of the new geometry object
  79669. * @returns the new geometry object
  79670. */
  79671. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79672. /**
  79673. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79674. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79675. * Be aware Math.random() could cause collisions, but:
  79676. * "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"
  79677. * @returns a string containing a new GUID
  79678. */
  79679. static RandomId(): string;
  79680. /** @hidden */
  79681. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79682. private static _CleanMatricesWeights;
  79683. /**
  79684. * Create a new geometry from persisted data (Using .babylon file format)
  79685. * @param parsedVertexData defines the persisted data
  79686. * @param scene defines the hosting scene
  79687. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79688. * @returns the new geometry object
  79689. */
  79690. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79691. }
  79692. }
  79693. declare module BABYLON {
  79694. /**
  79695. * Define an interface for all classes that will get and set the data on vertices
  79696. */
  79697. export interface IGetSetVerticesData {
  79698. /**
  79699. * Gets a boolean indicating if specific vertex data is present
  79700. * @param kind defines the vertex data kind to use
  79701. * @returns true is data kind is present
  79702. */
  79703. isVerticesDataPresent(kind: string): boolean;
  79704. /**
  79705. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79706. * @param kind defines the data kind (Position, normal, etc...)
  79707. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79708. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79709. * @returns a float array containing vertex data
  79710. */
  79711. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79712. /**
  79713. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79714. * @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.
  79715. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79716. * @returns the indices array or an empty array if the mesh has no geometry
  79717. */
  79718. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79719. /**
  79720. * Set specific vertex data
  79721. * @param kind defines the data kind (Position, normal, etc...)
  79722. * @param data defines the vertex data to use
  79723. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79724. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79725. */
  79726. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79727. /**
  79728. * Update a specific associated vertex buffer
  79729. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79730. * - VertexBuffer.PositionKind
  79731. * - VertexBuffer.UVKind
  79732. * - VertexBuffer.UV2Kind
  79733. * - VertexBuffer.UV3Kind
  79734. * - VertexBuffer.UV4Kind
  79735. * - VertexBuffer.UV5Kind
  79736. * - VertexBuffer.UV6Kind
  79737. * - VertexBuffer.ColorKind
  79738. * - VertexBuffer.MatricesIndicesKind
  79739. * - VertexBuffer.MatricesIndicesExtraKind
  79740. * - VertexBuffer.MatricesWeightsKind
  79741. * - VertexBuffer.MatricesWeightsExtraKind
  79742. * @param data defines the data source
  79743. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79744. * @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)
  79745. */
  79746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79747. /**
  79748. * Creates a new index buffer
  79749. * @param indices defines the indices to store in the index buffer
  79750. * @param totalVertices defines the total number of vertices (could be null)
  79751. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79752. */
  79753. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79754. }
  79755. /**
  79756. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79757. */
  79758. export class VertexData {
  79759. /**
  79760. * Mesh side orientation : usually the external or front surface
  79761. */
  79762. static readonly FRONTSIDE: number;
  79763. /**
  79764. * Mesh side orientation : usually the internal or back surface
  79765. */
  79766. static readonly BACKSIDE: number;
  79767. /**
  79768. * Mesh side orientation : both internal and external or front and back surfaces
  79769. */
  79770. static readonly DOUBLESIDE: number;
  79771. /**
  79772. * Mesh side orientation : by default, `FRONTSIDE`
  79773. */
  79774. static readonly DEFAULTSIDE: number;
  79775. /**
  79776. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79777. */
  79778. positions: Nullable<FloatArray>;
  79779. /**
  79780. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79781. */
  79782. normals: Nullable<FloatArray>;
  79783. /**
  79784. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79785. */
  79786. tangents: Nullable<FloatArray>;
  79787. /**
  79788. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79789. */
  79790. uvs: Nullable<FloatArray>;
  79791. /**
  79792. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79793. */
  79794. uvs2: Nullable<FloatArray>;
  79795. /**
  79796. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79797. */
  79798. uvs3: Nullable<FloatArray>;
  79799. /**
  79800. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79801. */
  79802. uvs4: Nullable<FloatArray>;
  79803. /**
  79804. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79805. */
  79806. uvs5: Nullable<FloatArray>;
  79807. /**
  79808. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79809. */
  79810. uvs6: Nullable<FloatArray>;
  79811. /**
  79812. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79813. */
  79814. colors: Nullable<FloatArray>;
  79815. /**
  79816. * 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).
  79817. */
  79818. matricesIndices: Nullable<FloatArray>;
  79819. /**
  79820. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79821. */
  79822. matricesWeights: Nullable<FloatArray>;
  79823. /**
  79824. * An array extending the number of possible indices
  79825. */
  79826. matricesIndicesExtra: Nullable<FloatArray>;
  79827. /**
  79828. * An array extending the number of possible weights when the number of indices is extended
  79829. */
  79830. matricesWeightsExtra: Nullable<FloatArray>;
  79831. /**
  79832. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79833. */
  79834. indices: Nullable<IndicesArray>;
  79835. /**
  79836. * Uses the passed data array to set the set the values for the specified kind of data
  79837. * @param data a linear array of floating numbers
  79838. * @param kind the type of data that is being set, eg positions, colors etc
  79839. */
  79840. set(data: FloatArray, kind: string): void;
  79841. /**
  79842. * Associates the vertexData to the passed Mesh.
  79843. * Sets it as updatable or not (default `false`)
  79844. * @param mesh the mesh the vertexData is applied to
  79845. * @param updatable when used and having the value true allows new data to update the vertexData
  79846. * @returns the VertexData
  79847. */
  79848. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79849. /**
  79850. * Associates the vertexData to the passed Geometry.
  79851. * Sets it as updatable or not (default `false`)
  79852. * @param geometry the geometry the vertexData is applied to
  79853. * @param updatable when used and having the value true allows new data to update the vertexData
  79854. * @returns VertexData
  79855. */
  79856. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79857. /**
  79858. * Updates the associated mesh
  79859. * @param mesh the mesh to be updated
  79860. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79861. * @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
  79862. * @returns VertexData
  79863. */
  79864. updateMesh(mesh: Mesh): VertexData;
  79865. /**
  79866. * Updates the associated geometry
  79867. * @param geometry the geometry to be updated
  79868. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79869. * @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
  79870. * @returns VertexData.
  79871. */
  79872. updateGeometry(geometry: Geometry): VertexData;
  79873. private _applyTo;
  79874. private _update;
  79875. /**
  79876. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79877. * @param matrix the transforming matrix
  79878. * @returns the VertexData
  79879. */
  79880. transform(matrix: Matrix): VertexData;
  79881. /**
  79882. * Merges the passed VertexData into the current one
  79883. * @param other the VertexData to be merged into the current one
  79884. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79885. * @returns the modified VertexData
  79886. */
  79887. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79888. private _mergeElement;
  79889. private _validate;
  79890. /**
  79891. * Serializes the VertexData
  79892. * @returns a serialized object
  79893. */
  79894. serialize(): any;
  79895. /**
  79896. * Extracts the vertexData from a mesh
  79897. * @param mesh the mesh from which to extract the VertexData
  79898. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79899. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79900. * @returns the object VertexData associated to the passed mesh
  79901. */
  79902. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79903. /**
  79904. * Extracts the vertexData from the geometry
  79905. * @param geometry the geometry from which to extract the VertexData
  79906. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79907. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79908. * @returns the object VertexData associated to the passed mesh
  79909. */
  79910. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79911. private static _ExtractFrom;
  79912. /**
  79913. * Creates the VertexData for a Ribbon
  79914. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79915. * * pathArray array of paths, each of which an array of successive Vector3
  79916. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79917. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79918. * * 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
  79919. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79920. * * 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)
  79921. * * 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)
  79922. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79923. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79924. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79925. * @returns the VertexData of the ribbon
  79926. */
  79927. static CreateRibbon(options: {
  79928. pathArray: Vector3[][];
  79929. closeArray?: boolean;
  79930. closePath?: boolean;
  79931. offset?: number;
  79932. sideOrientation?: number;
  79933. frontUVs?: Vector4;
  79934. backUVs?: Vector4;
  79935. invertUV?: boolean;
  79936. uvs?: Vector2[];
  79937. colors?: Color4[];
  79938. }): VertexData;
  79939. /**
  79940. * Creates the VertexData for a box
  79941. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79942. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79943. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79944. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79945. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79946. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79947. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79949. * * 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)
  79950. * * 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)
  79951. * @returns the VertexData of the box
  79952. */
  79953. static CreateBox(options: {
  79954. size?: number;
  79955. width?: number;
  79956. height?: number;
  79957. depth?: number;
  79958. faceUV?: Vector4[];
  79959. faceColors?: Color4[];
  79960. sideOrientation?: number;
  79961. frontUVs?: Vector4;
  79962. backUVs?: Vector4;
  79963. }): VertexData;
  79964. /**
  79965. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79966. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79967. * * segments sets the number of horizontal strips optional, default 32
  79968. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79969. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79970. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79971. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79972. * * 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
  79973. * * 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
  79974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79975. * * 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)
  79976. * * 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)
  79977. * @returns the VertexData of the ellipsoid
  79978. */
  79979. static CreateSphere(options: {
  79980. segments?: number;
  79981. diameter?: number;
  79982. diameterX?: number;
  79983. diameterY?: number;
  79984. diameterZ?: number;
  79985. arc?: number;
  79986. slice?: number;
  79987. sideOrientation?: number;
  79988. frontUVs?: Vector4;
  79989. backUVs?: Vector4;
  79990. }): VertexData;
  79991. /**
  79992. * Creates the VertexData for a cylinder, cone or prism
  79993. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79994. * * height sets the height (y direction) of the cylinder, optional, default 2
  79995. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79996. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79997. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79998. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79999. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  80000. * * 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
  80001. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80002. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80003. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  80004. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  80005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80006. * * 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)
  80007. * * 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)
  80008. * @returns the VertexData of the cylinder, cone or prism
  80009. */
  80010. static CreateCylinder(options: {
  80011. height?: number;
  80012. diameterTop?: number;
  80013. diameterBottom?: number;
  80014. diameter?: number;
  80015. tessellation?: number;
  80016. subdivisions?: number;
  80017. arc?: number;
  80018. faceColors?: Color4[];
  80019. faceUV?: Vector4[];
  80020. hasRings?: boolean;
  80021. enclose?: boolean;
  80022. sideOrientation?: number;
  80023. frontUVs?: Vector4;
  80024. backUVs?: Vector4;
  80025. }): VertexData;
  80026. /**
  80027. * Creates the VertexData for a torus
  80028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80029. * * diameter the diameter of the torus, optional default 1
  80030. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80031. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80033. * * 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)
  80034. * * 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)
  80035. * @returns the VertexData of the torus
  80036. */
  80037. static CreateTorus(options: {
  80038. diameter?: number;
  80039. thickness?: number;
  80040. tessellation?: number;
  80041. sideOrientation?: number;
  80042. frontUVs?: Vector4;
  80043. backUVs?: Vector4;
  80044. }): VertexData;
  80045. /**
  80046. * Creates the VertexData of the LineSystem
  80047. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80048. * - lines an array of lines, each line being an array of successive Vector3
  80049. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80050. * @returns the VertexData of the LineSystem
  80051. */
  80052. static CreateLineSystem(options: {
  80053. lines: Vector3[][];
  80054. colors?: Nullable<Color4[][]>;
  80055. }): VertexData;
  80056. /**
  80057. * Create the VertexData for a DashedLines
  80058. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80059. * - points an array successive Vector3
  80060. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80061. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80062. * - dashNb the intended total number of dashes, optional, default 200
  80063. * @returns the VertexData for the DashedLines
  80064. */
  80065. static CreateDashedLines(options: {
  80066. points: Vector3[];
  80067. dashSize?: number;
  80068. gapSize?: number;
  80069. dashNb?: number;
  80070. }): VertexData;
  80071. /**
  80072. * Creates the VertexData for a Ground
  80073. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80074. * - width the width (x direction) of the ground, optional, default 1
  80075. * - height the height (z direction) of the ground, optional, default 1
  80076. * - subdivisions the number of subdivisions per side, optional, default 1
  80077. * @returns the VertexData of the Ground
  80078. */
  80079. static CreateGround(options: {
  80080. width?: number;
  80081. height?: number;
  80082. subdivisions?: number;
  80083. subdivisionsX?: number;
  80084. subdivisionsY?: number;
  80085. }): VertexData;
  80086. /**
  80087. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80088. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80089. * * xmin the ground minimum X coordinate, optional, default -1
  80090. * * zmin the ground minimum Z coordinate, optional, default -1
  80091. * * xmax the ground maximum X coordinate, optional, default 1
  80092. * * zmax the ground maximum Z coordinate, optional, default 1
  80093. * * 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}
  80094. * * 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}
  80095. * @returns the VertexData of the TiledGround
  80096. */
  80097. static CreateTiledGround(options: {
  80098. xmin: number;
  80099. zmin: number;
  80100. xmax: number;
  80101. zmax: number;
  80102. subdivisions?: {
  80103. w: number;
  80104. h: number;
  80105. };
  80106. precision?: {
  80107. w: number;
  80108. h: number;
  80109. };
  80110. }): VertexData;
  80111. /**
  80112. * Creates the VertexData of the Ground designed from a heightmap
  80113. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80114. * * width the width (x direction) of the ground
  80115. * * height the height (z direction) of the ground
  80116. * * subdivisions the number of subdivisions per side
  80117. * * minHeight the minimum altitude on the ground, optional, default 0
  80118. * * maxHeight the maximum altitude on the ground, optional default 1
  80119. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80120. * * buffer the array holding the image color data
  80121. * * bufferWidth the width of image
  80122. * * bufferHeight the height of image
  80123. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80124. * @returns the VertexData of the Ground designed from a heightmap
  80125. */
  80126. static CreateGroundFromHeightMap(options: {
  80127. width: number;
  80128. height: number;
  80129. subdivisions: number;
  80130. minHeight: number;
  80131. maxHeight: number;
  80132. colorFilter: Color3;
  80133. buffer: Uint8Array;
  80134. bufferWidth: number;
  80135. bufferHeight: number;
  80136. alphaFilter: number;
  80137. }): VertexData;
  80138. /**
  80139. * Creates the VertexData for a Plane
  80140. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80141. * * size sets the width and height of the plane to the value of size, optional default 1
  80142. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80143. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80145. * * 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)
  80146. * * 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)
  80147. * @returns the VertexData of the box
  80148. */
  80149. static CreatePlane(options: {
  80150. size?: number;
  80151. width?: number;
  80152. height?: number;
  80153. sideOrientation?: number;
  80154. frontUVs?: Vector4;
  80155. backUVs?: Vector4;
  80156. }): VertexData;
  80157. /**
  80158. * Creates the VertexData of the Disc or regular Polygon
  80159. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80160. * * radius the radius of the disc, optional default 0.5
  80161. * * tessellation the number of polygon sides, optional, default 64
  80162. * * 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
  80163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80164. * * 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)
  80165. * * 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)
  80166. * @returns the VertexData of the box
  80167. */
  80168. static CreateDisc(options: {
  80169. radius?: number;
  80170. tessellation?: number;
  80171. arc?: number;
  80172. sideOrientation?: number;
  80173. frontUVs?: Vector4;
  80174. backUVs?: Vector4;
  80175. }): VertexData;
  80176. /**
  80177. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80178. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80179. * @param polygon a mesh built from polygonTriangulation.build()
  80180. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80181. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80182. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80183. * @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)
  80184. * @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)
  80185. * @returns the VertexData of the Polygon
  80186. */
  80187. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80188. /**
  80189. * Creates the VertexData of the IcoSphere
  80190. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80191. * * radius the radius of the IcoSphere, optional default 1
  80192. * * radiusX allows stretching in the x direction, optional, default radius
  80193. * * radiusY allows stretching in the y direction, optional, default radius
  80194. * * radiusZ allows stretching in the z direction, optional, default radius
  80195. * * flat when true creates a flat shaded mesh, optional, default true
  80196. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80198. * * 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)
  80199. * * 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)
  80200. * @returns the VertexData of the IcoSphere
  80201. */
  80202. static CreateIcoSphere(options: {
  80203. radius?: number;
  80204. radiusX?: number;
  80205. radiusY?: number;
  80206. radiusZ?: number;
  80207. flat?: boolean;
  80208. subdivisions?: number;
  80209. sideOrientation?: number;
  80210. frontUVs?: Vector4;
  80211. backUVs?: Vector4;
  80212. }): VertexData;
  80213. /**
  80214. * Creates the VertexData for a Polyhedron
  80215. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80216. * * type provided types are:
  80217. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80218. * * 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)
  80219. * * size the size of the IcoSphere, optional default 1
  80220. * * sizeX allows stretching in the x direction, optional, default size
  80221. * * sizeY allows stretching in the y direction, optional, default size
  80222. * * sizeZ allows stretching in the z direction, optional, default size
  80223. * * 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
  80224. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80225. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80226. * * flat when true creates a flat shaded mesh, optional, default true
  80227. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80229. * * 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)
  80230. * * 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)
  80231. * @returns the VertexData of the Polyhedron
  80232. */
  80233. static CreatePolyhedron(options: {
  80234. type?: number;
  80235. size?: number;
  80236. sizeX?: number;
  80237. sizeY?: number;
  80238. sizeZ?: number;
  80239. custom?: any;
  80240. faceUV?: Vector4[];
  80241. faceColors?: Color4[];
  80242. flat?: boolean;
  80243. sideOrientation?: number;
  80244. frontUVs?: Vector4;
  80245. backUVs?: Vector4;
  80246. }): VertexData;
  80247. /**
  80248. * Creates the VertexData for a TorusKnot
  80249. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80250. * * radius the radius of the torus knot, optional, default 2
  80251. * * tube the thickness of the tube, optional, default 0.5
  80252. * * radialSegments the number of sides on each tube segments, optional, default 32
  80253. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80254. * * p the number of windings around the z axis, optional, default 2
  80255. * * q the number of windings around the x axis, optional, default 3
  80256. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80257. * * 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)
  80258. * * 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)
  80259. * @returns the VertexData of the Torus Knot
  80260. */
  80261. static CreateTorusKnot(options: {
  80262. radius?: number;
  80263. tube?: number;
  80264. radialSegments?: number;
  80265. tubularSegments?: number;
  80266. p?: number;
  80267. q?: number;
  80268. sideOrientation?: number;
  80269. frontUVs?: Vector4;
  80270. backUVs?: Vector4;
  80271. }): VertexData;
  80272. /**
  80273. * Compute normals for given positions and indices
  80274. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80275. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80276. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80277. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80278. * * facetNormals : optional array of facet normals (vector3)
  80279. * * facetPositions : optional array of facet positions (vector3)
  80280. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80281. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80282. * * bInfo : optional bounding info, required for facetPartitioning computation
  80283. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80284. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80285. * * useRightHandedSystem: optional boolean to for right handed system computation
  80286. * * depthSort : optional boolean to enable the facet depth sort computation
  80287. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80288. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80289. */
  80290. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80291. facetNormals?: any;
  80292. facetPositions?: any;
  80293. facetPartitioning?: any;
  80294. ratio?: number;
  80295. bInfo?: any;
  80296. bbSize?: Vector3;
  80297. subDiv?: any;
  80298. useRightHandedSystem?: boolean;
  80299. depthSort?: boolean;
  80300. distanceTo?: Vector3;
  80301. depthSortedFacets?: any;
  80302. }): void;
  80303. /** @hidden */
  80304. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80305. /**
  80306. * Applies VertexData created from the imported parameters to the geometry
  80307. * @param parsedVertexData the parsed data from an imported file
  80308. * @param geometry the geometry to apply the VertexData to
  80309. */
  80310. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80311. }
  80312. }
  80313. declare module BABYLON {
  80314. /**
  80315. * Class containing static functions to help procedurally build meshes
  80316. */
  80317. export class DiscBuilder {
  80318. /**
  80319. * Creates a plane polygonal mesh. By default, this is a disc
  80320. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80321. * * 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
  80322. * * 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
  80323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80324. * * If you create a double-sided mesh, you can choose what parts of 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
  80325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80326. * @param name defines the name of the mesh
  80327. * @param options defines the options used to create the mesh
  80328. * @param scene defines the hosting scene
  80329. * @returns the plane polygonal mesh
  80330. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80331. */
  80332. static CreateDisc(name: string, options: {
  80333. radius?: number;
  80334. tessellation?: number;
  80335. arc?: number;
  80336. updatable?: boolean;
  80337. sideOrientation?: number;
  80338. frontUVs?: Vector4;
  80339. backUVs?: Vector4;
  80340. }, scene?: Nullable<Scene>): Mesh;
  80341. }
  80342. }
  80343. declare module BABYLON {
  80344. /**
  80345. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80346. *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.
  80347. * The SPS is also a particle system. It provides some methods to manage the particles.
  80348. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80349. *
  80350. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80351. */
  80352. export class SolidParticleSystem implements IDisposable {
  80353. /**
  80354. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80355. * Example : var p = SPS.particles[i];
  80356. */
  80357. particles: SolidParticle[];
  80358. /**
  80359. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80360. */
  80361. nbParticles: number;
  80362. /**
  80363. * If the particles must ever face the camera (default false). Useful for planar particles.
  80364. */
  80365. billboard: boolean;
  80366. /**
  80367. * Recompute normals when adding a shape
  80368. */
  80369. recomputeNormals: boolean;
  80370. /**
  80371. * This a counter ofr your own usage. It's not set by any SPS functions.
  80372. */
  80373. counter: number;
  80374. /**
  80375. * The SPS name. This name is also given to the underlying mesh.
  80376. */
  80377. name: string;
  80378. /**
  80379. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80380. */
  80381. mesh: Mesh;
  80382. /**
  80383. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80384. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80385. */
  80386. vars: any;
  80387. /**
  80388. * This array is populated when the SPS is set as 'pickable'.
  80389. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80390. * Each element of this array is an object `{idx: int, faceId: int}`.
  80391. * `idx` is the picked particle index in the `SPS.particles` array
  80392. * `faceId` is the picked face index counted within this particle.
  80393. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80394. */
  80395. pickedParticles: {
  80396. idx: number;
  80397. faceId: number;
  80398. }[];
  80399. /**
  80400. * This array is populated when `enableDepthSort` is set to true.
  80401. * Each element of this array is an instance of the class DepthSortedParticle.
  80402. */
  80403. depthSortedParticles: DepthSortedParticle[];
  80404. /**
  80405. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80406. * @hidden
  80407. */
  80408. _bSphereOnly: boolean;
  80409. /**
  80410. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80411. * @hidden
  80412. */
  80413. _bSphereRadiusFactor: number;
  80414. private _scene;
  80415. private _positions;
  80416. private _indices;
  80417. private _normals;
  80418. private _colors;
  80419. private _uvs;
  80420. private _indices32;
  80421. private _positions32;
  80422. private _normals32;
  80423. private _fixedNormal32;
  80424. private _colors32;
  80425. private _uvs32;
  80426. private _index;
  80427. private _updatable;
  80428. private _pickable;
  80429. private _isVisibilityBoxLocked;
  80430. private _alwaysVisible;
  80431. private _depthSort;
  80432. private _shapeCounter;
  80433. private _copy;
  80434. private _color;
  80435. private _computeParticleColor;
  80436. private _computeParticleTexture;
  80437. private _computeParticleRotation;
  80438. private _computeParticleVertex;
  80439. private _computeBoundingBox;
  80440. private _depthSortParticles;
  80441. private _camera;
  80442. private _mustUnrotateFixedNormals;
  80443. private _particlesIntersect;
  80444. private _needs32Bits;
  80445. /**
  80446. * Creates a SPS (Solid Particle System) object.
  80447. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80448. * @param scene (Scene) is the scene in which the SPS is added.
  80449. * @param options defines the options of the sps e.g.
  80450. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80451. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80452. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80453. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80454. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80455. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80456. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80457. */
  80458. constructor(name: string, scene: Scene, options?: {
  80459. updatable?: boolean;
  80460. isPickable?: boolean;
  80461. enableDepthSort?: boolean;
  80462. particleIntersection?: boolean;
  80463. boundingSphereOnly?: boolean;
  80464. bSphereRadiusFactor?: number;
  80465. });
  80466. /**
  80467. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80468. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80469. * @returns the created mesh
  80470. */
  80471. buildMesh(): Mesh;
  80472. /**
  80473. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80474. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80475. * Thus the particles generated from `digest()` have their property `position` set yet.
  80476. * @param mesh ( Mesh ) is the mesh to be digested
  80477. * @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
  80478. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80479. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80480. * @returns the current SPS
  80481. */
  80482. digest(mesh: Mesh, options?: {
  80483. facetNb?: number;
  80484. number?: number;
  80485. delta?: number;
  80486. }): SolidParticleSystem;
  80487. private _unrotateFixedNormals;
  80488. private _resetCopy;
  80489. private _meshBuilder;
  80490. private _posToShape;
  80491. private _uvsToShapeUV;
  80492. private _addParticle;
  80493. /**
  80494. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80495. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80496. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80497. * @param nb (positive integer) the number of particles to be created from this model
  80498. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80499. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80500. * @returns the number of shapes in the system
  80501. */
  80502. addShape(mesh: Mesh, nb: number, options?: {
  80503. positionFunction?: any;
  80504. vertexFunction?: any;
  80505. }): number;
  80506. private _rebuildParticle;
  80507. /**
  80508. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80509. * @returns the SPS.
  80510. */
  80511. rebuildMesh(): SolidParticleSystem;
  80512. /**
  80513. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80514. * This method calls `updateParticle()` for each particle of the SPS.
  80515. * For an animated SPS, it is usually called within the render loop.
  80516. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80517. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80518. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80519. * @returns the SPS.
  80520. */
  80521. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80522. /**
  80523. * Disposes the SPS.
  80524. */
  80525. dispose(): void;
  80526. /**
  80527. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80529. * @returns the SPS.
  80530. */
  80531. refreshVisibleSize(): SolidParticleSystem;
  80532. /**
  80533. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80534. * @param size the size (float) of the visibility box
  80535. * note : this doesn't lock the SPS mesh bounding box.
  80536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80537. */
  80538. setVisibilityBox(size: number): void;
  80539. /**
  80540. * Gets whether the SPS as always visible or not
  80541. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80542. */
  80543. /**
  80544. * Sets the SPS as always visible or not
  80545. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80546. */
  80547. isAlwaysVisible: boolean;
  80548. /**
  80549. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80550. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80551. */
  80552. /**
  80553. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80554. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80555. */
  80556. isVisibilityBoxLocked: boolean;
  80557. /**
  80558. * Tells to `setParticles()` to compute the particle rotations or not.
  80559. * Default value : true. The SPS is faster when it's set to false.
  80560. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80561. */
  80562. /**
  80563. * Gets if `setParticles()` computes the particle rotations or not.
  80564. * Default value : true. The SPS is faster when it's set to false.
  80565. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80566. */
  80567. computeParticleRotation: boolean;
  80568. /**
  80569. * Tells to `setParticles()` to compute the particle colors or not.
  80570. * Default value : true. The SPS is faster when it's set to false.
  80571. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80572. */
  80573. /**
  80574. * Gets if `setParticles()` computes the particle colors or not.
  80575. * Default value : true. The SPS is faster when it's set to false.
  80576. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80577. */
  80578. computeParticleColor: boolean;
  80579. /**
  80580. * Gets if `setParticles()` computes the particle textures or not.
  80581. * Default value : true. The SPS is faster when it's set to false.
  80582. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80583. */
  80584. computeParticleTexture: boolean;
  80585. /**
  80586. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80587. * Default value : false. The SPS is faster when it's set to false.
  80588. * Note : the particle custom vertex positions aren't stored values.
  80589. */
  80590. /**
  80591. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80592. * Default value : false. The SPS is faster when it's set to false.
  80593. * Note : the particle custom vertex positions aren't stored values.
  80594. */
  80595. computeParticleVertex: boolean;
  80596. /**
  80597. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80598. */
  80599. /**
  80600. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80601. */
  80602. computeBoundingBox: boolean;
  80603. /**
  80604. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80605. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80606. * Default : `true`
  80607. */
  80608. /**
  80609. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80610. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80611. * Default : `true`
  80612. */
  80613. depthSortParticles: boolean;
  80614. /**
  80615. * This function does nothing. It may be overwritten to set all the particle first values.
  80616. * The SPS doesn't call this function, you may have to call it by your own.
  80617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80618. */
  80619. initParticles(): void;
  80620. /**
  80621. * This function does nothing. It may be overwritten to recycle a particle.
  80622. * The SPS doesn't call this function, you may have to call it by your own.
  80623. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80624. * @param particle The particle to recycle
  80625. * @returns the recycled particle
  80626. */
  80627. recycleParticle(particle: SolidParticle): SolidParticle;
  80628. /**
  80629. * Updates a particle : this function should be overwritten by the user.
  80630. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80632. * @example : just set a particle position or velocity and recycle conditions
  80633. * @param particle The particle to update
  80634. * @returns the updated particle
  80635. */
  80636. updateParticle(particle: SolidParticle): SolidParticle;
  80637. /**
  80638. * Updates a vertex of a particle : it can be overwritten by the user.
  80639. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80640. * @param particle the current particle
  80641. * @param vertex the current index of the current particle
  80642. * @param pt the index of the current vertex in the particle shape
  80643. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80644. * @example : just set a vertex particle position
  80645. * @returns the updated vertex
  80646. */
  80647. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80648. /**
  80649. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80650. * This does nothing and may be overwritten by the user.
  80651. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80652. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80653. * @param update the boolean update value actually passed to setParticles()
  80654. */
  80655. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80656. /**
  80657. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80658. * This will be passed three parameters.
  80659. * This does nothing and may be overwritten by the user.
  80660. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80661. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80662. * @param update the boolean update value actually passed to setParticles()
  80663. */
  80664. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80665. }
  80666. }
  80667. declare module BABYLON {
  80668. /**
  80669. * Represents one particle of a solid particle system.
  80670. */
  80671. export class SolidParticle {
  80672. /**
  80673. * particle global index
  80674. */
  80675. idx: number;
  80676. /**
  80677. * The color of the particle
  80678. */
  80679. color: Nullable<Color4>;
  80680. /**
  80681. * The world space position of the particle.
  80682. */
  80683. position: Vector3;
  80684. /**
  80685. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80686. */
  80687. rotation: Vector3;
  80688. /**
  80689. * The world space rotation quaternion of the particle.
  80690. */
  80691. rotationQuaternion: Nullable<Quaternion>;
  80692. /**
  80693. * The scaling of the particle.
  80694. */
  80695. scaling: Vector3;
  80696. /**
  80697. * The uvs of the particle.
  80698. */
  80699. uvs: Vector4;
  80700. /**
  80701. * The current speed of the particle.
  80702. */
  80703. velocity: Vector3;
  80704. /**
  80705. * The pivot point in the particle local space.
  80706. */
  80707. pivot: Vector3;
  80708. /**
  80709. * Must the particle be translated from its pivot point in its local space ?
  80710. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80711. * Default : false
  80712. */
  80713. translateFromPivot: boolean;
  80714. /**
  80715. * Is the particle active or not ?
  80716. */
  80717. alive: boolean;
  80718. /**
  80719. * Is the particle visible or not ?
  80720. */
  80721. isVisible: boolean;
  80722. /**
  80723. * Index of this particle in the global "positions" array (Internal use)
  80724. * @hidden
  80725. */
  80726. _pos: number;
  80727. /**
  80728. * @hidden Index of this particle in the global "indices" array (Internal use)
  80729. */
  80730. _ind: number;
  80731. /**
  80732. * @hidden ModelShape of this particle (Internal use)
  80733. */
  80734. _model: ModelShape;
  80735. /**
  80736. * ModelShape id of this particle
  80737. */
  80738. shapeId: number;
  80739. /**
  80740. * Index of the particle in its shape id (Internal use)
  80741. */
  80742. idxInShape: number;
  80743. /**
  80744. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80745. */
  80746. _modelBoundingInfo: BoundingInfo;
  80747. /**
  80748. * @hidden Particle BoundingInfo object (Internal use)
  80749. */
  80750. _boundingInfo: BoundingInfo;
  80751. /**
  80752. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80753. */
  80754. _sps: SolidParticleSystem;
  80755. /**
  80756. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80757. */
  80758. _stillInvisible: boolean;
  80759. /**
  80760. * @hidden Last computed particle rotation matrix
  80761. */
  80762. _rotationMatrix: number[];
  80763. /**
  80764. * Parent particle Id, if any.
  80765. * Default null.
  80766. */
  80767. parentId: Nullable<number>;
  80768. /**
  80769. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80770. * The possible values are :
  80771. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80772. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80773. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80774. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80775. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80776. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80777. * */
  80778. cullingStrategy: number;
  80779. /**
  80780. * @hidden Internal global position in the SPS.
  80781. */
  80782. _globalPosition: Vector3;
  80783. /**
  80784. * Creates a Solid Particle object.
  80785. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80786. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80787. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80788. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80789. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80790. * @param shapeId (integer) is the model shape identifier in the SPS.
  80791. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80792. * @param sps defines the sps it is associated to
  80793. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80794. */
  80795. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80796. /**
  80797. * Legacy support, changed scale to scaling
  80798. */
  80799. /**
  80800. * Legacy support, changed scale to scaling
  80801. */
  80802. scale: Vector3;
  80803. /**
  80804. * Legacy support, changed quaternion to rotationQuaternion
  80805. */
  80806. /**
  80807. * Legacy support, changed quaternion to rotationQuaternion
  80808. */
  80809. quaternion: Nullable<Quaternion>;
  80810. /**
  80811. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80812. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80813. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80814. * @returns true if it intersects
  80815. */
  80816. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80817. /**
  80818. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80819. * A particle is in the frustum if its bounding box intersects the frustum
  80820. * @param frustumPlanes defines the frustum to test
  80821. * @returns true if the particle is in the frustum planes
  80822. */
  80823. isInFrustum(frustumPlanes: Plane[]): boolean;
  80824. /**
  80825. * get the rotation matrix of the particle
  80826. * @hidden
  80827. */
  80828. getRotationMatrix(m: Matrix): void;
  80829. }
  80830. /**
  80831. * Represents the shape of the model used by one particle of a solid particle system.
  80832. * SPS internal tool, don't use it manually.
  80833. */
  80834. export class ModelShape {
  80835. /**
  80836. * The shape id
  80837. * @hidden
  80838. */
  80839. shapeID: number;
  80840. /**
  80841. * flat array of model positions (internal use)
  80842. * @hidden
  80843. */
  80844. _shape: Vector3[];
  80845. /**
  80846. * flat array of model UVs (internal use)
  80847. * @hidden
  80848. */
  80849. _shapeUV: number[];
  80850. /**
  80851. * length of the shape in the model indices array (internal use)
  80852. * @hidden
  80853. */
  80854. _indicesLength: number;
  80855. /**
  80856. * Custom position function (internal use)
  80857. * @hidden
  80858. */
  80859. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80860. /**
  80861. * Custom vertex function (internal use)
  80862. * @hidden
  80863. */
  80864. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80865. /**
  80866. * 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.
  80867. * SPS internal tool, don't use it manually.
  80868. * @hidden
  80869. */
  80870. 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>);
  80871. }
  80872. /**
  80873. * Represents a Depth Sorted Particle in the solid particle system.
  80874. */
  80875. export class DepthSortedParticle {
  80876. /**
  80877. * Index of the particle in the "indices" array
  80878. */
  80879. ind: number;
  80880. /**
  80881. * Length of the particle shape in the "indices" array
  80882. */
  80883. indicesLength: number;
  80884. /**
  80885. * Squared distance from the particle to the camera
  80886. */
  80887. sqDistance: number;
  80888. }
  80889. }
  80890. declare module BABYLON {
  80891. /**
  80892. * Class used to store all common mesh properties
  80893. */
  80894. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80895. /** No occlusion */
  80896. static OCCLUSION_TYPE_NONE: number;
  80897. /** Occlusion set to optimisitic */
  80898. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80899. /** Occlusion set to strict */
  80900. static OCCLUSION_TYPE_STRICT: number;
  80901. /** Use an accurante occlusion algorithm */
  80902. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80903. /** Use a conservative occlusion algorithm */
  80904. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80905. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80906. * Test order :
  80907. * Is the bounding sphere outside the frustum ?
  80908. * If not, are the bounding box vertices outside the frustum ?
  80909. * It not, then the cullable object is in the frustum.
  80910. */
  80911. static readonly CULLINGSTRATEGY_STANDARD: number;
  80912. /** Culling strategy : Bounding Sphere Only.
  80913. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80914. * It's also less accurate than the standard because some not visible objects can still be selected.
  80915. * Test : is the bounding sphere outside the frustum ?
  80916. * If not, then the cullable object is in the frustum.
  80917. */
  80918. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80919. /** Culling strategy : Optimistic Inclusion.
  80920. * This in an inclusion test first, then the standard exclusion test.
  80921. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80922. * 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.
  80923. * Anyway, it's as accurate as the standard strategy.
  80924. * Test :
  80925. * Is the cullable object bounding sphere center in the frustum ?
  80926. * If not, apply the default culling strategy.
  80927. */
  80928. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80929. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80930. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80931. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80932. * 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.
  80933. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80934. * Test :
  80935. * Is the cullable object bounding sphere center in the frustum ?
  80936. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80937. */
  80938. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80939. /**
  80940. * No billboard
  80941. */
  80942. static readonly BILLBOARDMODE_NONE: number;
  80943. /** Billboard on X axis */
  80944. static readonly BILLBOARDMODE_X: number;
  80945. /** Billboard on Y axis */
  80946. static readonly BILLBOARDMODE_Y: number;
  80947. /** Billboard on Z axis */
  80948. static readonly BILLBOARDMODE_Z: number;
  80949. /** Billboard on all axes */
  80950. static readonly BILLBOARDMODE_ALL: number;
  80951. private _facetData;
  80952. /**
  80953. * The culling strategy to use to check whether the mesh must be rendered or not.
  80954. * This value can be changed at any time and will be used on the next render mesh selection.
  80955. * The possible values are :
  80956. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80957. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80958. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80959. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80960. * Please read each static variable documentation to get details about the culling process.
  80961. * */
  80962. cullingStrategy: number;
  80963. /**
  80964. * Gets the number of facets in the mesh
  80965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80966. */
  80967. readonly facetNb: number;
  80968. /**
  80969. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80971. */
  80972. partitioningSubdivisions: number;
  80973. /**
  80974. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80975. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80977. */
  80978. partitioningBBoxRatio: number;
  80979. /**
  80980. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80981. * Works only for updatable meshes.
  80982. * Doesn't work with multi-materials
  80983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80984. */
  80985. mustDepthSortFacets: boolean;
  80986. /**
  80987. * The location (Vector3) where the facet depth sort must be computed from.
  80988. * By default, the active camera position.
  80989. * Used only when facet depth sort is enabled
  80990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80991. */
  80992. facetDepthSortFrom: Vector3;
  80993. /**
  80994. * gets a boolean indicating if facetData is enabled
  80995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80996. */
  80997. readonly isFacetDataEnabled: boolean;
  80998. /** @hidden */
  80999. _updateNonUniformScalingState(value: boolean): boolean;
  81000. /**
  81001. * An event triggered when this mesh collides with another one
  81002. */
  81003. onCollideObservable: Observable<AbstractMesh>;
  81004. private _onCollideObserver;
  81005. /** Set a function to call when this mesh collides with another one */
  81006. onCollide: () => void;
  81007. /**
  81008. * An event triggered when the collision's position changes
  81009. */
  81010. onCollisionPositionChangeObservable: Observable<Vector3>;
  81011. private _onCollisionPositionChangeObserver;
  81012. /** Set a function to call when the collision's position changes */
  81013. onCollisionPositionChange: () => void;
  81014. /**
  81015. * An event triggered when material is changed
  81016. */
  81017. onMaterialChangedObservable: Observable<AbstractMesh>;
  81018. /**
  81019. * Gets or sets the orientation for POV movement & rotation
  81020. */
  81021. definedFacingForward: boolean;
  81022. /** @hidden */
  81023. _occlusionQuery: Nullable<WebGLQuery>;
  81024. private _visibility;
  81025. /**
  81026. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81027. */
  81028. /**
  81029. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81030. */
  81031. visibility: number;
  81032. /** Gets or sets the alpha index used to sort transparent meshes
  81033. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81034. */
  81035. alphaIndex: number;
  81036. /**
  81037. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81038. */
  81039. isVisible: boolean;
  81040. /**
  81041. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81042. */
  81043. isPickable: boolean;
  81044. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81045. showSubMeshesBoundingBox: boolean;
  81046. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81047. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81048. */
  81049. isBlocker: boolean;
  81050. /**
  81051. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81052. */
  81053. enablePointerMoveEvents: boolean;
  81054. /**
  81055. * Specifies the rendering group id for this mesh (0 by default)
  81056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81057. */
  81058. renderingGroupId: number;
  81059. private _material;
  81060. /** Gets or sets current material */
  81061. material: Nullable<Material>;
  81062. private _receiveShadows;
  81063. /**
  81064. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81065. * @see http://doc.babylonjs.com/babylon101/shadows
  81066. */
  81067. receiveShadows: boolean;
  81068. /** Defines color to use when rendering outline */
  81069. outlineColor: Color3;
  81070. /** Define width to use when rendering outline */
  81071. outlineWidth: number;
  81072. /** Defines color to use when rendering overlay */
  81073. overlayColor: Color3;
  81074. /** Defines alpha to use when rendering overlay */
  81075. overlayAlpha: number;
  81076. private _hasVertexAlpha;
  81077. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81078. hasVertexAlpha: boolean;
  81079. private _useVertexColors;
  81080. /** 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) */
  81081. useVertexColors: boolean;
  81082. private _computeBonesUsingShaders;
  81083. /**
  81084. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81085. */
  81086. computeBonesUsingShaders: boolean;
  81087. private _numBoneInfluencers;
  81088. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81089. numBoneInfluencers: number;
  81090. private _applyFog;
  81091. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81092. applyFog: boolean;
  81093. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81094. useOctreeForRenderingSelection: boolean;
  81095. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81096. useOctreeForPicking: boolean;
  81097. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81098. useOctreeForCollisions: boolean;
  81099. private _layerMask;
  81100. /**
  81101. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81102. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81103. */
  81104. layerMask: number;
  81105. /**
  81106. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81107. */
  81108. alwaysSelectAsActiveMesh: boolean;
  81109. /**
  81110. * Gets or sets the current action manager
  81111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81112. */
  81113. actionManager: Nullable<AbstractActionManager>;
  81114. private _checkCollisions;
  81115. private _collisionMask;
  81116. private _collisionGroup;
  81117. /**
  81118. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81120. */
  81121. ellipsoid: Vector3;
  81122. /**
  81123. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81124. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81125. */
  81126. ellipsoidOffset: Vector3;
  81127. private _collider;
  81128. private _oldPositionForCollisions;
  81129. private _diffPositionForCollisions;
  81130. /**
  81131. * Gets or sets a collision mask used to mask collisions (default is -1).
  81132. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81133. */
  81134. collisionMask: number;
  81135. /**
  81136. * Gets or sets the current collision group mask (-1 by default).
  81137. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81138. */
  81139. collisionGroup: number;
  81140. /**
  81141. * Defines edge width used when edgesRenderer is enabled
  81142. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81143. */
  81144. edgesWidth: number;
  81145. /**
  81146. * Defines edge color used when edgesRenderer is enabled
  81147. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81148. */
  81149. edgesColor: Color4;
  81150. /** @hidden */
  81151. _edgesRenderer: Nullable<IEdgesRenderer>;
  81152. /** @hidden */
  81153. _masterMesh: Nullable<AbstractMesh>;
  81154. /** @hidden */
  81155. _boundingInfo: Nullable<BoundingInfo>;
  81156. /** @hidden */
  81157. _renderId: number;
  81158. /**
  81159. * Gets or sets the list of subMeshes
  81160. * @see http://doc.babylonjs.com/how_to/multi_materials
  81161. */
  81162. subMeshes: SubMesh[];
  81163. /** @hidden */
  81164. _intersectionsInProgress: AbstractMesh[];
  81165. /** @hidden */
  81166. _unIndexed: boolean;
  81167. /** @hidden */
  81168. _lightSources: Light[];
  81169. /** @hidden */
  81170. readonly _positions: Nullable<Vector3[]>;
  81171. /** @hidden */
  81172. _waitingActions: any;
  81173. /** @hidden */
  81174. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81175. private _skeleton;
  81176. /** @hidden */
  81177. _bonesTransformMatrices: Nullable<Float32Array>;
  81178. /**
  81179. * Gets or sets a skeleton to apply skining transformations
  81180. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81181. */
  81182. skeleton: Nullable<Skeleton>;
  81183. /**
  81184. * An event triggered when the mesh is rebuilt.
  81185. */
  81186. onRebuildObservable: Observable<AbstractMesh>;
  81187. /**
  81188. * Creates a new AbstractMesh
  81189. * @param name defines the name of the mesh
  81190. * @param scene defines the hosting scene
  81191. */
  81192. constructor(name: string, scene?: Nullable<Scene>);
  81193. /**
  81194. * Returns the string "AbstractMesh"
  81195. * @returns "AbstractMesh"
  81196. */
  81197. getClassName(): string;
  81198. /**
  81199. * Gets a string representation of the current mesh
  81200. * @param fullDetails defines a boolean indicating if full details must be included
  81201. * @returns a string representation of the current mesh
  81202. */
  81203. toString(fullDetails?: boolean): string;
  81204. /** @hidden */
  81205. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81206. /** @hidden */
  81207. _rebuild(): void;
  81208. /** @hidden */
  81209. _resyncLightSources(): void;
  81210. /** @hidden */
  81211. _resyncLighSource(light: Light): void;
  81212. /** @hidden */
  81213. _unBindEffect(): void;
  81214. /** @hidden */
  81215. _removeLightSource(light: Light): void;
  81216. private _markSubMeshesAsDirty;
  81217. /** @hidden */
  81218. _markSubMeshesAsLightDirty(): void;
  81219. /** @hidden */
  81220. _markSubMeshesAsAttributesDirty(): void;
  81221. /** @hidden */
  81222. _markSubMeshesAsMiscDirty(): void;
  81223. /**
  81224. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81225. */
  81226. scaling: Vector3;
  81227. /**
  81228. * Returns true if the mesh is blocked. Implemented by child classes
  81229. */
  81230. readonly isBlocked: boolean;
  81231. /**
  81232. * Returns the mesh itself by default. Implemented by child classes
  81233. * @param camera defines the camera to use to pick the right LOD level
  81234. * @returns the currentAbstractMesh
  81235. */
  81236. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81237. /**
  81238. * Returns 0 by default. Implemented by child classes
  81239. * @returns an integer
  81240. */
  81241. getTotalVertices(): number;
  81242. /**
  81243. * Returns a positive integer : the total number of indices in this mesh geometry.
  81244. * @returns the numner of indices or zero if the mesh has no geometry.
  81245. */
  81246. getTotalIndices(): number;
  81247. /**
  81248. * Returns null by default. Implemented by child classes
  81249. * @returns null
  81250. */
  81251. getIndices(): Nullable<IndicesArray>;
  81252. /**
  81253. * Returns the array of the requested vertex data kind. Implemented by child classes
  81254. * @param kind defines the vertex data kind to use
  81255. * @returns null
  81256. */
  81257. getVerticesData(kind: string): Nullable<FloatArray>;
  81258. /**
  81259. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81260. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81261. * Note that a new underlying VertexBuffer object is created each call.
  81262. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81263. * @param kind defines vertex data kind:
  81264. * * VertexBuffer.PositionKind
  81265. * * VertexBuffer.UVKind
  81266. * * VertexBuffer.UV2Kind
  81267. * * VertexBuffer.UV3Kind
  81268. * * VertexBuffer.UV4Kind
  81269. * * VertexBuffer.UV5Kind
  81270. * * VertexBuffer.UV6Kind
  81271. * * VertexBuffer.ColorKind
  81272. * * VertexBuffer.MatricesIndicesKind
  81273. * * VertexBuffer.MatricesIndicesExtraKind
  81274. * * VertexBuffer.MatricesWeightsKind
  81275. * * VertexBuffer.MatricesWeightsExtraKind
  81276. * @param data defines the data source
  81277. * @param updatable defines if the data must be flagged as updatable (or static)
  81278. * @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
  81279. * @returns the current mesh
  81280. */
  81281. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81282. /**
  81283. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81284. * If the mesh has no geometry, it is simply returned as it is.
  81285. * @param kind defines vertex data kind:
  81286. * * VertexBuffer.PositionKind
  81287. * * VertexBuffer.UVKind
  81288. * * VertexBuffer.UV2Kind
  81289. * * VertexBuffer.UV3Kind
  81290. * * VertexBuffer.UV4Kind
  81291. * * VertexBuffer.UV5Kind
  81292. * * VertexBuffer.UV6Kind
  81293. * * VertexBuffer.ColorKind
  81294. * * VertexBuffer.MatricesIndicesKind
  81295. * * VertexBuffer.MatricesIndicesExtraKind
  81296. * * VertexBuffer.MatricesWeightsKind
  81297. * * VertexBuffer.MatricesWeightsExtraKind
  81298. * @param data defines the data source
  81299. * @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
  81300. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81301. * @returns the current mesh
  81302. */
  81303. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81304. /**
  81305. * Sets the mesh indices,
  81306. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81307. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81308. * @param totalVertices Defines the total number of vertices
  81309. * @returns the current mesh
  81310. */
  81311. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81312. /**
  81313. * Gets a boolean indicating if specific vertex data is present
  81314. * @param kind defines the vertex data kind to use
  81315. * @returns true is data kind is present
  81316. */
  81317. isVerticesDataPresent(kind: string): boolean;
  81318. /**
  81319. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81320. * @returns a BoundingInfo
  81321. */
  81322. getBoundingInfo(): BoundingInfo;
  81323. /**
  81324. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81325. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81326. * @returns the current mesh
  81327. */
  81328. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81329. /**
  81330. * Overwrite the current bounding info
  81331. * @param boundingInfo defines the new bounding info
  81332. * @returns the current mesh
  81333. */
  81334. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81335. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81336. readonly useBones: boolean;
  81337. /** @hidden */
  81338. _preActivate(): void;
  81339. /** @hidden */
  81340. _preActivateForIntermediateRendering(renderId: number): void;
  81341. /** @hidden */
  81342. _activate(renderId: number): void;
  81343. /**
  81344. * Gets the current world matrix
  81345. * @returns a Matrix
  81346. */
  81347. getWorldMatrix(): Matrix;
  81348. /** @hidden */
  81349. _getWorldMatrixDeterminant(): number;
  81350. /**
  81351. * Perform relative position change from the point of view of behind the front of the mesh.
  81352. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81353. * Supports definition of mesh facing forward or backward
  81354. * @param amountRight defines the distance on the right axis
  81355. * @param amountUp defines the distance on the up axis
  81356. * @param amountForward defines the distance on the forward axis
  81357. * @returns the current mesh
  81358. */
  81359. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81360. /**
  81361. * Calculate relative position change from the point of view of behind the front of the mesh.
  81362. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81363. * Supports definition of mesh facing forward or backward
  81364. * @param amountRight defines the distance on the right axis
  81365. * @param amountUp defines the distance on the up axis
  81366. * @param amountForward defines the distance on the forward axis
  81367. * @returns the new displacement vector
  81368. */
  81369. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81370. /**
  81371. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81372. * Supports definition of mesh facing forward or backward
  81373. * @param flipBack defines the flip
  81374. * @param twirlClockwise defines the twirl
  81375. * @param tiltRight defines the tilt
  81376. * @returns the current mesh
  81377. */
  81378. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81379. /**
  81380. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81381. * Supports definition of mesh facing forward or backward.
  81382. * @param flipBack defines the flip
  81383. * @param twirlClockwise defines the twirl
  81384. * @param tiltRight defines the tilt
  81385. * @returns the new rotation vector
  81386. */
  81387. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81388. /**
  81389. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81390. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81391. * @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
  81392. * @returns the new bounding vectors
  81393. */
  81394. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81395. min: Vector3;
  81396. max: Vector3;
  81397. };
  81398. /**
  81399. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81400. * This means the mesh underlying bounding box and sphere are recomputed.
  81401. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81402. * @returns the current mesh
  81403. */
  81404. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81405. /** @hidden */
  81406. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81407. /** @hidden */
  81408. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81409. /** @hidden */
  81410. _updateBoundingInfo(): AbstractMesh;
  81411. /** @hidden */
  81412. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81413. /** @hidden */
  81414. protected _afterComputeWorldMatrix(): void;
  81415. /**
  81416. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81417. * A mesh is in the frustum if its bounding box intersects the frustum
  81418. * @param frustumPlanes defines the frustum to test
  81419. * @returns true if the mesh is in the frustum planes
  81420. */
  81421. isInFrustum(frustumPlanes: Plane[]): boolean;
  81422. /**
  81423. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81424. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81425. * @param frustumPlanes defines the frustum to test
  81426. * @returns true if the mesh is completely in the frustum planes
  81427. */
  81428. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81429. /**
  81430. * True if the mesh intersects another mesh or a SolidParticle object
  81431. * @param mesh defines a target mesh or SolidParticle to test
  81432. * @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)
  81433. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81434. * @returns true if there is an intersection
  81435. */
  81436. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81437. /**
  81438. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81439. * @param point defines the point to test
  81440. * @returns true if there is an intersection
  81441. */
  81442. intersectsPoint(point: Vector3): boolean;
  81443. /**
  81444. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81446. */
  81447. checkCollisions: boolean;
  81448. /**
  81449. * Gets Collider object used to compute collisions (not physics)
  81450. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81451. */
  81452. readonly collider: Collider;
  81453. /**
  81454. * Move the mesh using collision engine
  81455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81456. * @param displacement defines the requested displacement vector
  81457. * @returns the current mesh
  81458. */
  81459. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81460. private _onCollisionPositionChange;
  81461. /** @hidden */
  81462. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81463. /** @hidden */
  81464. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81465. /** @hidden */
  81466. _checkCollision(collider: Collider): AbstractMesh;
  81467. /** @hidden */
  81468. _generatePointsArray(): boolean;
  81469. /**
  81470. * Checks if the passed Ray intersects with the mesh
  81471. * @param ray defines the ray to use
  81472. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81473. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81474. * @returns the picking info
  81475. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81476. */
  81477. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81478. /**
  81479. * Clones the current mesh
  81480. * @param name defines the mesh name
  81481. * @param newParent defines the new mesh parent
  81482. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81483. * @returns the new mesh
  81484. */
  81485. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81486. /**
  81487. * Disposes all the submeshes of the current meshnp
  81488. * @returns the current mesh
  81489. */
  81490. releaseSubMeshes(): AbstractMesh;
  81491. /**
  81492. * Releases resources associated with this abstract mesh.
  81493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81495. */
  81496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81497. /**
  81498. * Adds the passed mesh as a child to the current mesh
  81499. * @param mesh defines the child mesh
  81500. * @returns the current mesh
  81501. */
  81502. addChild(mesh: AbstractMesh): AbstractMesh;
  81503. /**
  81504. * Removes the passed mesh from the current mesh children list
  81505. * @param mesh defines the child mesh
  81506. * @returns the current mesh
  81507. */
  81508. removeChild(mesh: AbstractMesh): AbstractMesh;
  81509. /** @hidden */
  81510. private _initFacetData;
  81511. /**
  81512. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81513. * This method can be called within the render loop.
  81514. * 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
  81515. * @returns the current mesh
  81516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81517. */
  81518. updateFacetData(): AbstractMesh;
  81519. /**
  81520. * Returns the facetLocalNormals array.
  81521. * The normals are expressed in the mesh local spac
  81522. * @returns an array of Vector3
  81523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81524. */
  81525. getFacetLocalNormals(): Vector3[];
  81526. /**
  81527. * Returns the facetLocalPositions array.
  81528. * The facet positions are expressed in the mesh local space
  81529. * @returns an array of Vector3
  81530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81531. */
  81532. getFacetLocalPositions(): Vector3[];
  81533. /**
  81534. * Returns the facetLocalPartioning array
  81535. * @returns an array of array of numbers
  81536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81537. */
  81538. getFacetLocalPartitioning(): number[][];
  81539. /**
  81540. * Returns the i-th facet position in the world system.
  81541. * This method allocates a new Vector3 per call
  81542. * @param i defines the facet index
  81543. * @returns a new Vector3
  81544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81545. */
  81546. getFacetPosition(i: number): Vector3;
  81547. /**
  81548. * Sets the reference Vector3 with the i-th facet position in the world system
  81549. * @param i defines the facet index
  81550. * @param ref defines the target vector
  81551. * @returns the current mesh
  81552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81553. */
  81554. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81555. /**
  81556. * Returns the i-th facet normal in the world system.
  81557. * This method allocates a new Vector3 per call
  81558. * @param i defines the facet index
  81559. * @returns a new Vector3
  81560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81561. */
  81562. getFacetNormal(i: number): Vector3;
  81563. /**
  81564. * Sets the reference Vector3 with the i-th facet normal in the world system
  81565. * @param i defines the facet index
  81566. * @param ref defines the target vector
  81567. * @returns the current mesh
  81568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81569. */
  81570. getFacetNormalToRef(i: number, ref: Vector3): this;
  81571. /**
  81572. * 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)
  81573. * @param x defines x coordinate
  81574. * @param y defines y coordinate
  81575. * @param z defines z coordinate
  81576. * @returns the array of facet indexes
  81577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81578. */
  81579. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81580. /**
  81581. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81582. * @param projected sets as the (x,y,z) world projection on the facet
  81583. * @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
  81584. * @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
  81585. * @param x defines x coordinate
  81586. * @param y defines y coordinate
  81587. * @param z defines z coordinate
  81588. * @returns the face index if found (or null instead)
  81589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81590. */
  81591. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81592. /**
  81593. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81594. * @param projected sets as the (x,y,z) local projection on the facet
  81595. * @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
  81596. * @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
  81597. * @param x defines x coordinate
  81598. * @param y defines y coordinate
  81599. * @param z defines z coordinate
  81600. * @returns the face index if found (or null instead)
  81601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81602. */
  81603. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81604. /**
  81605. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81606. * @returns the parameters
  81607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81608. */
  81609. getFacetDataParameters(): any;
  81610. /**
  81611. * Disables the feature FacetData and frees the related memory
  81612. * @returns the current mesh
  81613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81614. */
  81615. disableFacetData(): AbstractMesh;
  81616. /**
  81617. * Updates the AbstractMesh indices array
  81618. * @param indices defines the data source
  81619. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81620. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  81621. * @returns the current mesh
  81622. */
  81623. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81624. /**
  81625. * Creates new normals data for the mesh
  81626. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81627. * @returns the current mesh
  81628. */
  81629. createNormals(updatable: boolean): AbstractMesh;
  81630. /**
  81631. * Align the mesh with a normal
  81632. * @param normal defines the normal to use
  81633. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81634. * @returns the current mesh
  81635. */
  81636. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81637. /** @hidden */
  81638. _checkOcclusionQuery(): boolean;
  81639. }
  81640. }
  81641. declare module BABYLON {
  81642. /**
  81643. * Interface used to define ActionEvent
  81644. */
  81645. export interface IActionEvent {
  81646. /** The mesh or sprite that triggered the action */
  81647. source: any;
  81648. /** The X mouse cursor position at the time of the event */
  81649. pointerX: number;
  81650. /** The Y mouse cursor position at the time of the event */
  81651. pointerY: number;
  81652. /** The mesh that is currently pointed at (can be null) */
  81653. meshUnderPointer: Nullable<AbstractMesh>;
  81654. /** the original (browser) event that triggered the ActionEvent */
  81655. sourceEvent?: any;
  81656. /** additional data for the event */
  81657. additionalData?: any;
  81658. }
  81659. /**
  81660. * ActionEvent is the event being sent when an action is triggered.
  81661. */
  81662. export class ActionEvent implements IActionEvent {
  81663. /** The mesh or sprite that triggered the action */
  81664. source: any;
  81665. /** The X mouse cursor position at the time of the event */
  81666. pointerX: number;
  81667. /** The Y mouse cursor position at the time of the event */
  81668. pointerY: number;
  81669. /** The mesh that is currently pointed at (can be null) */
  81670. meshUnderPointer: Nullable<AbstractMesh>;
  81671. /** the original (browser) event that triggered the ActionEvent */
  81672. sourceEvent?: any;
  81673. /** additional data for the event */
  81674. additionalData?: any;
  81675. /**
  81676. * Creates a new ActionEvent
  81677. * @param source The mesh or sprite that triggered the action
  81678. * @param pointerX The X mouse cursor position at the time of the event
  81679. * @param pointerY The Y mouse cursor position at the time of the event
  81680. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81681. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81682. * @param additionalData additional data for the event
  81683. */
  81684. constructor(
  81685. /** The mesh or sprite that triggered the action */
  81686. source: any,
  81687. /** The X mouse cursor position at the time of the event */
  81688. pointerX: number,
  81689. /** The Y mouse cursor position at the time of the event */
  81690. pointerY: number,
  81691. /** The mesh that is currently pointed at (can be null) */
  81692. meshUnderPointer: Nullable<AbstractMesh>,
  81693. /** the original (browser) event that triggered the ActionEvent */
  81694. sourceEvent?: any,
  81695. /** additional data for the event */
  81696. additionalData?: any);
  81697. /**
  81698. * Helper function to auto-create an ActionEvent from a source mesh.
  81699. * @param source The source mesh that triggered the event
  81700. * @param evt The original (browser) event
  81701. * @param additionalData additional data for the event
  81702. * @returns the new ActionEvent
  81703. */
  81704. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81705. /**
  81706. * Helper function to auto-create an ActionEvent from a source sprite
  81707. * @param source The source sprite that triggered the event
  81708. * @param scene Scene associated with the sprite
  81709. * @param evt The original (browser) event
  81710. * @param additionalData additional data for the event
  81711. * @returns the new ActionEvent
  81712. */
  81713. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81714. /**
  81715. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81716. * @param scene the scene where the event occurred
  81717. * @param evt The original (browser) event
  81718. * @returns the new ActionEvent
  81719. */
  81720. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81721. /**
  81722. * Helper function to auto-create an ActionEvent from a primitive
  81723. * @param prim defines the target primitive
  81724. * @param pointerPos defines the pointer position
  81725. * @param evt The original (browser) event
  81726. * @param additionalData additional data for the event
  81727. * @returns the new ActionEvent
  81728. */
  81729. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81730. }
  81731. }
  81732. declare module BABYLON {
  81733. /**
  81734. * Abstract class used to decouple action Manager from scene and meshes.
  81735. * Do not instantiate.
  81736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81737. */
  81738. export abstract class AbstractActionManager implements IDisposable {
  81739. /** Gets the list of active triggers */
  81740. static Triggers: {
  81741. [key: string]: number;
  81742. };
  81743. /** Gets the cursor to use when hovering items */
  81744. hoverCursor: string;
  81745. /** Gets the list of actions */
  81746. actions: IAction[];
  81747. /**
  81748. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81749. */
  81750. isRecursive: boolean;
  81751. /**
  81752. * Releases all associated resources
  81753. */
  81754. abstract dispose(): void;
  81755. /**
  81756. * Does this action manager has pointer triggers
  81757. */
  81758. abstract readonly hasPointerTriggers: boolean;
  81759. /**
  81760. * Does this action manager has pick triggers
  81761. */
  81762. abstract readonly hasPickTriggers: boolean;
  81763. /**
  81764. * Process a specific trigger
  81765. * @param trigger defines the trigger to process
  81766. * @param evt defines the event details to be processed
  81767. */
  81768. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81769. /**
  81770. * Does this action manager handles actions of any of the given triggers
  81771. * @param triggers defines the triggers to be tested
  81772. * @return a boolean indicating whether one (or more) of the triggers is handled
  81773. */
  81774. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81775. /**
  81776. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81777. * speed.
  81778. * @param triggerA defines the trigger to be tested
  81779. * @param triggerB defines the trigger to be tested
  81780. * @return a boolean indicating whether one (or more) of the triggers is handled
  81781. */
  81782. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81783. /**
  81784. * Does this action manager handles actions of a given trigger
  81785. * @param trigger defines the trigger to be tested
  81786. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81787. * @return whether the trigger is handled
  81788. */
  81789. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81790. /**
  81791. * Serialize this manager to a JSON object
  81792. * @param name defines the property name to store this manager
  81793. * @returns a JSON representation of this manager
  81794. */
  81795. abstract serialize(name: string): any;
  81796. /**
  81797. * Registers an action to this action manager
  81798. * @param action defines the action to be registered
  81799. * @return the action amended (prepared) after registration
  81800. */
  81801. abstract registerAction(action: IAction): Nullable<IAction>;
  81802. /**
  81803. * Unregisters an action to this action manager
  81804. * @param action defines the action to be unregistered
  81805. * @return a boolean indicating whether the action has been unregistered
  81806. */
  81807. abstract unregisterAction(action: IAction): Boolean;
  81808. /**
  81809. * Does exist one action manager with at least one trigger
  81810. **/
  81811. static readonly HasTriggers: boolean;
  81812. /**
  81813. * Does exist one action manager with at least one pick trigger
  81814. **/
  81815. static readonly HasPickTriggers: boolean;
  81816. /**
  81817. * Does exist one action manager that handles actions of a given trigger
  81818. * @param trigger defines the trigger to be tested
  81819. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81820. **/
  81821. static HasSpecificTrigger(trigger: number): boolean;
  81822. }
  81823. }
  81824. declare module BABYLON {
  81825. /**
  81826. * Defines how a node can be built from a string name.
  81827. */
  81828. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81829. /**
  81830. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81831. */
  81832. export class Node implements IBehaviorAware<Node> {
  81833. /** @hidden */
  81834. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81835. private static _NodeConstructors;
  81836. /**
  81837. * Add a new node constructor
  81838. * @param type defines the type name of the node to construct
  81839. * @param constructorFunc defines the constructor function
  81840. */
  81841. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81842. /**
  81843. * Returns a node constructor based on type name
  81844. * @param type defines the type name
  81845. * @param name defines the new node name
  81846. * @param scene defines the hosting scene
  81847. * @param options defines optional options to transmit to constructors
  81848. * @returns the new constructor or null
  81849. */
  81850. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81851. /**
  81852. * Gets or sets the name of the node
  81853. */
  81854. name: string;
  81855. /**
  81856. * Gets or sets the id of the node
  81857. */
  81858. id: string;
  81859. /**
  81860. * Gets or sets the unique id of the node
  81861. */
  81862. uniqueId: number;
  81863. /**
  81864. * Gets or sets a string used to store user defined state for the node
  81865. */
  81866. state: string;
  81867. /**
  81868. * Gets or sets an object used to store user defined information for the node
  81869. */
  81870. metadata: any;
  81871. /**
  81872. * For internal use only. Please do not use.
  81873. */
  81874. reservedDataStore: any;
  81875. /**
  81876. * Gets or sets a boolean used to define if the node must be serialized
  81877. */
  81878. doNotSerialize: boolean;
  81879. /** @hidden */
  81880. _isDisposed: boolean;
  81881. /**
  81882. * Gets a list of Animations associated with the node
  81883. */
  81884. animations: Animation[];
  81885. protected _ranges: {
  81886. [name: string]: Nullable<AnimationRange>;
  81887. };
  81888. /**
  81889. * Callback raised when the node is ready to be used
  81890. */
  81891. onReady: (node: Node) => void;
  81892. private _isEnabled;
  81893. private _isParentEnabled;
  81894. private _isReady;
  81895. /** @hidden */
  81896. _currentRenderId: number;
  81897. private _parentRenderId;
  81898. protected _childRenderId: number;
  81899. /** @hidden */
  81900. _waitingParentId: Nullable<string>;
  81901. /** @hidden */
  81902. _scene: Scene;
  81903. /** @hidden */
  81904. _cache: any;
  81905. private _parentNode;
  81906. private _children;
  81907. /** @hidden */
  81908. _worldMatrix: Matrix;
  81909. /** @hidden */
  81910. _worldMatrixDeterminant: number;
  81911. /** @hidden */
  81912. private _sceneRootNodesIndex;
  81913. /**
  81914. * Gets a boolean indicating if the node has been disposed
  81915. * @returns true if the node was disposed
  81916. */
  81917. isDisposed(): boolean;
  81918. /**
  81919. * Gets or sets the parent of the node
  81920. */
  81921. parent: Nullable<Node>;
  81922. private addToSceneRootNodes;
  81923. private removeFromSceneRootNodes;
  81924. private _animationPropertiesOverride;
  81925. /**
  81926. * Gets or sets the animation properties override
  81927. */
  81928. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81929. /**
  81930. * Gets a string idenfifying the name of the class
  81931. * @returns "Node" string
  81932. */
  81933. getClassName(): string;
  81934. /** @hidden */
  81935. readonly _isNode: boolean;
  81936. /**
  81937. * An event triggered when the mesh is disposed
  81938. */
  81939. onDisposeObservable: Observable<Node>;
  81940. private _onDisposeObserver;
  81941. /**
  81942. * Sets a callback that will be raised when the node will be disposed
  81943. */
  81944. onDispose: () => void;
  81945. /**
  81946. * Creates a new Node
  81947. * @param name the name and id to be given to this node
  81948. * @param scene the scene this node will be added to
  81949. * @param addToRootNodes the node will be added to scene.rootNodes
  81950. */
  81951. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81952. /**
  81953. * Gets the scene of the node
  81954. * @returns a scene
  81955. */
  81956. getScene(): Scene;
  81957. /**
  81958. * Gets the engine of the node
  81959. * @returns a Engine
  81960. */
  81961. getEngine(): Engine;
  81962. private _behaviors;
  81963. /**
  81964. * Attach a behavior to the node
  81965. * @see http://doc.babylonjs.com/features/behaviour
  81966. * @param behavior defines the behavior to attach
  81967. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81968. * @returns the current Node
  81969. */
  81970. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81971. /**
  81972. * Remove an attached behavior
  81973. * @see http://doc.babylonjs.com/features/behaviour
  81974. * @param behavior defines the behavior to attach
  81975. * @returns the current Node
  81976. */
  81977. removeBehavior(behavior: Behavior<Node>): Node;
  81978. /**
  81979. * Gets the list of attached behaviors
  81980. * @see http://doc.babylonjs.com/features/behaviour
  81981. */
  81982. readonly behaviors: Behavior<Node>[];
  81983. /**
  81984. * Gets an attached behavior by name
  81985. * @param name defines the name of the behavior to look for
  81986. * @see http://doc.babylonjs.com/features/behaviour
  81987. * @returns null if behavior was not found else the requested behavior
  81988. */
  81989. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81990. /**
  81991. * Returns the latest update of the World matrix
  81992. * @returns a Matrix
  81993. */
  81994. getWorldMatrix(): Matrix;
  81995. /** @hidden */
  81996. _getWorldMatrixDeterminant(): number;
  81997. /**
  81998. * Returns directly the latest state of the mesh World matrix.
  81999. * A Matrix is returned.
  82000. */
  82001. readonly worldMatrixFromCache: Matrix;
  82002. /** @hidden */
  82003. _initCache(): void;
  82004. /** @hidden */
  82005. updateCache(force?: boolean): void;
  82006. /** @hidden */
  82007. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82008. /** @hidden */
  82009. _updateCache(ignoreParentClass?: boolean): void;
  82010. /** @hidden */
  82011. _isSynchronized(): boolean;
  82012. /** @hidden */
  82013. _markSyncedWithParent(): void;
  82014. /** @hidden */
  82015. isSynchronizedWithParent(): boolean;
  82016. /** @hidden */
  82017. isSynchronized(): boolean;
  82018. /**
  82019. * Is this node ready to be used/rendered
  82020. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82021. * @return true if the node is ready
  82022. */
  82023. isReady(completeCheck?: boolean): boolean;
  82024. /**
  82025. * Is this node enabled?
  82026. * 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
  82027. * @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
  82028. * @return whether this node (and its parent) is enabled
  82029. */
  82030. isEnabled(checkAncestors?: boolean): boolean;
  82031. /** @hidden */
  82032. protected _syncParentEnabledState(): void;
  82033. /**
  82034. * Set the enabled state of this node
  82035. * @param value defines the new enabled state
  82036. */
  82037. setEnabled(value: boolean): void;
  82038. /**
  82039. * Is this node a descendant of the given node?
  82040. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82041. * @param ancestor defines the parent node to inspect
  82042. * @returns a boolean indicating if this node is a descendant of the given node
  82043. */
  82044. isDescendantOf(ancestor: Node): boolean;
  82045. /** @hidden */
  82046. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82047. /**
  82048. * Will return all nodes that have this node as ascendant
  82049. * @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
  82050. * @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
  82051. * @return all children nodes of all types
  82052. */
  82053. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82054. /**
  82055. * Get all child-meshes of this node
  82056. * @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)
  82057. * @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
  82058. * @returns an array of AbstractMesh
  82059. */
  82060. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82061. /**
  82062. * Get all direct children of this node
  82063. * @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
  82064. * @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)
  82065. * @returns an array of Node
  82066. */
  82067. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82068. /** @hidden */
  82069. _setReady(state: boolean): void;
  82070. /**
  82071. * Get an animation by name
  82072. * @param name defines the name of the animation to look for
  82073. * @returns null if not found else the requested animation
  82074. */
  82075. getAnimationByName(name: string): Nullable<Animation>;
  82076. /**
  82077. * Creates an animation range for this node
  82078. * @param name defines the name of the range
  82079. * @param from defines the starting key
  82080. * @param to defines the end key
  82081. */
  82082. createAnimationRange(name: string, from: number, to: number): void;
  82083. /**
  82084. * Delete a specific animation range
  82085. * @param name defines the name of the range to delete
  82086. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82087. */
  82088. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82089. /**
  82090. * Get an animation range by name
  82091. * @param name defines the name of the animation range to look for
  82092. * @returns null if not found else the requested animation range
  82093. */
  82094. getAnimationRange(name: string): Nullable<AnimationRange>;
  82095. /**
  82096. * Gets the list of all animation ranges defined on this node
  82097. * @returns an array
  82098. */
  82099. getAnimationRanges(): Nullable<AnimationRange>[];
  82100. /**
  82101. * Will start the animation sequence
  82102. * @param name defines the range frames for animation sequence
  82103. * @param loop defines if the animation should loop (false by default)
  82104. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82105. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82106. * @returns the object created for this animation. If range does not exist, it will return null
  82107. */
  82108. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82109. /**
  82110. * Serialize animation ranges into a JSON compatible object
  82111. * @returns serialization object
  82112. */
  82113. serializeAnimationRanges(): any;
  82114. /**
  82115. * Computes the world matrix of the node
  82116. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82117. * @returns the world matrix
  82118. */
  82119. computeWorldMatrix(force?: boolean): Matrix;
  82120. /**
  82121. * Releases resources associated with this node.
  82122. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82123. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82124. */
  82125. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82126. /**
  82127. * Parse animation range data from a serialization object and store them into a given node
  82128. * @param node defines where to store the animation ranges
  82129. * @param parsedNode defines the serialization object to read data from
  82130. * @param scene defines the hosting scene
  82131. */
  82132. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82133. }
  82134. }
  82135. declare module BABYLON {
  82136. /**
  82137. * Class used to store any kind of animation
  82138. */
  82139. export class Animation {
  82140. /**Name of the animation */
  82141. name: string;
  82142. /**Property to animate */
  82143. targetProperty: string;
  82144. /**The frames per second of the animation */
  82145. framePerSecond: number;
  82146. /**The data type of the animation */
  82147. dataType: number;
  82148. /**The loop mode of the animation */
  82149. loopMode?: number | undefined;
  82150. /**Specifies if blending should be enabled */
  82151. enableBlending?: boolean | undefined;
  82152. /**
  82153. * Use matrix interpolation instead of using direct key value when animating matrices
  82154. */
  82155. static AllowMatricesInterpolation: boolean;
  82156. /**
  82157. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82158. */
  82159. static AllowMatrixDecomposeForInterpolation: boolean;
  82160. /**
  82161. * Stores the key frames of the animation
  82162. */
  82163. private _keys;
  82164. /**
  82165. * Stores the easing function of the animation
  82166. */
  82167. private _easingFunction;
  82168. /**
  82169. * @hidden Internal use only
  82170. */
  82171. _runtimeAnimations: RuntimeAnimation[];
  82172. /**
  82173. * The set of event that will be linked to this animation
  82174. */
  82175. private _events;
  82176. /**
  82177. * Stores an array of target property paths
  82178. */
  82179. targetPropertyPath: string[];
  82180. /**
  82181. * Stores the blending speed of the animation
  82182. */
  82183. blendingSpeed: number;
  82184. /**
  82185. * Stores the animation ranges for the animation
  82186. */
  82187. private _ranges;
  82188. /**
  82189. * @hidden Internal use
  82190. */
  82191. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82192. /**
  82193. * Sets up an animation
  82194. * @param property The property to animate
  82195. * @param animationType The animation type to apply
  82196. * @param framePerSecond The frames per second of the animation
  82197. * @param easingFunction The easing function used in the animation
  82198. * @returns The created animation
  82199. */
  82200. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82201. /**
  82202. * Create and start an animation on a node
  82203. * @param name defines the name of the global animation that will be run on all nodes
  82204. * @param node defines the root node where the animation will take place
  82205. * @param targetProperty defines property to animate
  82206. * @param framePerSecond defines the number of frame per second yo use
  82207. * @param totalFrame defines the number of frames in total
  82208. * @param from defines the initial value
  82209. * @param to defines the final value
  82210. * @param loopMode defines which loop mode you want to use (off by default)
  82211. * @param easingFunction defines the easing function to use (linear by default)
  82212. * @param onAnimationEnd defines the callback to call when animation end
  82213. * @returns the animatable created for this animation
  82214. */
  82215. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82216. /**
  82217. * Create and start an animation on a node and its descendants
  82218. * @param name defines the name of the global animation that will be run on all nodes
  82219. * @param node defines the root node where the animation will take place
  82220. * @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
  82221. * @param targetProperty defines property to animate
  82222. * @param framePerSecond defines the number of frame per second to use
  82223. * @param totalFrame defines the number of frames in total
  82224. * @param from defines the initial value
  82225. * @param to defines the final value
  82226. * @param loopMode defines which loop mode you want to use (off by default)
  82227. * @param easingFunction defines the easing function to use (linear by default)
  82228. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82229. * @returns the list of animatables created for all nodes
  82230. * @example https://www.babylonjs-playground.com/#MH0VLI
  82231. */
  82232. 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[]>;
  82233. /**
  82234. * Creates a new animation, merges it with the existing animations and starts it
  82235. * @param name Name of the animation
  82236. * @param node Node which contains the scene that begins the animations
  82237. * @param targetProperty Specifies which property to animate
  82238. * @param framePerSecond The frames per second of the animation
  82239. * @param totalFrame The total number of frames
  82240. * @param from The frame at the beginning of the animation
  82241. * @param to The frame at the end of the animation
  82242. * @param loopMode Specifies the loop mode of the animation
  82243. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82244. * @param onAnimationEnd Callback to run once the animation is complete
  82245. * @returns Nullable animation
  82246. */
  82247. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82248. /**
  82249. * Transition property of an host to the target Value
  82250. * @param property The property to transition
  82251. * @param targetValue The target Value of the property
  82252. * @param host The object where the property to animate belongs
  82253. * @param scene Scene used to run the animation
  82254. * @param frameRate Framerate (in frame/s) to use
  82255. * @param transition The transition type we want to use
  82256. * @param duration The duration of the animation, in milliseconds
  82257. * @param onAnimationEnd Callback trigger at the end of the animation
  82258. * @returns Nullable animation
  82259. */
  82260. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82261. /**
  82262. * Return the array of runtime animations currently using this animation
  82263. */
  82264. readonly runtimeAnimations: RuntimeAnimation[];
  82265. /**
  82266. * Specifies if any of the runtime animations are currently running
  82267. */
  82268. readonly hasRunningRuntimeAnimations: boolean;
  82269. /**
  82270. * Initializes the animation
  82271. * @param name Name of the animation
  82272. * @param targetProperty Property to animate
  82273. * @param framePerSecond The frames per second of the animation
  82274. * @param dataType The data type of the animation
  82275. * @param loopMode The loop mode of the animation
  82276. * @param enableBlending Specifies if blending should be enabled
  82277. */
  82278. constructor(
  82279. /**Name of the animation */
  82280. name: string,
  82281. /**Property to animate */
  82282. targetProperty: string,
  82283. /**The frames per second of the animation */
  82284. framePerSecond: number,
  82285. /**The data type of the animation */
  82286. dataType: number,
  82287. /**The loop mode of the animation */
  82288. loopMode?: number | undefined,
  82289. /**Specifies if blending should be enabled */
  82290. enableBlending?: boolean | undefined);
  82291. /**
  82292. * Converts the animation to a string
  82293. * @param fullDetails support for multiple levels of logging within scene loading
  82294. * @returns String form of the animation
  82295. */
  82296. toString(fullDetails?: boolean): string;
  82297. /**
  82298. * Add an event to this animation
  82299. * @param event Event to add
  82300. */
  82301. addEvent(event: AnimationEvent): void;
  82302. /**
  82303. * Remove all events found at the given frame
  82304. * @param frame The frame to remove events from
  82305. */
  82306. removeEvents(frame: number): void;
  82307. /**
  82308. * Retrieves all the events from the animation
  82309. * @returns Events from the animation
  82310. */
  82311. getEvents(): AnimationEvent[];
  82312. /**
  82313. * Creates an animation range
  82314. * @param name Name of the animation range
  82315. * @param from Starting frame of the animation range
  82316. * @param to Ending frame of the animation
  82317. */
  82318. createRange(name: string, from: number, to: number): void;
  82319. /**
  82320. * Deletes an animation range by name
  82321. * @param name Name of the animation range to delete
  82322. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82323. */
  82324. deleteRange(name: string, deleteFrames?: boolean): void;
  82325. /**
  82326. * Gets the animation range by name, or null if not defined
  82327. * @param name Name of the animation range
  82328. * @returns Nullable animation range
  82329. */
  82330. getRange(name: string): Nullable<AnimationRange>;
  82331. /**
  82332. * Gets the key frames from the animation
  82333. * @returns The key frames of the animation
  82334. */
  82335. getKeys(): Array<IAnimationKey>;
  82336. /**
  82337. * Gets the highest frame rate of the animation
  82338. * @returns Highest frame rate of the animation
  82339. */
  82340. getHighestFrame(): number;
  82341. /**
  82342. * Gets the easing function of the animation
  82343. * @returns Easing function of the animation
  82344. */
  82345. getEasingFunction(): IEasingFunction;
  82346. /**
  82347. * Sets the easing function of the animation
  82348. * @param easingFunction A custom mathematical formula for animation
  82349. */
  82350. setEasingFunction(easingFunction: EasingFunction): void;
  82351. /**
  82352. * Interpolates a scalar linearly
  82353. * @param startValue Start value of the animation curve
  82354. * @param endValue End value of the animation curve
  82355. * @param gradient Scalar amount to interpolate
  82356. * @returns Interpolated scalar value
  82357. */
  82358. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82359. /**
  82360. * Interpolates a scalar cubically
  82361. * @param startValue Start value of the animation curve
  82362. * @param outTangent End tangent of the animation
  82363. * @param endValue End value of the animation curve
  82364. * @param inTangent Start tangent of the animation curve
  82365. * @param gradient Scalar amount to interpolate
  82366. * @returns Interpolated scalar value
  82367. */
  82368. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82369. /**
  82370. * Interpolates a quaternion using a spherical linear interpolation
  82371. * @param startValue Start value of the animation curve
  82372. * @param endValue End value of the animation curve
  82373. * @param gradient Scalar amount to interpolate
  82374. * @returns Interpolated quaternion value
  82375. */
  82376. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82377. /**
  82378. * Interpolates a quaternion cubically
  82379. * @param startValue Start value of the animation curve
  82380. * @param outTangent End tangent of the animation curve
  82381. * @param endValue End value of the animation curve
  82382. * @param inTangent Start tangent of the animation curve
  82383. * @param gradient Scalar amount to interpolate
  82384. * @returns Interpolated quaternion value
  82385. */
  82386. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82387. /**
  82388. * Interpolates a Vector3 linearl
  82389. * @param startValue Start value of the animation curve
  82390. * @param endValue End value of the animation curve
  82391. * @param gradient Scalar amount to interpolate
  82392. * @returns Interpolated scalar value
  82393. */
  82394. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82395. /**
  82396. * Interpolates a Vector3 cubically
  82397. * @param startValue Start value of the animation curve
  82398. * @param outTangent End tangent of the animation
  82399. * @param endValue End value of the animation curve
  82400. * @param inTangent Start tangent of the animation curve
  82401. * @param gradient Scalar amount to interpolate
  82402. * @returns InterpolatedVector3 value
  82403. */
  82404. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82405. /**
  82406. * Interpolates a Vector2 linearly
  82407. * @param startValue Start value of the animation curve
  82408. * @param endValue End value of the animation curve
  82409. * @param gradient Scalar amount to interpolate
  82410. * @returns Interpolated Vector2 value
  82411. */
  82412. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82413. /**
  82414. * Interpolates a Vector2 cubically
  82415. * @param startValue Start value of the animation curve
  82416. * @param outTangent End tangent of the animation
  82417. * @param endValue End value of the animation curve
  82418. * @param inTangent Start tangent of the animation curve
  82419. * @param gradient Scalar amount to interpolate
  82420. * @returns Interpolated Vector2 value
  82421. */
  82422. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82423. /**
  82424. * Interpolates a size linearly
  82425. * @param startValue Start value of the animation curve
  82426. * @param endValue End value of the animation curve
  82427. * @param gradient Scalar amount to interpolate
  82428. * @returns Interpolated Size value
  82429. */
  82430. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82431. /**
  82432. * Interpolates a Color3 linearly
  82433. * @param startValue Start value of the animation curve
  82434. * @param endValue End value of the animation curve
  82435. * @param gradient Scalar amount to interpolate
  82436. * @returns Interpolated Color3 value
  82437. */
  82438. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82439. /**
  82440. * @hidden Internal use only
  82441. */
  82442. _getKeyValue(value: any): any;
  82443. /**
  82444. * @hidden Internal use only
  82445. */
  82446. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82447. /**
  82448. * Defines the function to use to interpolate matrices
  82449. * @param startValue defines the start matrix
  82450. * @param endValue defines the end matrix
  82451. * @param gradient defines the gradient between both matrices
  82452. * @param result defines an optional target matrix where to store the interpolation
  82453. * @returns the interpolated matrix
  82454. */
  82455. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82456. /**
  82457. * Makes a copy of the animation
  82458. * @returns Cloned animation
  82459. */
  82460. clone(): Animation;
  82461. /**
  82462. * Sets the key frames of the animation
  82463. * @param values The animation key frames to set
  82464. */
  82465. setKeys(values: Array<IAnimationKey>): void;
  82466. /**
  82467. * Serializes the animation to an object
  82468. * @returns Serialized object
  82469. */
  82470. serialize(): any;
  82471. /**
  82472. * Float animation type
  82473. */
  82474. private static _ANIMATIONTYPE_FLOAT;
  82475. /**
  82476. * Vector3 animation type
  82477. */
  82478. private static _ANIMATIONTYPE_VECTOR3;
  82479. /**
  82480. * Quaternion animation type
  82481. */
  82482. private static _ANIMATIONTYPE_QUATERNION;
  82483. /**
  82484. * Matrix animation type
  82485. */
  82486. private static _ANIMATIONTYPE_MATRIX;
  82487. /**
  82488. * Color3 animation type
  82489. */
  82490. private static _ANIMATIONTYPE_COLOR3;
  82491. /**
  82492. * Vector2 animation type
  82493. */
  82494. private static _ANIMATIONTYPE_VECTOR2;
  82495. /**
  82496. * Size animation type
  82497. */
  82498. private static _ANIMATIONTYPE_SIZE;
  82499. /**
  82500. * Relative Loop Mode
  82501. */
  82502. private static _ANIMATIONLOOPMODE_RELATIVE;
  82503. /**
  82504. * Cycle Loop Mode
  82505. */
  82506. private static _ANIMATIONLOOPMODE_CYCLE;
  82507. /**
  82508. * Constant Loop Mode
  82509. */
  82510. private static _ANIMATIONLOOPMODE_CONSTANT;
  82511. /**
  82512. * Get the float animation type
  82513. */
  82514. static readonly ANIMATIONTYPE_FLOAT: number;
  82515. /**
  82516. * Get the Vector3 animation type
  82517. */
  82518. static readonly ANIMATIONTYPE_VECTOR3: number;
  82519. /**
  82520. * Get the Vector2 animation type
  82521. */
  82522. static readonly ANIMATIONTYPE_VECTOR2: number;
  82523. /**
  82524. * Get the Size animation type
  82525. */
  82526. static readonly ANIMATIONTYPE_SIZE: number;
  82527. /**
  82528. * Get the Quaternion animation type
  82529. */
  82530. static readonly ANIMATIONTYPE_QUATERNION: number;
  82531. /**
  82532. * Get the Matrix animation type
  82533. */
  82534. static readonly ANIMATIONTYPE_MATRIX: number;
  82535. /**
  82536. * Get the Color3 animation type
  82537. */
  82538. static readonly ANIMATIONTYPE_COLOR3: number;
  82539. /**
  82540. * Get the Relative Loop Mode
  82541. */
  82542. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82543. /**
  82544. * Get the Cycle Loop Mode
  82545. */
  82546. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82547. /**
  82548. * Get the Constant Loop Mode
  82549. */
  82550. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82551. /** @hidden */
  82552. static _UniversalLerp(left: any, right: any, amount: number): any;
  82553. /**
  82554. * Parses an animation object and creates an animation
  82555. * @param parsedAnimation Parsed animation object
  82556. * @returns Animation object
  82557. */
  82558. static Parse(parsedAnimation: any): Animation;
  82559. /**
  82560. * Appends the serialized animations from the source animations
  82561. * @param source Source containing the animations
  82562. * @param destination Target to store the animations
  82563. */
  82564. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82565. }
  82566. }
  82567. declare module BABYLON {
  82568. /**
  82569. * Base class of all the textures in babylon.
  82570. * It groups all the common properties the materials, post process, lights... might need
  82571. * in order to make a correct use of the texture.
  82572. */
  82573. export class BaseTexture implements IAnimatable {
  82574. /**
  82575. * Default anisotropic filtering level for the application.
  82576. * It is set to 4 as a good tradeoff between perf and quality.
  82577. */
  82578. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82579. /**
  82580. * Gets or sets the unique id of the texture
  82581. */
  82582. uniqueId: number;
  82583. /**
  82584. * Define the name of the texture.
  82585. */
  82586. name: string;
  82587. /**
  82588. * Gets or sets an object used to store user defined information.
  82589. */
  82590. metadata: any;
  82591. /**
  82592. * For internal use only. Please do not use.
  82593. */
  82594. reservedDataStore: any;
  82595. private _hasAlpha;
  82596. /**
  82597. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82598. */
  82599. hasAlpha: boolean;
  82600. /**
  82601. * Defines if the alpha value should be determined via the rgb values.
  82602. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82603. */
  82604. getAlphaFromRGB: boolean;
  82605. /**
  82606. * Intensity or strength of the texture.
  82607. * It is commonly used by materials to fine tune the intensity of the texture
  82608. */
  82609. level: number;
  82610. /**
  82611. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82612. * This is part of the texture as textures usually maps to one uv set.
  82613. */
  82614. coordinatesIndex: number;
  82615. private _coordinatesMode;
  82616. /**
  82617. * How a texture is mapped.
  82618. *
  82619. * | Value | Type | Description |
  82620. * | ----- | ----------------------------------- | ----------- |
  82621. * | 0 | EXPLICIT_MODE | |
  82622. * | 1 | SPHERICAL_MODE | |
  82623. * | 2 | PLANAR_MODE | |
  82624. * | 3 | CUBIC_MODE | |
  82625. * | 4 | PROJECTION_MODE | |
  82626. * | 5 | SKYBOX_MODE | |
  82627. * | 6 | INVCUBIC_MODE | |
  82628. * | 7 | EQUIRECTANGULAR_MODE | |
  82629. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82630. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82631. */
  82632. coordinatesMode: number;
  82633. /**
  82634. * | Value | Type | Description |
  82635. * | ----- | ------------------ | ----------- |
  82636. * | 0 | CLAMP_ADDRESSMODE | |
  82637. * | 1 | WRAP_ADDRESSMODE | |
  82638. * | 2 | MIRROR_ADDRESSMODE | |
  82639. */
  82640. wrapU: number;
  82641. /**
  82642. * | Value | Type | Description |
  82643. * | ----- | ------------------ | ----------- |
  82644. * | 0 | CLAMP_ADDRESSMODE | |
  82645. * | 1 | WRAP_ADDRESSMODE | |
  82646. * | 2 | MIRROR_ADDRESSMODE | |
  82647. */
  82648. wrapV: number;
  82649. /**
  82650. * | Value | Type | Description |
  82651. * | ----- | ------------------ | ----------- |
  82652. * | 0 | CLAMP_ADDRESSMODE | |
  82653. * | 1 | WRAP_ADDRESSMODE | |
  82654. * | 2 | MIRROR_ADDRESSMODE | |
  82655. */
  82656. wrapR: number;
  82657. /**
  82658. * With compliant hardware and browser (supporting anisotropic filtering)
  82659. * this defines the level of anisotropic filtering in the texture.
  82660. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82661. */
  82662. anisotropicFilteringLevel: number;
  82663. /**
  82664. * Define if the texture is a cube texture or if false a 2d texture.
  82665. */
  82666. isCube: boolean;
  82667. /**
  82668. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82669. */
  82670. is3D: boolean;
  82671. /**
  82672. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82673. * HDR texture are usually stored in linear space.
  82674. * This only impacts the PBR and Background materials
  82675. */
  82676. gammaSpace: boolean;
  82677. /**
  82678. * Gets whether or not the texture contains RGBD data.
  82679. */
  82680. readonly isRGBD: boolean;
  82681. /**
  82682. * Is Z inverted in the texture (useful in a cube texture).
  82683. */
  82684. invertZ: boolean;
  82685. /**
  82686. * Are mip maps generated for this texture or not.
  82687. */
  82688. readonly noMipmap: boolean;
  82689. /**
  82690. * @hidden
  82691. */
  82692. lodLevelInAlpha: boolean;
  82693. /**
  82694. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82695. */
  82696. lodGenerationOffset: number;
  82697. /**
  82698. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82699. */
  82700. lodGenerationScale: number;
  82701. /**
  82702. * Define if the texture is a render target.
  82703. */
  82704. isRenderTarget: boolean;
  82705. /**
  82706. * Define the unique id of the texture in the scene.
  82707. */
  82708. readonly uid: string;
  82709. /**
  82710. * Return a string representation of the texture.
  82711. * @returns the texture as a string
  82712. */
  82713. toString(): string;
  82714. /**
  82715. * Get the class name of the texture.
  82716. * @returns "BaseTexture"
  82717. */
  82718. getClassName(): string;
  82719. /**
  82720. * Define the list of animation attached to the texture.
  82721. */
  82722. animations: Animation[];
  82723. /**
  82724. * An event triggered when the texture is disposed.
  82725. */
  82726. onDisposeObservable: Observable<BaseTexture>;
  82727. private _onDisposeObserver;
  82728. /**
  82729. * Callback triggered when the texture has been disposed.
  82730. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82731. */
  82732. onDispose: () => void;
  82733. /**
  82734. * Define the current state of the loading sequence when in delayed load mode.
  82735. */
  82736. delayLoadState: number;
  82737. private _scene;
  82738. /** @hidden */
  82739. _texture: Nullable<InternalTexture>;
  82740. private _uid;
  82741. /**
  82742. * Define if the texture is preventinga material to render or not.
  82743. * If not and the texture is not ready, the engine will use a default black texture instead.
  82744. */
  82745. readonly isBlocking: boolean;
  82746. /**
  82747. * Instantiates a new BaseTexture.
  82748. * Base class of all the textures in babylon.
  82749. * It groups all the common properties the materials, post process, lights... might need
  82750. * in order to make a correct use of the texture.
  82751. * @param scene Define the scene the texture blongs to
  82752. */
  82753. constructor(scene: Nullable<Scene>);
  82754. /**
  82755. * Get the scene the texture belongs to.
  82756. * @returns the scene or null if undefined
  82757. */
  82758. getScene(): Nullable<Scene>;
  82759. /**
  82760. * Get the texture transform matrix used to offset tile the texture for istance.
  82761. * @returns the transformation matrix
  82762. */
  82763. getTextureMatrix(): Matrix;
  82764. /**
  82765. * Get the texture reflection matrix used to rotate/transform the reflection.
  82766. * @returns the reflection matrix
  82767. */
  82768. getReflectionTextureMatrix(): Matrix;
  82769. /**
  82770. * Get the underlying lower level texture from Babylon.
  82771. * @returns the insternal texture
  82772. */
  82773. getInternalTexture(): Nullable<InternalTexture>;
  82774. /**
  82775. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82776. * @returns true if ready or not blocking
  82777. */
  82778. isReadyOrNotBlocking(): boolean;
  82779. /**
  82780. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82781. * @returns true if fully ready
  82782. */
  82783. isReady(): boolean;
  82784. private _cachedSize;
  82785. /**
  82786. * Get the size of the texture.
  82787. * @returns the texture size.
  82788. */
  82789. getSize(): ISize;
  82790. /**
  82791. * Get the base size of the texture.
  82792. * It can be different from the size if the texture has been resized for POT for instance
  82793. * @returns the base size
  82794. */
  82795. getBaseSize(): ISize;
  82796. /**
  82797. * Update the sampling mode of the texture.
  82798. * Default is Trilinear mode.
  82799. *
  82800. * | Value | Type | Description |
  82801. * | ----- | ------------------ | ----------- |
  82802. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82803. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82804. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82805. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82806. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82807. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82808. * | 7 | NEAREST_LINEAR | |
  82809. * | 8 | NEAREST_NEAREST | |
  82810. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82811. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82812. * | 11 | LINEAR_LINEAR | |
  82813. * | 12 | LINEAR_NEAREST | |
  82814. *
  82815. * > _mag_: magnification filter (close to the viewer)
  82816. * > _min_: minification filter (far from the viewer)
  82817. * > _mip_: filter used between mip map levels
  82818. *@param samplingMode Define the new sampling mode of the texture
  82819. */
  82820. updateSamplingMode(samplingMode: number): void;
  82821. /**
  82822. * Scales the texture if is `canRescale()`
  82823. * @param ratio the resize factor we want to use to rescale
  82824. */
  82825. scale(ratio: number): void;
  82826. /**
  82827. * Get if the texture can rescale.
  82828. */
  82829. readonly canRescale: boolean;
  82830. /** @hidden */
  82831. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82832. /** @hidden */
  82833. _rebuild(): void;
  82834. /**
  82835. * Triggers the load sequence in delayed load mode.
  82836. */
  82837. delayLoad(): void;
  82838. /**
  82839. * Clones the texture.
  82840. * @returns the cloned texture
  82841. */
  82842. clone(): Nullable<BaseTexture>;
  82843. /**
  82844. * Get the texture underlying type (INT, FLOAT...)
  82845. */
  82846. readonly textureType: number;
  82847. /**
  82848. * Get the texture underlying format (RGB, RGBA...)
  82849. */
  82850. readonly textureFormat: number;
  82851. /**
  82852. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82853. * This will returns an RGBA array buffer containing either in values (0-255) or
  82854. * float values (0-1) depending of the underlying buffer type.
  82855. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82856. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82857. * @param buffer defines a user defined buffer to fill with data (can be null)
  82858. * @returns The Array buffer containing the pixels data.
  82859. */
  82860. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82861. /**
  82862. * Release and destroy the underlying lower level texture aka internalTexture.
  82863. */
  82864. releaseInternalTexture(): void;
  82865. /**
  82866. * Get the polynomial representation of the texture data.
  82867. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82868. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82869. */
  82870. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82871. /** @hidden */
  82872. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82873. /** @hidden */
  82874. readonly _lodTextureMid: Nullable<BaseTexture>;
  82875. /** @hidden */
  82876. readonly _lodTextureLow: Nullable<BaseTexture>;
  82877. /**
  82878. * Dispose the texture and release its associated resources.
  82879. */
  82880. dispose(): void;
  82881. /**
  82882. * Serialize the texture into a JSON representation that can be parsed later on.
  82883. * @returns the JSON representation of the texture
  82884. */
  82885. serialize(): any;
  82886. /**
  82887. * Helper function to be called back once a list of texture contains only ready textures.
  82888. * @param textures Define the list of textures to wait for
  82889. * @param callback Define the callback triggered once the entire list will be ready
  82890. */
  82891. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82892. }
  82893. }
  82894. declare module BABYLON {
  82895. /**
  82896. * Uniform buffer objects.
  82897. *
  82898. * Handles blocks of uniform on the GPU.
  82899. *
  82900. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82901. *
  82902. * For more information, please refer to :
  82903. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82904. */
  82905. export class UniformBuffer {
  82906. private _engine;
  82907. private _buffer;
  82908. private _data;
  82909. private _bufferData;
  82910. private _dynamic?;
  82911. private _uniformLocations;
  82912. private _uniformSizes;
  82913. private _uniformLocationPointer;
  82914. private _needSync;
  82915. private _noUBO;
  82916. private _currentEffect;
  82917. private static _MAX_UNIFORM_SIZE;
  82918. private static _tempBuffer;
  82919. /**
  82920. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82921. * This is dynamic to allow compat with webgl 1 and 2.
  82922. * You will need to pass the name of the uniform as well as the value.
  82923. */
  82924. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82925. /**
  82926. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82927. * This is dynamic to allow compat with webgl 1 and 2.
  82928. * You will need to pass the name of the uniform as well as the value.
  82929. */
  82930. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82931. /**
  82932. * Lambda to Update a single float in a uniform buffer.
  82933. * This is dynamic to allow compat with webgl 1 and 2.
  82934. * You will need to pass the name of the uniform as well as the value.
  82935. */
  82936. updateFloat: (name: string, x: number) => void;
  82937. /**
  82938. * Lambda to Update a vec2 of float in a uniform buffer.
  82939. * This is dynamic to allow compat with webgl 1 and 2.
  82940. * You will need to pass the name of the uniform as well as the value.
  82941. */
  82942. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82943. /**
  82944. * Lambda to Update a vec3 of float in a uniform buffer.
  82945. * This is dynamic to allow compat with webgl 1 and 2.
  82946. * You will need to pass the name of the uniform as well as the value.
  82947. */
  82948. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82949. /**
  82950. * Lambda to Update a vec4 of float in a uniform buffer.
  82951. * This is dynamic to allow compat with webgl 1 and 2.
  82952. * You will need to pass the name of the uniform as well as the value.
  82953. */
  82954. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82955. /**
  82956. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82957. * This is dynamic to allow compat with webgl 1 and 2.
  82958. * You will need to pass the name of the uniform as well as the value.
  82959. */
  82960. updateMatrix: (name: string, mat: Matrix) => void;
  82961. /**
  82962. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82963. * This is dynamic to allow compat with webgl 1 and 2.
  82964. * You will need to pass the name of the uniform as well as the value.
  82965. */
  82966. updateVector3: (name: string, vector: Vector3) => void;
  82967. /**
  82968. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82969. * This is dynamic to allow compat with webgl 1 and 2.
  82970. * You will need to pass the name of the uniform as well as the value.
  82971. */
  82972. updateVector4: (name: string, vector: Vector4) => void;
  82973. /**
  82974. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82975. * This is dynamic to allow compat with webgl 1 and 2.
  82976. * You will need to pass the name of the uniform as well as the value.
  82977. */
  82978. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82979. /**
  82980. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82981. * This is dynamic to allow compat with webgl 1 and 2.
  82982. * You will need to pass the name of the uniform as well as the value.
  82983. */
  82984. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82985. /**
  82986. * Instantiates a new Uniform buffer objects.
  82987. *
  82988. * Handles blocks of uniform on the GPU.
  82989. *
  82990. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82991. *
  82992. * For more information, please refer to :
  82993. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82994. * @param engine Define the engine the buffer is associated with
  82995. * @param data Define the data contained in the buffer
  82996. * @param dynamic Define if the buffer is updatable
  82997. */
  82998. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82999. /**
  83000. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83001. * or just falling back on setUniformXXX calls.
  83002. */
  83003. readonly useUbo: boolean;
  83004. /**
  83005. * Indicates if the WebGL underlying uniform buffer is in sync
  83006. * with the javascript cache data.
  83007. */
  83008. readonly isSync: boolean;
  83009. /**
  83010. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83011. * Also, a dynamic UniformBuffer will disable cache verification and always
  83012. * update the underlying WebGL uniform buffer to the GPU.
  83013. * @returns if Dynamic, otherwise false
  83014. */
  83015. isDynamic(): boolean;
  83016. /**
  83017. * The data cache on JS side.
  83018. * @returns the underlying data as a float array
  83019. */
  83020. getData(): Float32Array;
  83021. /**
  83022. * The underlying WebGL Uniform buffer.
  83023. * @returns the webgl buffer
  83024. */
  83025. getBuffer(): Nullable<WebGLBuffer>;
  83026. /**
  83027. * std140 layout specifies how to align data within an UBO structure.
  83028. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83029. * for specs.
  83030. */
  83031. private _fillAlignment;
  83032. /**
  83033. * Adds an uniform in the buffer.
  83034. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83035. * for the layout to be correct !
  83036. * @param name Name of the uniform, as used in the uniform block in the shader.
  83037. * @param size Data size, or data directly.
  83038. */
  83039. addUniform(name: string, size: number | number[]): void;
  83040. /**
  83041. * Adds a Matrix 4x4 to the uniform buffer.
  83042. * @param name Name of the uniform, as used in the uniform block in the shader.
  83043. * @param mat A 4x4 matrix.
  83044. */
  83045. addMatrix(name: string, mat: Matrix): void;
  83046. /**
  83047. * Adds a vec2 to the uniform buffer.
  83048. * @param name Name of the uniform, as used in the uniform block in the shader.
  83049. * @param x Define the x component value of the vec2
  83050. * @param y Define the y component value of the vec2
  83051. */
  83052. addFloat2(name: string, x: number, y: number): void;
  83053. /**
  83054. * Adds a vec3 to the uniform buffer.
  83055. * @param name Name of the uniform, as used in the uniform block in the shader.
  83056. * @param x Define the x component value of the vec3
  83057. * @param y Define the y component value of the vec3
  83058. * @param z Define the z component value of the vec3
  83059. */
  83060. addFloat3(name: string, x: number, y: number, z: number): void;
  83061. /**
  83062. * Adds a vec3 to the uniform buffer.
  83063. * @param name Name of the uniform, as used in the uniform block in the shader.
  83064. * @param color Define the vec3 from a Color
  83065. */
  83066. addColor3(name: string, color: Color3): void;
  83067. /**
  83068. * Adds a vec4 to the uniform buffer.
  83069. * @param name Name of the uniform, as used in the uniform block in the shader.
  83070. * @param color Define the rgb components from a Color
  83071. * @param alpha Define the a component of the vec4
  83072. */
  83073. addColor4(name: string, color: Color3, alpha: number): void;
  83074. /**
  83075. * Adds a vec3 to the uniform buffer.
  83076. * @param name Name of the uniform, as used in the uniform block in the shader.
  83077. * @param vector Define the vec3 components from a Vector
  83078. */
  83079. addVector3(name: string, vector: Vector3): void;
  83080. /**
  83081. * Adds a Matrix 3x3 to the uniform buffer.
  83082. * @param name Name of the uniform, as used in the uniform block in the shader.
  83083. */
  83084. addMatrix3x3(name: string): void;
  83085. /**
  83086. * Adds a Matrix 2x2 to the uniform buffer.
  83087. * @param name Name of the uniform, as used in the uniform block in the shader.
  83088. */
  83089. addMatrix2x2(name: string): void;
  83090. /**
  83091. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83092. */
  83093. create(): void;
  83094. /** @hidden */
  83095. _rebuild(): void;
  83096. /**
  83097. * Updates the WebGL Uniform Buffer on the GPU.
  83098. * If the `dynamic` flag is set to true, no cache comparison is done.
  83099. * Otherwise, the buffer will be updated only if the cache differs.
  83100. */
  83101. update(): void;
  83102. /**
  83103. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83104. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83105. * @param data Define the flattened data
  83106. * @param size Define the size of the data.
  83107. */
  83108. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83109. private _updateMatrix3x3ForUniform;
  83110. private _updateMatrix3x3ForEffect;
  83111. private _updateMatrix2x2ForEffect;
  83112. private _updateMatrix2x2ForUniform;
  83113. private _updateFloatForEffect;
  83114. private _updateFloatForUniform;
  83115. private _updateFloat2ForEffect;
  83116. private _updateFloat2ForUniform;
  83117. private _updateFloat3ForEffect;
  83118. private _updateFloat3ForUniform;
  83119. private _updateFloat4ForEffect;
  83120. private _updateFloat4ForUniform;
  83121. private _updateMatrixForEffect;
  83122. private _updateMatrixForUniform;
  83123. private _updateVector3ForEffect;
  83124. private _updateVector3ForUniform;
  83125. private _updateVector4ForEffect;
  83126. private _updateVector4ForUniform;
  83127. private _updateColor3ForEffect;
  83128. private _updateColor3ForUniform;
  83129. private _updateColor4ForEffect;
  83130. private _updateColor4ForUniform;
  83131. /**
  83132. * Sets a sampler uniform on the effect.
  83133. * @param name Define the name of the sampler.
  83134. * @param texture Define the texture to set in the sampler
  83135. */
  83136. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83137. /**
  83138. * Directly updates the value of the uniform in the cache AND on the GPU.
  83139. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83140. * @param data Define the flattened data
  83141. */
  83142. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83143. /**
  83144. * Binds this uniform buffer to an effect.
  83145. * @param effect Define the effect to bind the buffer to
  83146. * @param name Name of the uniform block in the shader.
  83147. */
  83148. bindToEffect(effect: Effect, name: string): void;
  83149. /**
  83150. * Disposes the uniform buffer.
  83151. */
  83152. dispose(): void;
  83153. }
  83154. }
  83155. declare module BABYLON {
  83156. /**
  83157. * This represents the required contract to create a new type of texture loader.
  83158. */
  83159. export interface IInternalTextureLoader {
  83160. /**
  83161. * Defines wether the loader supports cascade loading the different faces.
  83162. */
  83163. supportCascades: boolean;
  83164. /**
  83165. * This returns if the loader support the current file information.
  83166. * @param extension defines the file extension of the file being loaded
  83167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83168. * @param fallback defines the fallback internal texture if any
  83169. * @param isBase64 defines whether the texture is encoded as a base64
  83170. * @param isBuffer defines whether the texture data are stored as a buffer
  83171. * @returns true if the loader can load the specified file
  83172. */
  83173. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83174. /**
  83175. * Transform the url before loading if required.
  83176. * @param rootUrl the url of the texture
  83177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83178. * @returns the transformed texture
  83179. */
  83180. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83181. /**
  83182. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83183. * @param rootUrl the url of the texture
  83184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83185. * @returns the fallback texture
  83186. */
  83187. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83188. /**
  83189. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83190. * @param data contains the texture data
  83191. * @param texture defines the BabylonJS internal texture
  83192. * @param createPolynomials will be true if polynomials have been requested
  83193. * @param onLoad defines the callback to trigger once the texture is ready
  83194. * @param onError defines the callback to trigger in case of error
  83195. */
  83196. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83197. /**
  83198. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83199. * @param data contains the texture data
  83200. * @param texture defines the BabylonJS internal texture
  83201. * @param callback defines the method to call once ready to upload
  83202. */
  83203. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83204. }
  83205. }
  83206. declare module BABYLON {
  83207. /**
  83208. * Creation options of the multi render target texture.
  83209. */
  83210. export interface IMultiRenderTargetOptions {
  83211. /**
  83212. * Define if the texture needs to create mip maps after render.
  83213. */
  83214. generateMipMaps?: boolean;
  83215. /**
  83216. * Define the types of all the draw buffers we want to create
  83217. */
  83218. types?: number[];
  83219. /**
  83220. * Define the sampling modes of all the draw buffers we want to create
  83221. */
  83222. samplingModes?: number[];
  83223. /**
  83224. * Define if a depth buffer is required
  83225. */
  83226. generateDepthBuffer?: boolean;
  83227. /**
  83228. * Define if a stencil buffer is required
  83229. */
  83230. generateStencilBuffer?: boolean;
  83231. /**
  83232. * Define if a depth texture is required instead of a depth buffer
  83233. */
  83234. generateDepthTexture?: boolean;
  83235. /**
  83236. * Define the number of desired draw buffers
  83237. */
  83238. textureCount?: number;
  83239. /**
  83240. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83241. */
  83242. doNotChangeAspectRatio?: boolean;
  83243. /**
  83244. * Define the default type of the buffers we are creating
  83245. */
  83246. defaultType?: number;
  83247. }
  83248. /**
  83249. * A multi render target, like a render target provides the ability to render to a texture.
  83250. * Unlike the render target, it can render to several draw buffers in one draw.
  83251. * This is specially interesting in deferred rendering or for any effects requiring more than
  83252. * just one color from a single pass.
  83253. */
  83254. export class MultiRenderTarget extends RenderTargetTexture {
  83255. private _internalTextures;
  83256. private _textures;
  83257. private _multiRenderTargetOptions;
  83258. /**
  83259. * Get if draw buffers are currently supported by the used hardware and browser.
  83260. */
  83261. readonly isSupported: boolean;
  83262. /**
  83263. * Get the list of textures generated by the multi render target.
  83264. */
  83265. readonly textures: Texture[];
  83266. /**
  83267. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83268. */
  83269. readonly depthTexture: Texture;
  83270. /**
  83271. * Set the wrapping mode on U of all the textures we are rendering to.
  83272. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83273. */
  83274. wrapU: number;
  83275. /**
  83276. * Set the wrapping mode on V of all the textures we are rendering to.
  83277. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83278. */
  83279. wrapV: number;
  83280. /**
  83281. * Instantiate a new multi render target texture.
  83282. * A multi render target, like a render target provides the ability to render to a texture.
  83283. * Unlike the render target, it can render to several draw buffers in one draw.
  83284. * This is specially interesting in deferred rendering or for any effects requiring more than
  83285. * just one color from a single pass.
  83286. * @param name Define the name of the texture
  83287. * @param size Define the size of the buffers to render to
  83288. * @param count Define the number of target we are rendering into
  83289. * @param scene Define the scene the texture belongs to
  83290. * @param options Define the options used to create the multi render target
  83291. */
  83292. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83293. /** @hidden */
  83294. _rebuild(): void;
  83295. private _createInternalTextures;
  83296. private _createTextures;
  83297. /**
  83298. * Define the number of samples used if MSAA is enabled.
  83299. */
  83300. samples: number;
  83301. /**
  83302. * Resize all the textures in the multi render target.
  83303. * Be carrefull as it will recreate all the data in the new texture.
  83304. * @param size Define the new size
  83305. */
  83306. resize(size: any): void;
  83307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83308. /**
  83309. * Dispose the render targets and their associated resources
  83310. */
  83311. dispose(): void;
  83312. /**
  83313. * Release all the underlying texture used as draw buffers.
  83314. */
  83315. releaseInternalTextures(): void;
  83316. }
  83317. }
  83318. declare module BABYLON {
  83319. /**
  83320. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83322. */
  83323. export class Analyser {
  83324. /**
  83325. * Gets or sets the smoothing
  83326. * @ignorenaming
  83327. */
  83328. SMOOTHING: number;
  83329. /**
  83330. * Gets or sets the FFT table size
  83331. * @ignorenaming
  83332. */
  83333. FFT_SIZE: number;
  83334. /**
  83335. * Gets or sets the bar graph amplitude
  83336. * @ignorenaming
  83337. */
  83338. BARGRAPHAMPLITUDE: number;
  83339. /**
  83340. * Gets or sets the position of the debug canvas
  83341. * @ignorenaming
  83342. */
  83343. DEBUGCANVASPOS: {
  83344. x: number;
  83345. y: number;
  83346. };
  83347. /**
  83348. * Gets or sets the debug canvas size
  83349. * @ignorenaming
  83350. */
  83351. DEBUGCANVASSIZE: {
  83352. width: number;
  83353. height: number;
  83354. };
  83355. private _byteFreqs;
  83356. private _byteTime;
  83357. private _floatFreqs;
  83358. private _webAudioAnalyser;
  83359. private _debugCanvas;
  83360. private _debugCanvasContext;
  83361. private _scene;
  83362. private _registerFunc;
  83363. private _audioEngine;
  83364. /**
  83365. * Creates a new analyser
  83366. * @param scene defines hosting scene
  83367. */
  83368. constructor(scene: Scene);
  83369. /**
  83370. * Get the number of data values you will have to play with for the visualization
  83371. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83372. * @returns a number
  83373. */
  83374. getFrequencyBinCount(): number;
  83375. /**
  83376. * Gets the current frequency data as a byte array
  83377. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83378. * @returns a Uint8Array
  83379. */
  83380. getByteFrequencyData(): Uint8Array;
  83381. /**
  83382. * Gets the current waveform as a byte array
  83383. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83384. * @returns a Uint8Array
  83385. */
  83386. getByteTimeDomainData(): Uint8Array;
  83387. /**
  83388. * Gets the current frequency data as a float array
  83389. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83390. * @returns a Float32Array
  83391. */
  83392. getFloatFrequencyData(): Float32Array;
  83393. /**
  83394. * Renders the debug canvas
  83395. */
  83396. drawDebugCanvas(): void;
  83397. /**
  83398. * Stops rendering the debug canvas and removes it
  83399. */
  83400. stopDebugCanvas(): void;
  83401. /**
  83402. * Connects two audio nodes
  83403. * @param inputAudioNode defines first node to connect
  83404. * @param outputAudioNode defines second node to connect
  83405. */
  83406. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83407. /**
  83408. * Releases all associated resources
  83409. */
  83410. dispose(): void;
  83411. }
  83412. }
  83413. declare module BABYLON {
  83414. /**
  83415. * This represents an audio engine and it is responsible
  83416. * to play, synchronize and analyse sounds throughout the application.
  83417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83418. */
  83419. export interface IAudioEngine extends IDisposable {
  83420. /**
  83421. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83422. */
  83423. readonly canUseWebAudio: boolean;
  83424. /**
  83425. * Gets the current AudioContext if available.
  83426. */
  83427. readonly audioContext: Nullable<AudioContext>;
  83428. /**
  83429. * The master gain node defines the global audio volume of your audio engine.
  83430. */
  83431. readonly masterGain: GainNode;
  83432. /**
  83433. * Gets whether or not mp3 are supported by your browser.
  83434. */
  83435. readonly isMP3supported: boolean;
  83436. /**
  83437. * Gets whether or not ogg are supported by your browser.
  83438. */
  83439. readonly isOGGsupported: boolean;
  83440. /**
  83441. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83442. * @ignoreNaming
  83443. */
  83444. WarnedWebAudioUnsupported: boolean;
  83445. /**
  83446. * Defines if the audio engine relies on a custom unlocked button.
  83447. * In this case, the embedded button will not be displayed.
  83448. */
  83449. useCustomUnlockedButton: boolean;
  83450. /**
  83451. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83452. */
  83453. readonly unlocked: boolean;
  83454. /**
  83455. * Event raised when audio has been unlocked on the browser.
  83456. */
  83457. onAudioUnlockedObservable: Observable<AudioEngine>;
  83458. /**
  83459. * Event raised when audio has been locked on the browser.
  83460. */
  83461. onAudioLockedObservable: Observable<AudioEngine>;
  83462. /**
  83463. * Flags the audio engine in Locked state.
  83464. * This happens due to new browser policies preventing audio to autoplay.
  83465. */
  83466. lock(): void;
  83467. /**
  83468. * Unlocks the audio engine once a user action has been done on the dom.
  83469. * This is helpful to resume play once browser policies have been satisfied.
  83470. */
  83471. unlock(): void;
  83472. }
  83473. /**
  83474. * This represents the default audio engine used in babylon.
  83475. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83477. */
  83478. export class AudioEngine implements IAudioEngine {
  83479. private _audioContext;
  83480. private _audioContextInitialized;
  83481. private _muteButton;
  83482. private _hostElement;
  83483. /**
  83484. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83485. */
  83486. canUseWebAudio: boolean;
  83487. /**
  83488. * The master gain node defines the global audio volume of your audio engine.
  83489. */
  83490. masterGain: GainNode;
  83491. /**
  83492. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83493. * @ignoreNaming
  83494. */
  83495. WarnedWebAudioUnsupported: boolean;
  83496. /**
  83497. * Gets whether or not mp3 are supported by your browser.
  83498. */
  83499. isMP3supported: boolean;
  83500. /**
  83501. * Gets whether or not ogg are supported by your browser.
  83502. */
  83503. isOGGsupported: boolean;
  83504. /**
  83505. * Gets whether audio has been unlocked on the device.
  83506. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83507. * a user interaction has happened.
  83508. */
  83509. unlocked: boolean;
  83510. /**
  83511. * Defines if the audio engine relies on a custom unlocked button.
  83512. * In this case, the embedded button will not be displayed.
  83513. */
  83514. useCustomUnlockedButton: boolean;
  83515. /**
  83516. * Event raised when audio has been unlocked on the browser.
  83517. */
  83518. onAudioUnlockedObservable: Observable<AudioEngine>;
  83519. /**
  83520. * Event raised when audio has been locked on the browser.
  83521. */
  83522. onAudioLockedObservable: Observable<AudioEngine>;
  83523. /**
  83524. * Gets the current AudioContext if available.
  83525. */
  83526. readonly audioContext: Nullable<AudioContext>;
  83527. private _connectedAnalyser;
  83528. /**
  83529. * Instantiates a new audio engine.
  83530. *
  83531. * There should be only one per page as some browsers restrict the number
  83532. * of audio contexts you can create.
  83533. * @param hostElement defines the host element where to display the mute icon if necessary
  83534. */
  83535. constructor(hostElement?: Nullable<HTMLElement>);
  83536. /**
  83537. * Flags the audio engine in Locked state.
  83538. * This happens due to new browser policies preventing audio to autoplay.
  83539. */
  83540. lock(): void;
  83541. /**
  83542. * Unlocks the audio engine once a user action has been done on the dom.
  83543. * This is helpful to resume play once browser policies have been satisfied.
  83544. */
  83545. unlock(): void;
  83546. private _resumeAudioContext;
  83547. private _initializeAudioContext;
  83548. private _tryToRun;
  83549. private _triggerRunningState;
  83550. private _triggerSuspendedState;
  83551. private _displayMuteButton;
  83552. private _moveButtonToTopLeft;
  83553. private _onResize;
  83554. private _hideMuteButton;
  83555. /**
  83556. * Destroy and release the resources associated with the audio ccontext.
  83557. */
  83558. dispose(): void;
  83559. /**
  83560. * Gets the global volume sets on the master gain.
  83561. * @returns the global volume if set or -1 otherwise
  83562. */
  83563. getGlobalVolume(): number;
  83564. /**
  83565. * Sets the global volume of your experience (sets on the master gain).
  83566. * @param newVolume Defines the new global volume of the application
  83567. */
  83568. setGlobalVolume(newVolume: number): void;
  83569. /**
  83570. * Connect the audio engine to an audio analyser allowing some amazing
  83571. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83573. * @param analyser The analyser to connect to the engine
  83574. */
  83575. connectToAnalyser(analyser: Analyser): void;
  83576. }
  83577. }
  83578. declare module BABYLON {
  83579. /**
  83580. * Interface used to present a loading screen while loading a scene
  83581. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83582. */
  83583. export interface ILoadingScreen {
  83584. /**
  83585. * Function called to display the loading screen
  83586. */
  83587. displayLoadingUI: () => void;
  83588. /**
  83589. * Function called to hide the loading screen
  83590. */
  83591. hideLoadingUI: () => void;
  83592. /**
  83593. * Gets or sets the color to use for the background
  83594. */
  83595. loadingUIBackgroundColor: string;
  83596. /**
  83597. * Gets or sets the text to display while loading
  83598. */
  83599. loadingUIText: string;
  83600. }
  83601. /**
  83602. * Class used for the default loading screen
  83603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83604. */
  83605. export class DefaultLoadingScreen implements ILoadingScreen {
  83606. private _renderingCanvas;
  83607. private _loadingText;
  83608. private _loadingDivBackgroundColor;
  83609. private _loadingDiv;
  83610. private _loadingTextDiv;
  83611. /**
  83612. * Creates a new default loading screen
  83613. * @param _renderingCanvas defines the canvas used to render the scene
  83614. * @param _loadingText defines the default text to display
  83615. * @param _loadingDivBackgroundColor defines the default background color
  83616. */
  83617. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83618. /**
  83619. * Function called to display the loading screen
  83620. */
  83621. displayLoadingUI(): void;
  83622. /**
  83623. * Function called to hide the loading screen
  83624. */
  83625. hideLoadingUI(): void;
  83626. /**
  83627. * Gets or sets the text to display while loading
  83628. */
  83629. loadingUIText: string;
  83630. /**
  83631. * Gets or sets the color to use for the background
  83632. */
  83633. loadingUIBackgroundColor: string;
  83634. private _resizeLoadingUI;
  83635. }
  83636. }
  83637. declare module BABYLON {
  83638. /**
  83639. * Settings for finer control over video usage
  83640. */
  83641. export interface VideoTextureSettings {
  83642. /**
  83643. * Applies `autoplay` to video, if specified
  83644. */
  83645. autoPlay?: boolean;
  83646. /**
  83647. * Applies `loop` to video, if specified
  83648. */
  83649. loop?: boolean;
  83650. /**
  83651. * Automatically updates internal texture from video at every frame in the render loop
  83652. */
  83653. autoUpdateTexture: boolean;
  83654. /**
  83655. * Image src displayed during the video loading or until the user interacts with the video.
  83656. */
  83657. poster?: string;
  83658. }
  83659. /**
  83660. * If you want to display a video in your scene, this is the special texture for that.
  83661. * This special texture works similar to other textures, with the exception of a few parameters.
  83662. * @see https://doc.babylonjs.com/how_to/video_texture
  83663. */
  83664. export class VideoTexture extends Texture {
  83665. /**
  83666. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83667. */
  83668. readonly autoUpdateTexture: boolean;
  83669. /**
  83670. * The video instance used by the texture internally
  83671. */
  83672. readonly video: HTMLVideoElement;
  83673. private _onUserActionRequestedObservable;
  83674. /**
  83675. * Event triggerd when a dom action is required by the user to play the video.
  83676. * This happens due to recent changes in browser policies preventing video to auto start.
  83677. */
  83678. readonly onUserActionRequestedObservable: Observable<Texture>;
  83679. private _generateMipMaps;
  83680. private _engine;
  83681. private _stillImageCaptured;
  83682. private _displayingPosterTexture;
  83683. private _settings;
  83684. private _createInternalTextureOnEvent;
  83685. /**
  83686. * Creates a video texture.
  83687. * If you want to display a video in your scene, this is the special texture for that.
  83688. * This special texture works similar to other textures, with the exception of a few parameters.
  83689. * @see https://doc.babylonjs.com/how_to/video_texture
  83690. * @param name optional name, will detect from video source, if not defined
  83691. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83692. * @param scene is obviously the current scene.
  83693. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83694. * @param invertY is false by default but can be used to invert video on Y axis
  83695. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83696. * @param settings allows finer control over video usage
  83697. */
  83698. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83699. private _getName;
  83700. private _getVideo;
  83701. private _createInternalTexture;
  83702. private reset;
  83703. /**
  83704. * @hidden Internal method to initiate `update`.
  83705. */
  83706. _rebuild(): void;
  83707. /**
  83708. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83709. */
  83710. update(): void;
  83711. /**
  83712. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83713. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83714. */
  83715. updateTexture(isVisible: boolean): void;
  83716. protected _updateInternalTexture: () => void;
  83717. /**
  83718. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83719. * @param url New url.
  83720. */
  83721. updateURL(url: string): void;
  83722. /**
  83723. * Dispose the texture and release its associated resources.
  83724. */
  83725. dispose(): void;
  83726. /**
  83727. * Creates a video texture straight from a stream.
  83728. * @param scene Define the scene the texture should be created in
  83729. * @param stream Define the stream the texture should be created from
  83730. * @returns The created video texture as a promise
  83731. */
  83732. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83733. /**
  83734. * Creates a video texture straight from your WebCam video feed.
  83735. * @param scene Define the scene the texture should be created in
  83736. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83737. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83738. * @returns The created video texture as a promise
  83739. */
  83740. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83741. minWidth: number;
  83742. maxWidth: number;
  83743. minHeight: number;
  83744. maxHeight: number;
  83745. deviceId: string;
  83746. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83747. /**
  83748. * Creates a video texture straight from your WebCam video feed.
  83749. * @param scene Define the scene the texture should be created in
  83750. * @param onReady Define a callback to triggered once the texture will be ready
  83751. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83752. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83753. */
  83754. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83755. minWidth: number;
  83756. maxWidth: number;
  83757. minHeight: number;
  83758. maxHeight: number;
  83759. deviceId: string;
  83760. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83761. }
  83762. }
  83763. declare module BABYLON {
  83764. /**
  83765. * Interface for attribute information associated with buffer instanciation
  83766. */
  83767. export class InstancingAttributeInfo {
  83768. /**
  83769. * Index/offset of the attribute in the vertex shader
  83770. */
  83771. index: number;
  83772. /**
  83773. * size of the attribute, 1, 2, 3 or 4
  83774. */
  83775. attributeSize: number;
  83776. /**
  83777. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83778. * default is FLOAT
  83779. */
  83780. attribyteType: number;
  83781. /**
  83782. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83783. */
  83784. normalized: boolean;
  83785. /**
  83786. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83787. */
  83788. offset: number;
  83789. /**
  83790. * Name of the GLSL attribute, for debugging purpose only
  83791. */
  83792. attributeName: string;
  83793. }
  83794. /**
  83795. * Define options used to create a depth texture
  83796. */
  83797. export class DepthTextureCreationOptions {
  83798. /** Specifies whether or not a stencil should be allocated in the texture */
  83799. generateStencil?: boolean;
  83800. /** Specifies whether or not bilinear filtering is enable on the texture */
  83801. bilinearFiltering?: boolean;
  83802. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83803. comparisonFunction?: number;
  83804. /** Specifies if the created texture is a cube texture */
  83805. isCube?: boolean;
  83806. }
  83807. /**
  83808. * Class used to describe the capabilities of the engine relatively to the current browser
  83809. */
  83810. export class EngineCapabilities {
  83811. /** Maximum textures units per fragment shader */
  83812. maxTexturesImageUnits: number;
  83813. /** Maximum texture units per vertex shader */
  83814. maxVertexTextureImageUnits: number;
  83815. /** Maximum textures units in the entire pipeline */
  83816. maxCombinedTexturesImageUnits: number;
  83817. /** Maximum texture size */
  83818. maxTextureSize: number;
  83819. /** Maximum cube texture size */
  83820. maxCubemapTextureSize: number;
  83821. /** Maximum render texture size */
  83822. maxRenderTextureSize: number;
  83823. /** Maximum number of vertex attributes */
  83824. maxVertexAttribs: number;
  83825. /** Maximum number of varyings */
  83826. maxVaryingVectors: number;
  83827. /** Maximum number of uniforms per vertex shader */
  83828. maxVertexUniformVectors: number;
  83829. /** Maximum number of uniforms per fragment shader */
  83830. maxFragmentUniformVectors: number;
  83831. /** Defines if standard derivates (dx/dy) are supported */
  83832. standardDerivatives: boolean;
  83833. /** Defines if s3tc texture compression is supported */
  83834. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83835. /** Defines if pvrtc texture compression is supported */
  83836. pvrtc: any;
  83837. /** Defines if etc1 texture compression is supported */
  83838. etc1: any;
  83839. /** Defines if etc2 texture compression is supported */
  83840. etc2: any;
  83841. /** Defines if astc texture compression is supported */
  83842. astc: any;
  83843. /** Defines if float textures are supported */
  83844. textureFloat: boolean;
  83845. /** Defines if vertex array objects are supported */
  83846. vertexArrayObject: boolean;
  83847. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83848. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83849. /** Gets the maximum level of anisotropy supported */
  83850. maxAnisotropy: number;
  83851. /** Defines if instancing is supported */
  83852. instancedArrays: boolean;
  83853. /** Defines if 32 bits indices are supported */
  83854. uintIndices: boolean;
  83855. /** Defines if high precision shaders are supported */
  83856. highPrecisionShaderSupported: boolean;
  83857. /** Defines if depth reading in the fragment shader is supported */
  83858. fragmentDepthSupported: boolean;
  83859. /** Defines if float texture linear filtering is supported*/
  83860. textureFloatLinearFiltering: boolean;
  83861. /** Defines if rendering to float textures is supported */
  83862. textureFloatRender: boolean;
  83863. /** Defines if half float textures are supported*/
  83864. textureHalfFloat: boolean;
  83865. /** Defines if half float texture linear filtering is supported*/
  83866. textureHalfFloatLinearFiltering: boolean;
  83867. /** Defines if rendering to half float textures is supported */
  83868. textureHalfFloatRender: boolean;
  83869. /** Defines if textureLOD shader command is supported */
  83870. textureLOD: boolean;
  83871. /** Defines if draw buffers extension is supported */
  83872. drawBuffersExtension: boolean;
  83873. /** Defines if depth textures are supported */
  83874. depthTextureExtension: boolean;
  83875. /** Defines if float color buffer are supported */
  83876. colorBufferFloat: boolean;
  83877. /** Gets disjoint timer query extension (null if not supported) */
  83878. timerQuery: EXT_disjoint_timer_query;
  83879. /** Defines if timestamp can be used with timer query */
  83880. canUseTimestampForTimerQuery: boolean;
  83881. /** Function used to let the system compiles shaders in background */
  83882. parallelShaderCompile: {
  83883. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83884. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83885. COMPLETION_STATUS_KHR: number;
  83886. };
  83887. }
  83888. /** Interface defining initialization parameters for Engine class */
  83889. export interface EngineOptions extends WebGLContextAttributes {
  83890. /**
  83891. * Defines if the engine should no exceed a specified device ratio
  83892. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83893. */
  83894. limitDeviceRatio?: number;
  83895. /**
  83896. * Defines if webvr should be enabled automatically
  83897. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83898. */
  83899. autoEnableWebVR?: boolean;
  83900. /**
  83901. * Defines if webgl2 should be turned off even if supported
  83902. * @see http://doc.babylonjs.com/features/webgl2
  83903. */
  83904. disableWebGL2Support?: boolean;
  83905. /**
  83906. * Defines if webaudio should be initialized as well
  83907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83908. */
  83909. audioEngine?: boolean;
  83910. /**
  83911. * Defines if animations should run using a deterministic lock step
  83912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83913. */
  83914. deterministicLockstep?: boolean;
  83915. /** Defines the maximum steps to use with deterministic lock step mode */
  83916. lockstepMaxSteps?: number;
  83917. /**
  83918. * Defines that engine should ignore context lost events
  83919. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83920. */
  83921. doNotHandleContextLost?: boolean;
  83922. /**
  83923. * Defines that engine should ignore modifying touch action attribute and style
  83924. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83925. */
  83926. doNotHandleTouchAction?: boolean;
  83927. }
  83928. /**
  83929. * Defines the interface used by display changed events
  83930. */
  83931. export interface IDisplayChangedEventArgs {
  83932. /** Gets the vrDisplay object (if any) */
  83933. vrDisplay: Nullable<any>;
  83934. /** Gets a boolean indicating if webVR is supported */
  83935. vrSupported: boolean;
  83936. }
  83937. /**
  83938. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83939. */
  83940. export class Engine {
  83941. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83942. static ExceptionList: ({
  83943. key: string;
  83944. capture: string;
  83945. captureConstraint: number;
  83946. targets: string[];
  83947. } | {
  83948. key: string;
  83949. capture: null;
  83950. captureConstraint: null;
  83951. targets: string[];
  83952. })[];
  83953. /** Gets the list of created engines */
  83954. static readonly Instances: Engine[];
  83955. /**
  83956. * Gets the latest created engine
  83957. */
  83958. static readonly LastCreatedEngine: Nullable<Engine>;
  83959. /**
  83960. * Gets the latest created scene
  83961. */
  83962. static readonly LastCreatedScene: Nullable<Scene>;
  83963. /**
  83964. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83965. * @param flag defines which part of the materials must be marked as dirty
  83966. * @param predicate defines a predicate used to filter which materials should be affected
  83967. */
  83968. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83969. /**
  83970. * Hidden
  83971. */
  83972. static _TextureLoaders: IInternalTextureLoader[];
  83973. /** Defines that alpha blending is disabled */
  83974. static readonly ALPHA_DISABLE: number;
  83975. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83976. static readonly ALPHA_ADD: number;
  83977. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83978. static readonly ALPHA_COMBINE: number;
  83979. /** Defines that alpha blending to DEST - SRC * DEST */
  83980. static readonly ALPHA_SUBTRACT: number;
  83981. /** Defines that alpha blending to SRC * DEST */
  83982. static readonly ALPHA_MULTIPLY: number;
  83983. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83984. static readonly ALPHA_MAXIMIZED: number;
  83985. /** Defines that alpha blending to SRC + DEST */
  83986. static readonly ALPHA_ONEONE: number;
  83987. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83988. static readonly ALPHA_PREMULTIPLIED: number;
  83989. /**
  83990. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83991. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83992. */
  83993. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83994. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83995. static readonly ALPHA_INTERPOLATE: number;
  83996. /**
  83997. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83998. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83999. */
  84000. static readonly ALPHA_SCREENMODE: number;
  84001. /** Defines that the ressource is not delayed*/
  84002. static readonly DELAYLOADSTATE_NONE: number;
  84003. /** Defines that the ressource was successfully delay loaded */
  84004. static readonly DELAYLOADSTATE_LOADED: number;
  84005. /** Defines that the ressource is currently delay loading */
  84006. static readonly DELAYLOADSTATE_LOADING: number;
  84007. /** Defines that the ressource is delayed and has not started loading */
  84008. static readonly DELAYLOADSTATE_NOTLOADED: number;
  84009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  84010. static readonly NEVER: number;
  84011. /** 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 */
  84012. static readonly ALWAYS: number;
  84013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  84014. static readonly LESS: number;
  84015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  84016. static readonly EQUAL: number;
  84017. /** 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 */
  84018. static readonly LEQUAL: number;
  84019. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84020. static readonly GREATER: number;
  84021. /** 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 */
  84022. static readonly GEQUAL: number;
  84023. /** 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 */
  84024. static readonly NOTEQUAL: number;
  84025. /** Passed to stencilOperation to specify that stencil value must be kept */
  84026. static readonly KEEP: number;
  84027. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84028. static readonly REPLACE: number;
  84029. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84030. static readonly INCR: number;
  84031. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84032. static readonly DECR: number;
  84033. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84034. static readonly INVERT: number;
  84035. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84036. static readonly INCR_WRAP: number;
  84037. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84038. static readonly DECR_WRAP: number;
  84039. /** Texture is not repeating outside of 0..1 UVs */
  84040. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84041. /** Texture is repeating outside of 0..1 UVs */
  84042. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84043. /** Texture is repeating and mirrored */
  84044. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84045. /** ALPHA */
  84046. static readonly TEXTUREFORMAT_ALPHA: number;
  84047. /** LUMINANCE */
  84048. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84049. /** LUMINANCE_ALPHA */
  84050. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84051. /** RGB */
  84052. static readonly TEXTUREFORMAT_RGB: number;
  84053. /** RGBA */
  84054. static readonly TEXTUREFORMAT_RGBA: number;
  84055. /** RED */
  84056. static readonly TEXTUREFORMAT_RED: number;
  84057. /** RED (2nd reference) */
  84058. static readonly TEXTUREFORMAT_R: number;
  84059. /** RG */
  84060. static readonly TEXTUREFORMAT_RG: number;
  84061. /** RED_INTEGER */
  84062. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84063. /** RED_INTEGER (2nd reference) */
  84064. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84065. /** RG_INTEGER */
  84066. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84067. /** RGB_INTEGER */
  84068. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84069. /** RGBA_INTEGER */
  84070. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84071. /** UNSIGNED_BYTE */
  84072. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84073. /** UNSIGNED_BYTE (2nd reference) */
  84074. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84075. /** FLOAT */
  84076. static readonly TEXTURETYPE_FLOAT: number;
  84077. /** HALF_FLOAT */
  84078. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84079. /** BYTE */
  84080. static readonly TEXTURETYPE_BYTE: number;
  84081. /** SHORT */
  84082. static readonly TEXTURETYPE_SHORT: number;
  84083. /** UNSIGNED_SHORT */
  84084. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84085. /** INT */
  84086. static readonly TEXTURETYPE_INT: number;
  84087. /** UNSIGNED_INT */
  84088. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84089. /** UNSIGNED_SHORT_4_4_4_4 */
  84090. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84091. /** UNSIGNED_SHORT_5_5_5_1 */
  84092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84093. /** UNSIGNED_SHORT_5_6_5 */
  84094. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84095. /** UNSIGNED_INT_2_10_10_10_REV */
  84096. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84097. /** UNSIGNED_INT_24_8 */
  84098. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84099. /** UNSIGNED_INT_10F_11F_11F_REV */
  84100. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84101. /** UNSIGNED_INT_5_9_9_9_REV */
  84102. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84103. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84104. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84105. /** nearest is mag = nearest and min = nearest and mip = linear */
  84106. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84107. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84108. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84109. /** Trilinear is mag = linear and min = linear and mip = linear */
  84110. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84111. /** nearest is mag = nearest and min = nearest and mip = linear */
  84112. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84113. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84114. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84115. /** Trilinear is mag = linear and min = linear and mip = linear */
  84116. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84117. /** mag = nearest and min = nearest and mip = nearest */
  84118. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84119. /** mag = nearest and min = linear and mip = nearest */
  84120. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84121. /** mag = nearest and min = linear and mip = linear */
  84122. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84123. /** mag = nearest and min = linear and mip = none */
  84124. static readonly TEXTURE_NEAREST_LINEAR: number;
  84125. /** mag = nearest and min = nearest and mip = none */
  84126. static readonly TEXTURE_NEAREST_NEAREST: number;
  84127. /** mag = linear and min = nearest and mip = nearest */
  84128. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84129. /** mag = linear and min = nearest and mip = linear */
  84130. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84131. /** mag = linear and min = linear and mip = none */
  84132. static readonly TEXTURE_LINEAR_LINEAR: number;
  84133. /** mag = linear and min = nearest and mip = none */
  84134. static readonly TEXTURE_LINEAR_NEAREST: number;
  84135. /** Explicit coordinates mode */
  84136. static readonly TEXTURE_EXPLICIT_MODE: number;
  84137. /** Spherical coordinates mode */
  84138. static readonly TEXTURE_SPHERICAL_MODE: number;
  84139. /** Planar coordinates mode */
  84140. static readonly TEXTURE_PLANAR_MODE: number;
  84141. /** Cubic coordinates mode */
  84142. static readonly TEXTURE_CUBIC_MODE: number;
  84143. /** Projection coordinates mode */
  84144. static readonly TEXTURE_PROJECTION_MODE: number;
  84145. /** Skybox coordinates mode */
  84146. static readonly TEXTURE_SKYBOX_MODE: number;
  84147. /** Inverse Cubic coordinates mode */
  84148. static readonly TEXTURE_INVCUBIC_MODE: number;
  84149. /** Equirectangular coordinates mode */
  84150. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84151. /** Equirectangular Fixed coordinates mode */
  84152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84153. /** Equirectangular Fixed Mirrored coordinates mode */
  84154. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84155. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84156. static readonly SCALEMODE_FLOOR: number;
  84157. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84158. static readonly SCALEMODE_NEAREST: number;
  84159. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84160. static readonly SCALEMODE_CEILING: number;
  84161. /**
  84162. * Returns the current version of the framework
  84163. */
  84164. static readonly Version: string;
  84165. /**
  84166. * Returns a string describing the current engine
  84167. */
  84168. readonly description: string;
  84169. /**
  84170. * Gets or sets the epsilon value used by collision engine
  84171. */
  84172. static CollisionsEpsilon: number;
  84173. /**
  84174. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84175. */
  84176. static ShadersRepository: string;
  84177. /**
  84178. * Method called to create the default loading screen.
  84179. * This can be overriden in your own app.
  84180. * @param canvas The rendering canvas element
  84181. * @returns The loading screen
  84182. */
  84183. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84184. /**
  84185. * Method called to create the default rescale post process on each engine.
  84186. */
  84187. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84188. /**
  84189. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84190. */
  84191. forcePOTTextures: boolean;
  84192. /**
  84193. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84194. */
  84195. isFullscreen: boolean;
  84196. /**
  84197. * Gets a boolean indicating if the pointer is currently locked
  84198. */
  84199. isPointerLock: boolean;
  84200. /**
  84201. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84202. */
  84203. cullBackFaces: boolean;
  84204. /**
  84205. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84206. */
  84207. renderEvenInBackground: boolean;
  84208. /**
  84209. * Gets or sets a boolean indicating that cache can be kept between frames
  84210. */
  84211. preventCacheWipeBetweenFrames: boolean;
  84212. /**
  84213. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84214. **/
  84215. enableOfflineSupport: boolean;
  84216. /**
  84217. * 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)
  84218. **/
  84219. disableManifestCheck: boolean;
  84220. /**
  84221. * Gets the list of created scenes
  84222. */
  84223. scenes: Scene[];
  84224. /**
  84225. * Event raised when a new scene is created
  84226. */
  84227. onNewSceneAddedObservable: Observable<Scene>;
  84228. /**
  84229. * Gets the list of created postprocesses
  84230. */
  84231. postProcesses: PostProcess[];
  84232. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84233. validateShaderPrograms: boolean;
  84234. /**
  84235. * Observable event triggered each time the rendering canvas is resized
  84236. */
  84237. onResizeObservable: Observable<Engine>;
  84238. /**
  84239. * Observable event triggered each time the canvas loses focus
  84240. */
  84241. onCanvasBlurObservable: Observable<Engine>;
  84242. /**
  84243. * Observable event triggered each time the canvas gains focus
  84244. */
  84245. onCanvasFocusObservable: Observable<Engine>;
  84246. /**
  84247. * Observable event triggered each time the canvas receives pointerout event
  84248. */
  84249. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84250. /**
  84251. * Observable event triggered before each texture is initialized
  84252. */
  84253. onBeforeTextureInitObservable: Observable<Texture>;
  84254. private _vrDisplay;
  84255. private _vrSupported;
  84256. private _oldSize;
  84257. private _oldHardwareScaleFactor;
  84258. private _vrExclusivePointerMode;
  84259. private _webVRInitPromise;
  84260. /**
  84261. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84262. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84263. */
  84264. readonly isInVRExclusivePointerMode: boolean;
  84265. /**
  84266. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84267. */
  84268. disableUniformBuffers: boolean;
  84269. /** @hidden */
  84270. _uniformBuffers: UniformBuffer[];
  84271. /**
  84272. * Gets a boolean indicating that the engine supports uniform buffers
  84273. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84274. */
  84275. readonly supportsUniformBuffers: boolean;
  84276. /**
  84277. * Observable raised when the engine begins a new frame
  84278. */
  84279. onBeginFrameObservable: Observable<Engine>;
  84280. /**
  84281. * If set, will be used to request the next animation frame for the render loop
  84282. */
  84283. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84284. /**
  84285. * Observable raised when the engine ends the current frame
  84286. */
  84287. onEndFrameObservable: Observable<Engine>;
  84288. /**
  84289. * Observable raised when the engine is about to compile a shader
  84290. */
  84291. onBeforeShaderCompilationObservable: Observable<Engine>;
  84292. /**
  84293. * Observable raised when the engine has jsut compiled a shader
  84294. */
  84295. onAfterShaderCompilationObservable: Observable<Engine>;
  84296. /** @hidden */
  84297. _gl: WebGLRenderingContext;
  84298. private _renderingCanvas;
  84299. private _windowIsBackground;
  84300. private _webGLVersion;
  84301. /**
  84302. * Gets a boolean indicating that only power of 2 textures are supported
  84303. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84304. */
  84305. readonly needPOTTextures: boolean;
  84306. /** @hidden */
  84307. _badOS: boolean;
  84308. /** @hidden */
  84309. _badDesktopOS: boolean;
  84310. /**
  84311. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84312. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84313. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84314. */
  84315. disableTextureBindingOptimization: boolean;
  84316. /**
  84317. * Gets the audio engine
  84318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84319. * @ignorenaming
  84320. */
  84321. static audioEngine: IAudioEngine;
  84322. /**
  84323. * Default AudioEngine factory responsible of creating the Audio Engine.
  84324. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84325. */
  84326. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84327. /**
  84328. * Default offline support factory responsible of creating a tool used to store data locally.
  84329. * By default, this will create a Database object if the workload has been embedded.
  84330. */
  84331. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84332. private _onFocus;
  84333. private _onBlur;
  84334. private _onCanvasPointerOut;
  84335. private _onCanvasBlur;
  84336. private _onCanvasFocus;
  84337. private _onFullscreenChange;
  84338. private _onPointerLockChange;
  84339. private _onVRDisplayPointerRestricted;
  84340. private _onVRDisplayPointerUnrestricted;
  84341. private _onVrDisplayConnect;
  84342. private _onVrDisplayDisconnect;
  84343. private _onVrDisplayPresentChange;
  84344. /**
  84345. * Observable signaled when VR display mode changes
  84346. */
  84347. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84348. /**
  84349. * Observable signaled when VR request present is complete
  84350. */
  84351. onVRRequestPresentComplete: Observable<boolean>;
  84352. /**
  84353. * Observable signaled when VR request present starts
  84354. */
  84355. onVRRequestPresentStart: Observable<Engine>;
  84356. private _hardwareScalingLevel;
  84357. /** @hidden */
  84358. protected _caps: EngineCapabilities;
  84359. private _pointerLockRequested;
  84360. private _isStencilEnable;
  84361. private _colorWrite;
  84362. private _loadingScreen;
  84363. /** @hidden */
  84364. _drawCalls: PerfCounter;
  84365. /** @hidden */
  84366. _textureCollisions: PerfCounter;
  84367. private _glVersion;
  84368. private _glRenderer;
  84369. private _glVendor;
  84370. private _videoTextureSupported;
  84371. private _renderingQueueLaunched;
  84372. private _activeRenderLoops;
  84373. private _deterministicLockstep;
  84374. private _lockstepMaxSteps;
  84375. /**
  84376. * Observable signaled when a context lost event is raised
  84377. */
  84378. onContextLostObservable: Observable<Engine>;
  84379. /**
  84380. * Observable signaled when a context restored event is raised
  84381. */
  84382. onContextRestoredObservable: Observable<Engine>;
  84383. private _onContextLost;
  84384. private _onContextRestored;
  84385. private _contextWasLost;
  84386. private _doNotHandleContextLost;
  84387. /**
  84388. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84389. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84390. */
  84391. doNotHandleContextLost: boolean;
  84392. private _performanceMonitor;
  84393. private _fps;
  84394. private _deltaTime;
  84395. /**
  84396. * Turn this value on if you want to pause FPS computation when in background
  84397. */
  84398. disablePerformanceMonitorInBackground: boolean;
  84399. /**
  84400. * Gets the performance monitor attached to this engine
  84401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84402. */
  84403. readonly performanceMonitor: PerformanceMonitor;
  84404. /** @hidden */
  84405. protected _depthCullingState: _DepthCullingState;
  84406. /** @hidden */
  84407. protected _stencilState: _StencilState;
  84408. /** @hidden */
  84409. protected _alphaState: _AlphaState;
  84410. /** @hidden */
  84411. protected _alphaMode: number;
  84412. protected _internalTexturesCache: InternalTexture[];
  84413. /** @hidden */
  84414. protected _activeChannel: number;
  84415. private _currentTextureChannel;
  84416. /** @hidden */
  84417. protected _boundTexturesCache: {
  84418. [key: string]: Nullable<InternalTexture>;
  84419. };
  84420. /** @hidden */
  84421. protected _currentEffect: Nullable<Effect>;
  84422. /** @hidden */
  84423. protected _currentProgram: Nullable<WebGLProgram>;
  84424. private _compiledEffects;
  84425. private _vertexAttribArraysEnabled;
  84426. /** @hidden */
  84427. protected _cachedViewport: Nullable<Viewport>;
  84428. private _cachedVertexArrayObject;
  84429. /** @hidden */
  84430. protected _cachedVertexBuffers: any;
  84431. /** @hidden */
  84432. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84433. /** @hidden */
  84434. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84435. /** @hidden */
  84436. protected _currentRenderTarget: Nullable<InternalTexture>;
  84437. private _uintIndicesCurrentlySet;
  84438. private _currentBoundBuffer;
  84439. /** @hidden */
  84440. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84441. private _currentBufferPointers;
  84442. private _currentInstanceLocations;
  84443. private _currentInstanceBuffers;
  84444. private _textureUnits;
  84445. private _firstBoundInternalTextureTracker;
  84446. private _lastBoundInternalTextureTracker;
  84447. private _workingCanvas;
  84448. private _workingContext;
  84449. private _rescalePostProcess;
  84450. private _dummyFramebuffer;
  84451. private _externalData;
  84452. private _bindedRenderFunction;
  84453. private _vaoRecordInProgress;
  84454. private _mustWipeVertexAttributes;
  84455. private _emptyTexture;
  84456. private _emptyCubeTexture;
  84457. private _emptyTexture3D;
  84458. /** @hidden */
  84459. _frameHandler: number;
  84460. private _nextFreeTextureSlots;
  84461. private _maxSimultaneousTextures;
  84462. private _activeRequests;
  84463. private _texturesSupported;
  84464. private _textureFormatInUse;
  84465. /**
  84466. * Gets the list of texture formats supported
  84467. */
  84468. readonly texturesSupported: Array<string>;
  84469. /**
  84470. * Gets the list of texture formats in use
  84471. */
  84472. readonly textureFormatInUse: Nullable<string>;
  84473. /**
  84474. * Gets the current viewport
  84475. */
  84476. readonly currentViewport: Nullable<Viewport>;
  84477. /**
  84478. * Gets the default empty texture
  84479. */
  84480. readonly emptyTexture: InternalTexture;
  84481. /**
  84482. * Gets the default empty 3D texture
  84483. */
  84484. readonly emptyTexture3D: InternalTexture;
  84485. /**
  84486. * Gets the default empty cube texture
  84487. */
  84488. readonly emptyCubeTexture: InternalTexture;
  84489. /**
  84490. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84491. */
  84492. readonly premultipliedAlpha: boolean;
  84493. /**
  84494. * Creates a new engine
  84495. * @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
  84496. * @param antialias defines enable antialiasing (default: false)
  84497. * @param options defines further options to be sent to the getContext() function
  84498. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84499. */
  84500. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84501. private _disableTouchAction;
  84502. private _rebuildInternalTextures;
  84503. private _rebuildEffects;
  84504. /**
  84505. * Gets a boolean indicating if all created effects are ready
  84506. * @returns true if all effects are ready
  84507. */
  84508. areAllEffectsReady(): boolean;
  84509. private _rebuildBuffers;
  84510. private _initGLContext;
  84511. /**
  84512. * Gets version of the current webGL context
  84513. */
  84514. readonly webGLVersion: number;
  84515. /**
  84516. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84517. */
  84518. readonly isStencilEnable: boolean;
  84519. private _prepareWorkingCanvas;
  84520. /**
  84521. * Reset the texture cache to empty state
  84522. */
  84523. resetTextureCache(): void;
  84524. /**
  84525. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84526. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84527. * @returns true if engine is in deterministic lock step mode
  84528. */
  84529. isDeterministicLockStep(): boolean;
  84530. /**
  84531. * Gets the max steps when engine is running in deterministic lock step
  84532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84533. * @returns the max steps
  84534. */
  84535. getLockstepMaxSteps(): number;
  84536. /**
  84537. * Gets an object containing information about the current webGL context
  84538. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84539. */
  84540. getGlInfo(): {
  84541. vendor: string;
  84542. renderer: string;
  84543. version: string;
  84544. };
  84545. /**
  84546. * Gets current aspect ratio
  84547. * @param camera defines the camera to use to get the aspect ratio
  84548. * @param useScreen defines if screen size must be used (or the current render target if any)
  84549. * @returns a number defining the aspect ratio
  84550. */
  84551. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84552. /**
  84553. * Gets current screen aspect ratio
  84554. * @returns a number defining the aspect ratio
  84555. */
  84556. getScreenAspectRatio(): number;
  84557. /**
  84558. * Gets the current render width
  84559. * @param useScreen defines if screen size must be used (or the current render target if any)
  84560. * @returns a number defining the current render width
  84561. */
  84562. getRenderWidth(useScreen?: boolean): number;
  84563. /**
  84564. * Gets the current render height
  84565. * @param useScreen defines if screen size must be used (or the current render target if any)
  84566. * @returns a number defining the current render height
  84567. */
  84568. getRenderHeight(useScreen?: boolean): number;
  84569. /**
  84570. * Gets the HTML canvas attached with the current webGL context
  84571. * @returns a HTML canvas
  84572. */
  84573. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84574. /**
  84575. * Gets the client rect of the HTML canvas attached with the current webGL context
  84576. * @returns a client rectanglee
  84577. */
  84578. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84579. /**
  84580. * Defines the hardware scaling level.
  84581. * By default the hardware scaling level is computed from the window device ratio.
  84582. * 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.
  84583. * @param level defines the level to use
  84584. */
  84585. setHardwareScalingLevel(level: number): void;
  84586. /**
  84587. * Gets the current hardware scaling level.
  84588. * By default the hardware scaling level is computed from the window device ratio.
  84589. * 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.
  84590. * @returns a number indicating the current hardware scaling level
  84591. */
  84592. getHardwareScalingLevel(): number;
  84593. /**
  84594. * Gets the list of loaded textures
  84595. * @returns an array containing all loaded textures
  84596. */
  84597. getLoadedTexturesCache(): InternalTexture[];
  84598. /**
  84599. * Gets the object containing all engine capabilities
  84600. * @returns the EngineCapabilities object
  84601. */
  84602. getCaps(): EngineCapabilities;
  84603. /**
  84604. * Gets the current depth function
  84605. * @returns a number defining the depth function
  84606. */
  84607. getDepthFunction(): Nullable<number>;
  84608. /**
  84609. * Sets the current depth function
  84610. * @param depthFunc defines the function to use
  84611. */
  84612. setDepthFunction(depthFunc: number): void;
  84613. /**
  84614. * Sets the current depth function to GREATER
  84615. */
  84616. setDepthFunctionToGreater(): void;
  84617. /**
  84618. * Sets the current depth function to GEQUAL
  84619. */
  84620. setDepthFunctionToGreaterOrEqual(): void;
  84621. /**
  84622. * Sets the current depth function to LESS
  84623. */
  84624. setDepthFunctionToLess(): void;
  84625. /**
  84626. * Sets the current depth function to LEQUAL
  84627. */
  84628. setDepthFunctionToLessOrEqual(): void;
  84629. /**
  84630. * Gets a boolean indicating if stencil buffer is enabled
  84631. * @returns the current stencil buffer state
  84632. */
  84633. getStencilBuffer(): boolean;
  84634. /**
  84635. * Enable or disable the stencil buffer
  84636. * @param enable defines if the stencil buffer must be enabled or disabled
  84637. */
  84638. setStencilBuffer(enable: boolean): void;
  84639. /**
  84640. * Gets the current stencil mask
  84641. * @returns a number defining the new stencil mask to use
  84642. */
  84643. getStencilMask(): number;
  84644. /**
  84645. * Sets the current stencil mask
  84646. * @param mask defines the new stencil mask to use
  84647. */
  84648. setStencilMask(mask: number): void;
  84649. /**
  84650. * Gets the current stencil function
  84651. * @returns a number defining the stencil function to use
  84652. */
  84653. getStencilFunction(): number;
  84654. /**
  84655. * Gets the current stencil reference value
  84656. * @returns a number defining the stencil reference value to use
  84657. */
  84658. getStencilFunctionReference(): number;
  84659. /**
  84660. * Gets the current stencil mask
  84661. * @returns a number defining the stencil mask to use
  84662. */
  84663. getStencilFunctionMask(): number;
  84664. /**
  84665. * Sets the current stencil function
  84666. * @param stencilFunc defines the new stencil function to use
  84667. */
  84668. setStencilFunction(stencilFunc: number): void;
  84669. /**
  84670. * Sets the current stencil reference
  84671. * @param reference defines the new stencil reference to use
  84672. */
  84673. setStencilFunctionReference(reference: number): void;
  84674. /**
  84675. * Sets the current stencil mask
  84676. * @param mask defines the new stencil mask to use
  84677. */
  84678. setStencilFunctionMask(mask: number): void;
  84679. /**
  84680. * Gets the current stencil operation when stencil fails
  84681. * @returns a number defining stencil operation to use when stencil fails
  84682. */
  84683. getStencilOperationFail(): number;
  84684. /**
  84685. * Gets the current stencil operation when depth fails
  84686. * @returns a number defining stencil operation to use when depth fails
  84687. */
  84688. getStencilOperationDepthFail(): number;
  84689. /**
  84690. * Gets the current stencil operation when stencil passes
  84691. * @returns a number defining stencil operation to use when stencil passes
  84692. */
  84693. getStencilOperationPass(): number;
  84694. /**
  84695. * Sets the stencil operation to use when stencil fails
  84696. * @param operation defines the stencil operation to use when stencil fails
  84697. */
  84698. setStencilOperationFail(operation: number): void;
  84699. /**
  84700. * Sets the stencil operation to use when depth fails
  84701. * @param operation defines the stencil operation to use when depth fails
  84702. */
  84703. setStencilOperationDepthFail(operation: number): void;
  84704. /**
  84705. * Sets the stencil operation to use when stencil passes
  84706. * @param operation defines the stencil operation to use when stencil passes
  84707. */
  84708. setStencilOperationPass(operation: number): void;
  84709. /**
  84710. * Sets a boolean indicating if the dithering state is enabled or disabled
  84711. * @param value defines the dithering state
  84712. */
  84713. setDitheringState(value: boolean): void;
  84714. /**
  84715. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84716. * @param value defines the rasterizer state
  84717. */
  84718. setRasterizerState(value: boolean): void;
  84719. /**
  84720. * stop executing a render loop function and remove it from the execution array
  84721. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84722. */
  84723. stopRenderLoop(renderFunction?: () => void): void;
  84724. /** @hidden */
  84725. _renderLoop(): void;
  84726. /**
  84727. * Register and execute a render loop. The engine can have more than one render function
  84728. * @param renderFunction defines the function to continuously execute
  84729. */
  84730. runRenderLoop(renderFunction: () => void): void;
  84731. /**
  84732. * Toggle full screen mode
  84733. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84734. */
  84735. switchFullscreen(requestPointerLock: boolean): void;
  84736. /**
  84737. * Enters full screen mode
  84738. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84739. */
  84740. enterFullscreen(requestPointerLock: boolean): void;
  84741. /**
  84742. * Exits full screen mode
  84743. */
  84744. exitFullscreen(): void;
  84745. /**
  84746. * Clear the current render buffer or the current render target (if any is set up)
  84747. * @param color defines the color to use
  84748. * @param backBuffer defines if the back buffer must be cleared
  84749. * @param depth defines if the depth buffer must be cleared
  84750. * @param stencil defines if the stencil buffer must be cleared
  84751. */
  84752. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84753. /**
  84754. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84755. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84756. * @param y defines the y-coordinate of the corner of the clear rectangle
  84757. * @param width defines the width of the clear rectangle
  84758. * @param height defines the height of the clear rectangle
  84759. * @param clearColor defines the clear color
  84760. */
  84761. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84762. /**
  84763. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84764. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84765. * @param y defines the y-coordinate of the corner of the clear rectangle
  84766. * @param width defines the width of the clear rectangle
  84767. * @param height defines the height of the clear rectangle
  84768. */
  84769. enableScissor(x: number, y: number, width: number, height: number): void;
  84770. /**
  84771. * Disable previously set scissor test rectangle
  84772. */
  84773. disableScissor(): void;
  84774. private _viewportCached;
  84775. /** @hidden */
  84776. _viewport(x: number, y: number, width: number, height: number): void;
  84777. /**
  84778. * Set the WebGL's viewport
  84779. * @param viewport defines the viewport element to be used
  84780. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84781. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84782. */
  84783. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84784. /**
  84785. * Directly set the WebGL Viewport
  84786. * @param x defines the x coordinate of the viewport (in screen space)
  84787. * @param y defines the y coordinate of the viewport (in screen space)
  84788. * @param width defines the width of the viewport (in screen space)
  84789. * @param height defines the height of the viewport (in screen space)
  84790. * @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
  84791. */
  84792. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84793. /**
  84794. * Begin a new frame
  84795. */
  84796. beginFrame(): void;
  84797. /**
  84798. * Enf the current frame
  84799. */
  84800. endFrame(): void;
  84801. /**
  84802. * Resize the view according to the canvas' size
  84803. */
  84804. resize(): void;
  84805. /**
  84806. * Force a specific size of the canvas
  84807. * @param width defines the new canvas' width
  84808. * @param height defines the new canvas' height
  84809. */
  84810. setSize(width: number, height: number): void;
  84811. /**
  84812. * Gets a boolean indicating if a webVR device was detected
  84813. * @returns true if a webVR device was detected
  84814. */
  84815. isVRDevicePresent(): boolean;
  84816. /**
  84817. * Gets the current webVR device
  84818. * @returns the current webVR device (or null)
  84819. */
  84820. getVRDevice(): any;
  84821. /**
  84822. * Initializes a webVR display and starts listening to display change events
  84823. * The onVRDisplayChangedObservable will be notified upon these changes
  84824. * @returns The onVRDisplayChangedObservable
  84825. */
  84826. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84827. /**
  84828. * Initializes a webVR display and starts listening to display change events
  84829. * The onVRDisplayChangedObservable will be notified upon these changes
  84830. * @returns A promise containing a VRDisplay and if vr is supported
  84831. */
  84832. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84833. /**
  84834. * Call this function to switch to webVR mode
  84835. * Will do nothing if webVR is not supported or if there is no webVR device
  84836. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84837. */
  84838. enableVR(): void;
  84839. /**
  84840. * Call this function to leave webVR mode
  84841. * Will do nothing if webVR is not supported or if there is no webVR device
  84842. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84843. */
  84844. disableVR(): void;
  84845. private _onVRFullScreenTriggered;
  84846. private _getVRDisplaysAsync;
  84847. /**
  84848. * Binds the frame buffer to the specified texture.
  84849. * @param texture The texture to render to or null for the default canvas
  84850. * @param faceIndex The face of the texture to render to in case of cube texture
  84851. * @param requiredWidth The width of the target to render to
  84852. * @param requiredHeight The height of the target to render to
  84853. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84854. * @param depthStencilTexture The depth stencil texture to use to render
  84855. * @param lodLevel defines le lod level to bind to the frame buffer
  84856. */
  84857. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84858. private bindUnboundFramebuffer;
  84859. /**
  84860. * Unbind the current render target texture from the webGL context
  84861. * @param texture defines the render target texture to unbind
  84862. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84863. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84864. */
  84865. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84866. /**
  84867. * Unbind a list of render target textures from the webGL context
  84868. * This is used only when drawBuffer extension or webGL2 are active
  84869. * @param textures defines the render target textures to unbind
  84870. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84871. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84872. */
  84873. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84874. /**
  84875. * Force the mipmap generation for the given render target texture
  84876. * @param texture defines the render target texture to use
  84877. */
  84878. generateMipMapsForCubemap(texture: InternalTexture): void;
  84879. /**
  84880. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84881. */
  84882. flushFramebuffer(): void;
  84883. /**
  84884. * Unbind the current render target and bind the default framebuffer
  84885. */
  84886. restoreDefaultFramebuffer(): void;
  84887. /**
  84888. * Create an uniform buffer
  84889. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84890. * @param elements defines the content of the uniform buffer
  84891. * @returns the webGL uniform buffer
  84892. */
  84893. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84894. /**
  84895. * Create a dynamic uniform buffer
  84896. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84897. * @param elements defines the content of the uniform buffer
  84898. * @returns the webGL uniform buffer
  84899. */
  84900. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84901. /**
  84902. * Update an existing uniform buffer
  84903. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84904. * @param uniformBuffer defines the target uniform buffer
  84905. * @param elements defines the content to update
  84906. * @param offset defines the offset in the uniform buffer where update should start
  84907. * @param count defines the size of the data to update
  84908. */
  84909. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84910. private _resetVertexBufferBinding;
  84911. /**
  84912. * Creates a vertex buffer
  84913. * @param data the data for the vertex buffer
  84914. * @returns the new WebGL static buffer
  84915. */
  84916. createVertexBuffer(data: DataArray): WebGLBuffer;
  84917. /**
  84918. * Creates a dynamic vertex buffer
  84919. * @param data the data for the dynamic vertex buffer
  84920. * @returns the new WebGL dynamic buffer
  84921. */
  84922. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84923. /**
  84924. * Update a dynamic index buffer
  84925. * @param indexBuffer defines the target index buffer
  84926. * @param indices defines the data to update
  84927. * @param offset defines the offset in the target index buffer where update should start
  84928. */
  84929. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84930. /**
  84931. * Updates a dynamic vertex buffer.
  84932. * @param vertexBuffer the vertex buffer to update
  84933. * @param data the data used to update the vertex buffer
  84934. * @param byteOffset the byte offset of the data
  84935. * @param byteLength the byte length of the data
  84936. */
  84937. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84938. private _resetIndexBufferBinding;
  84939. /**
  84940. * Creates a new index buffer
  84941. * @param indices defines the content of the index buffer
  84942. * @param updatable defines if the index buffer must be updatable
  84943. * @returns a new webGL buffer
  84944. */
  84945. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84946. /**
  84947. * Bind a webGL buffer to the webGL context
  84948. * @param buffer defines the buffer to bind
  84949. */
  84950. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84951. /**
  84952. * Bind an uniform buffer to the current webGL context
  84953. * @param buffer defines the buffer to bind
  84954. */
  84955. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84956. /**
  84957. * Bind a buffer to the current webGL context at a given location
  84958. * @param buffer defines the buffer to bind
  84959. * @param location defines the index where to bind the buffer
  84960. */
  84961. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84962. /**
  84963. * Bind a specific block at a given index in a specific shader program
  84964. * @param shaderProgram defines the shader program
  84965. * @param blockName defines the block name
  84966. * @param index defines the index where to bind the block
  84967. */
  84968. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84969. private bindIndexBuffer;
  84970. private bindBuffer;
  84971. /**
  84972. * update the bound buffer with the given data
  84973. * @param data defines the data to update
  84974. */
  84975. updateArrayBuffer(data: Float32Array): void;
  84976. private _vertexAttribPointer;
  84977. private _bindIndexBufferWithCache;
  84978. private _bindVertexBuffersAttributes;
  84979. /**
  84980. * Records a vertex array object
  84981. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84982. * @param vertexBuffers defines the list of vertex buffers to store
  84983. * @param indexBuffer defines the index buffer to store
  84984. * @param effect defines the effect to store
  84985. * @returns the new vertex array object
  84986. */
  84987. recordVertexArrayObject(vertexBuffers: {
  84988. [key: string]: VertexBuffer;
  84989. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84990. /**
  84991. * Bind a specific vertex array object
  84992. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84993. * @param vertexArrayObject defines the vertex array object to bind
  84994. * @param indexBuffer defines the index buffer to bind
  84995. */
  84996. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84997. /**
  84998. * Bind webGl buffers directly to the webGL context
  84999. * @param vertexBuffer defines the vertex buffer to bind
  85000. * @param indexBuffer defines the index buffer to bind
  85001. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  85002. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  85003. * @param effect defines the effect associated with the vertex buffer
  85004. */
  85005. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  85006. private _unbindVertexArrayObject;
  85007. /**
  85008. * Bind a list of vertex buffers to the webGL context
  85009. * @param vertexBuffers defines the list of vertex buffers to bind
  85010. * @param indexBuffer defines the index buffer to bind
  85011. * @param effect defines the effect associated with the vertex buffers
  85012. */
  85013. bindBuffers(vertexBuffers: {
  85014. [key: string]: Nullable<VertexBuffer>;
  85015. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  85016. /**
  85017. * Unbind all instance attributes
  85018. */
  85019. unbindInstanceAttributes(): void;
  85020. /**
  85021. * Release and free the memory of a vertex array object
  85022. * @param vao defines the vertex array object to delete
  85023. */
  85024. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85025. /** @hidden */
  85026. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85027. /**
  85028. * Creates a webGL buffer to use with instanciation
  85029. * @param capacity defines the size of the buffer
  85030. * @returns the webGL buffer
  85031. */
  85032. createInstancesBuffer(capacity: number): WebGLBuffer;
  85033. /**
  85034. * Delete a webGL buffer used with instanciation
  85035. * @param buffer defines the webGL buffer to delete
  85036. */
  85037. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85038. /**
  85039. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85040. * @param instancesBuffer defines the webGL buffer to update and bind
  85041. * @param data defines the data to store in the buffer
  85042. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85043. */
  85044. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85045. /**
  85046. * Apply all cached states (depth, culling, stencil and alpha)
  85047. */
  85048. applyStates(): void;
  85049. /**
  85050. * Send a draw order
  85051. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85052. * @param indexStart defines the starting index
  85053. * @param indexCount defines the number of index to draw
  85054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85055. */
  85056. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85057. /**
  85058. * Draw a list of points
  85059. * @param verticesStart defines the index of first vertex to draw
  85060. * @param verticesCount defines the count of vertices to draw
  85061. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85062. */
  85063. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85064. /**
  85065. * Draw a list of unindexed primitives
  85066. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85067. * @param verticesStart defines the index of first vertex to draw
  85068. * @param verticesCount defines the count of vertices to draw
  85069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85070. */
  85071. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85072. /**
  85073. * Draw a list of indexed primitives
  85074. * @param fillMode defines the primitive to use
  85075. * @param indexStart defines the starting index
  85076. * @param indexCount defines the number of index to draw
  85077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85078. */
  85079. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85080. /**
  85081. * Draw a list of unindexed primitives
  85082. * @param fillMode defines the primitive to use
  85083. * @param verticesStart defines the index of first vertex to draw
  85084. * @param verticesCount defines the count of vertices to draw
  85085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85086. */
  85087. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85088. private _drawMode;
  85089. /** @hidden */
  85090. _releaseEffect(effect: Effect): void;
  85091. /** @hidden */
  85092. _deleteProgram(program: WebGLProgram): void;
  85093. /**
  85094. * Create a new effect (used to store vertex/fragment shaders)
  85095. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85096. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85097. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85098. * @param samplers defines an array of string used to represent textures
  85099. * @param defines defines the string containing the defines to use to compile the shaders
  85100. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85101. * @param onCompiled defines a function to call when the effect creation is successful
  85102. * @param onError defines a function to call when the effect creation has failed
  85103. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85104. * @returns the new Effect
  85105. */
  85106. 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;
  85107. private _compileShader;
  85108. private _compileRawShader;
  85109. /**
  85110. * Directly creates a webGL program
  85111. * @param vertexCode defines the vertex shader code to use
  85112. * @param fragmentCode defines the fragment shader code to use
  85113. * @param context defines the webGL context to use (if not set, the current one will be used)
  85114. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85115. * @returns the new webGL program
  85116. */
  85117. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85118. /**
  85119. * Creates a webGL program
  85120. * @param vertexCode defines the vertex shader code to use
  85121. * @param fragmentCode defines the fragment shader code to use
  85122. * @param defines defines the string containing the defines to use to compile the shaders
  85123. * @param context defines the webGL context to use (if not set, the current one will be used)
  85124. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85125. * @returns the new webGL program
  85126. */
  85127. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85128. private _createShaderProgram;
  85129. private _finalizeProgram;
  85130. /** @hidden */
  85131. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85132. /** @hidden */
  85133. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85134. /**
  85135. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85136. * @param shaderProgram defines the webGL program to use
  85137. * @param uniformsNames defines the list of uniform names
  85138. * @returns an array of webGL uniform locations
  85139. */
  85140. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85141. /**
  85142. * Gets the lsit of active attributes for a given webGL program
  85143. * @param shaderProgram defines the webGL program to use
  85144. * @param attributesNames defines the list of attribute names to get
  85145. * @returns an array of indices indicating the offset of each attribute
  85146. */
  85147. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85148. /**
  85149. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85150. * @param effect defines the effect to activate
  85151. */
  85152. enableEffect(effect: Nullable<Effect>): void;
  85153. /**
  85154. * Set the value of an uniform to an array of int32
  85155. * @param uniform defines the webGL uniform location where to store the value
  85156. * @param array defines the array of int32 to store
  85157. */
  85158. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85159. /**
  85160. * Set the value of an uniform to an array of int32 (stored as vec2)
  85161. * @param uniform defines the webGL uniform location where to store the value
  85162. * @param array defines the array of int32 to store
  85163. */
  85164. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85165. /**
  85166. * Set the value of an uniform to an array of int32 (stored as vec3)
  85167. * @param uniform defines the webGL uniform location where to store the value
  85168. * @param array defines the array of int32 to store
  85169. */
  85170. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85171. /**
  85172. * Set the value of an uniform to an array of int32 (stored as vec4)
  85173. * @param uniform defines the webGL uniform location where to store the value
  85174. * @param array defines the array of int32 to store
  85175. */
  85176. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85177. /**
  85178. * Set the value of an uniform to an array of float32
  85179. * @param uniform defines the webGL uniform location where to store the value
  85180. * @param array defines the array of float32 to store
  85181. */
  85182. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85183. /**
  85184. * Set the value of an uniform to an array of float32 (stored as vec2)
  85185. * @param uniform defines the webGL uniform location where to store the value
  85186. * @param array defines the array of float32 to store
  85187. */
  85188. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85189. /**
  85190. * Set the value of an uniform to an array of float32 (stored as vec3)
  85191. * @param uniform defines the webGL uniform location where to store the value
  85192. * @param array defines the array of float32 to store
  85193. */
  85194. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85195. /**
  85196. * Set the value of an uniform to an array of float32 (stored as vec4)
  85197. * @param uniform defines the webGL uniform location where to store the value
  85198. * @param array defines the array of float32 to store
  85199. */
  85200. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85201. /**
  85202. * Set the value of an uniform to an array of number
  85203. * @param uniform defines the webGL uniform location where to store the value
  85204. * @param array defines the array of number to store
  85205. */
  85206. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85207. /**
  85208. * Set the value of an uniform to an array of number (stored as vec2)
  85209. * @param uniform defines the webGL uniform location where to store the value
  85210. * @param array defines the array of number to store
  85211. */
  85212. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85213. /**
  85214. * Set the value of an uniform to an array of number (stored as vec3)
  85215. * @param uniform defines the webGL uniform location where to store the value
  85216. * @param array defines the array of number to store
  85217. */
  85218. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85219. /**
  85220. * Set the value of an uniform to an array of number (stored as vec4)
  85221. * @param uniform defines the webGL uniform location where to store the value
  85222. * @param array defines the array of number to store
  85223. */
  85224. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85225. /**
  85226. * Set the value of an uniform to an array of float32 (stored as matrices)
  85227. * @param uniform defines the webGL uniform location where to store the value
  85228. * @param matrices defines the array of float32 to store
  85229. */
  85230. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85231. /**
  85232. * Set the value of an uniform to a matrix
  85233. * @param uniform defines the webGL uniform location where to store the value
  85234. * @param matrix defines the matrix to store
  85235. */
  85236. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85237. /**
  85238. * Set the value of an uniform to a matrix (3x3)
  85239. * @param uniform defines the webGL uniform location where to store the value
  85240. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85241. */
  85242. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85243. /**
  85244. * Set the value of an uniform to a matrix (2x2)
  85245. * @param uniform defines the webGL uniform location where to store the value
  85246. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85247. */
  85248. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85249. /**
  85250. * Set the value of an uniform to a number (int)
  85251. * @param uniform defines the webGL uniform location where to store the value
  85252. * @param value defines the int number to store
  85253. */
  85254. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85255. /**
  85256. * Set the value of an uniform to a number (float)
  85257. * @param uniform defines the webGL uniform location where to store the value
  85258. * @param value defines the float number to store
  85259. */
  85260. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85261. /**
  85262. * Set the value of an uniform to a vec2
  85263. * @param uniform defines the webGL uniform location where to store the value
  85264. * @param x defines the 1st component of the value
  85265. * @param y defines the 2nd component of the value
  85266. */
  85267. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85268. /**
  85269. * Set the value of an uniform to a vec3
  85270. * @param uniform defines the webGL uniform location where to store the value
  85271. * @param x defines the 1st component of the value
  85272. * @param y defines the 2nd component of the value
  85273. * @param z defines the 3rd component of the value
  85274. */
  85275. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85276. /**
  85277. * Set the value of an uniform to a boolean
  85278. * @param uniform defines the webGL uniform location where to store the value
  85279. * @param bool defines the boolean to store
  85280. */
  85281. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85282. /**
  85283. * Set the value of an uniform to a vec4
  85284. * @param uniform defines the webGL uniform location where to store the value
  85285. * @param x defines the 1st component of the value
  85286. * @param y defines the 2nd component of the value
  85287. * @param z defines the 3rd component of the value
  85288. * @param w defines the 4th component of the value
  85289. */
  85290. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85291. /**
  85292. * Set the value of an uniform to a Color3
  85293. * @param uniform defines the webGL uniform location where to store the value
  85294. * @param color3 defines the color to store
  85295. */
  85296. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85297. /**
  85298. * Set the value of an uniform to a Color3 and an alpha value
  85299. * @param uniform defines the webGL uniform location where to store the value
  85300. * @param color3 defines the color to store
  85301. * @param alpha defines the alpha component to store
  85302. */
  85303. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85304. /**
  85305. * Sets a Color4 on a uniform variable
  85306. * @param uniform defines the uniform location
  85307. * @param color4 defines the value to be set
  85308. */
  85309. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85310. /**
  85311. * Set various states to the webGL context
  85312. * @param culling defines backface culling state
  85313. * @param zOffset defines the value to apply to zOffset (0 by default)
  85314. * @param force defines if states must be applied even if cache is up to date
  85315. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85316. */
  85317. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85318. /**
  85319. * Set the z offset to apply to current rendering
  85320. * @param value defines the offset to apply
  85321. */
  85322. setZOffset(value: number): void;
  85323. /**
  85324. * Gets the current value of the zOffset
  85325. * @returns the current zOffset state
  85326. */
  85327. getZOffset(): number;
  85328. /**
  85329. * Enable or disable depth buffering
  85330. * @param enable defines the state to set
  85331. */
  85332. setDepthBuffer(enable: boolean): void;
  85333. /**
  85334. * Gets a boolean indicating if depth writing is enabled
  85335. * @returns the current depth writing state
  85336. */
  85337. getDepthWrite(): boolean;
  85338. /**
  85339. * Enable or disable depth writing
  85340. * @param enable defines the state to set
  85341. */
  85342. setDepthWrite(enable: boolean): void;
  85343. /**
  85344. * Enable or disable color writing
  85345. * @param enable defines the state to set
  85346. */
  85347. setColorWrite(enable: boolean): void;
  85348. /**
  85349. * Gets a boolean indicating if color writing is enabled
  85350. * @returns the current color writing state
  85351. */
  85352. getColorWrite(): boolean;
  85353. /**
  85354. * Sets alpha constants used by some alpha blending modes
  85355. * @param r defines the red component
  85356. * @param g defines the green component
  85357. * @param b defines the blue component
  85358. * @param a defines the alpha component
  85359. */
  85360. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85361. /**
  85362. * Sets the current alpha mode
  85363. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85364. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85365. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85366. */
  85367. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85368. /**
  85369. * Gets the current alpha mode
  85370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85371. * @returns the current alpha mode
  85372. */
  85373. getAlphaMode(): number;
  85374. /**
  85375. * Clears the list of texture accessible through engine.
  85376. * This can help preventing texture load conflict due to name collision.
  85377. */
  85378. clearInternalTexturesCache(): void;
  85379. /**
  85380. * Force the entire cache to be cleared
  85381. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85382. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85383. */
  85384. wipeCaches(bruteForce?: boolean): void;
  85385. /**
  85386. * Set the compressed texture format to use, based on the formats you have, and the formats
  85387. * supported by the hardware / browser.
  85388. *
  85389. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85390. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85391. * to API arguments needed to compressed textures. This puts the burden on the container
  85392. * generator to house the arcane code for determining these for current & future formats.
  85393. *
  85394. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85395. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85396. *
  85397. * Note: The result of this call is not taken into account when a texture is base64.
  85398. *
  85399. * @param formatsAvailable defines the list of those format families you have created
  85400. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85401. *
  85402. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85403. * @returns The extension selected.
  85404. */
  85405. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85406. private _getSamplingParameters;
  85407. private _partialLoadImg;
  85408. private _cascadeLoadImgs;
  85409. /** @hidden */
  85410. _createTexture(): WebGLTexture;
  85411. /**
  85412. * Usually called from Texture.ts.
  85413. * Passed information to create a WebGLTexture
  85414. * @param urlArg defines a value which contains one of the following:
  85415. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85416. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85417. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85419. * @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)
  85420. * @param scene needed for loading to the correct scene
  85421. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85422. * @param onLoad optional callback to be called upon successful completion
  85423. * @param onError optional callback to be called upon failure
  85424. * @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
  85425. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85426. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85427. * @param forcedExtension defines the extension to use to pick the right loader
  85428. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85429. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85430. */
  85431. 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;
  85432. private _rescaleTexture;
  85433. /**
  85434. * Update a raw texture
  85435. * @param texture defines the texture to update
  85436. * @param data defines the data to store in the texture
  85437. * @param format defines the format of the data
  85438. * @param invertY defines if data must be stored with Y axis inverted
  85439. * @param compression defines the compression used (null by default)
  85440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85441. */
  85442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85443. /**
  85444. * Creates a raw texture
  85445. * @param data defines the data to store in the texture
  85446. * @param width defines the width of the texture
  85447. * @param height defines the height of the texture
  85448. * @param format defines the format of the data
  85449. * @param generateMipMaps defines if the engine should generate the mip levels
  85450. * @param invertY defines if data must be stored with Y axis inverted
  85451. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85452. * @param compression defines the compression used (null by default)
  85453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85454. * @returns the raw texture inside an InternalTexture
  85455. */
  85456. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85457. private _unpackFlipYCached;
  85458. /**
  85459. * In case you are sharing the context with other applications, it might
  85460. * be interested to not cache the unpack flip y state to ensure a consistent
  85461. * value would be set.
  85462. */
  85463. enableUnpackFlipYCached: boolean;
  85464. /** @hidden */
  85465. _unpackFlipY(value: boolean): void;
  85466. /** @hidden */
  85467. _getUnpackAlignement(): number;
  85468. /**
  85469. * Creates a dynamic texture
  85470. * @param width defines the width of the texture
  85471. * @param height defines the height of the texture
  85472. * @param generateMipMaps defines if the engine should generate the mip levels
  85473. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85474. * @returns the dynamic texture inside an InternalTexture
  85475. */
  85476. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85477. /**
  85478. * Update the sampling mode of a given texture
  85479. * @param samplingMode defines the required sampling mode
  85480. * @param texture defines the texture to update
  85481. */
  85482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85483. /**
  85484. * Update the content of a dynamic texture
  85485. * @param texture defines the texture to update
  85486. * @param canvas defines the canvas containing the source
  85487. * @param invertY defines if data must be stored with Y axis inverted
  85488. * @param premulAlpha defines if alpha is stored as premultiplied
  85489. * @param format defines the format of the data
  85490. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85491. */
  85492. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85493. /**
  85494. * Update a video texture
  85495. * @param texture defines the texture to update
  85496. * @param video defines the video element to use
  85497. * @param invertY defines if data must be stored with Y axis inverted
  85498. */
  85499. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85500. /**
  85501. * Updates a depth texture Comparison Mode and Function.
  85502. * If the comparison Function is equal to 0, the mode will be set to none.
  85503. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85504. * @param texture The texture to set the comparison function for
  85505. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85506. */
  85507. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85508. private _setupDepthStencilTexture;
  85509. /**
  85510. * Creates a depth stencil texture.
  85511. * This is only available in WebGL 2 or with the depth texture extension available.
  85512. * @param size The size of face edge in the texture.
  85513. * @param options The options defining the texture.
  85514. * @returns The texture
  85515. */
  85516. createDepthStencilTexture(size: number | {
  85517. width: number;
  85518. height: number;
  85519. }, options: DepthTextureCreationOptions): InternalTexture;
  85520. /**
  85521. * Creates a depth stencil texture.
  85522. * This is only available in WebGL 2 or with the depth texture extension available.
  85523. * @param size The size of face edge in the texture.
  85524. * @param options The options defining the texture.
  85525. * @returns The texture
  85526. */
  85527. private _createDepthStencilTexture;
  85528. /**
  85529. * Creates a depth stencil cube texture.
  85530. * This is only available in WebGL 2.
  85531. * @param size The size of face edge in the cube texture.
  85532. * @param options The options defining the cube texture.
  85533. * @returns The cube texture
  85534. */
  85535. private _createDepthStencilCubeTexture;
  85536. /**
  85537. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85538. * @param renderTarget The render target to set the frame buffer for
  85539. */
  85540. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85541. /**
  85542. * Creates a new render target texture
  85543. * @param size defines the size of the texture
  85544. * @param options defines the options used to create the texture
  85545. * @returns a new render target texture stored in an InternalTexture
  85546. */
  85547. createRenderTargetTexture(size: number | {
  85548. width: number;
  85549. height: number;
  85550. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85551. /**
  85552. * Create a multi render target texture
  85553. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85554. * @param size defines the size of the texture
  85555. * @param options defines the creation options
  85556. * @returns the cube texture as an InternalTexture
  85557. */
  85558. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85559. private _setupFramebufferDepthAttachments;
  85560. /**
  85561. * Updates the sample count of a render target texture
  85562. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85563. * @param texture defines the texture to update
  85564. * @param samples defines the sample count to set
  85565. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85566. */
  85567. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85568. /**
  85569. * Update the sample count for a given multiple render target texture
  85570. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85571. * @param textures defines the textures to update
  85572. * @param samples defines the sample count to set
  85573. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85574. */
  85575. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85576. /** @hidden */
  85577. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85578. /** @hidden */
  85579. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85580. /** @hidden */
  85581. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85582. /** @hidden */
  85583. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85584. /**
  85585. * Creates a new render target cube texture
  85586. * @param size defines the size of the texture
  85587. * @param options defines the options used to create the texture
  85588. * @returns a new render target cube texture stored in an InternalTexture
  85589. */
  85590. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85591. /**
  85592. * Creates a cube texture
  85593. * @param rootUrl defines the url where the files to load is located
  85594. * @param scene defines the current scene
  85595. * @param files defines the list of files to load (1 per face)
  85596. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85597. * @param onLoad defines an optional callback raised when the texture is loaded
  85598. * @param onError defines an optional callback raised if there is an issue to load the texture
  85599. * @param format defines the format of the data
  85600. * @param forcedExtension defines the extension to use to pick the right loader
  85601. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85602. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85603. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85604. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85605. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85606. * @returns the cube texture as an InternalTexture
  85607. */
  85608. 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;
  85609. /**
  85610. * @hidden
  85611. */
  85612. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85613. /**
  85614. * Update a raw cube texture
  85615. * @param texture defines the texture to udpdate
  85616. * @param data defines the data to store
  85617. * @param format defines the data format
  85618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85619. * @param invertY defines if data must be stored with Y axis inverted
  85620. * @param compression defines the compression used (null by default)
  85621. * @param level defines which level of the texture to update
  85622. */
  85623. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85624. /**
  85625. * Creates a new raw cube texture
  85626. * @param data defines the array of data to use to create each face
  85627. * @param size defines the size of the textures
  85628. * @param format defines the format of the data
  85629. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85630. * @param generateMipMaps defines if the engine should generate the mip levels
  85631. * @param invertY defines if data must be stored with Y axis inverted
  85632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85633. * @param compression defines the compression used (null by default)
  85634. * @returns the cube texture as an InternalTexture
  85635. */
  85636. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85637. /**
  85638. * Creates a new raw cube texture from a specified url
  85639. * @param url defines the url where the data is located
  85640. * @param scene defines the current scene
  85641. * @param size defines the size of the textures
  85642. * @param format defines the format of the data
  85643. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85644. * @param noMipmap defines if the engine should avoid generating the mip levels
  85645. * @param callback defines a callback used to extract texture data from loaded data
  85646. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85647. * @param onLoad defines a callback called when texture is loaded
  85648. * @param onError defines a callback called if there is an error
  85649. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85650. * @param invertY defines if data must be stored with Y axis inverted
  85651. * @returns the cube texture as an InternalTexture
  85652. */
  85653. 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;
  85654. /**
  85655. * Update a raw 3D texture
  85656. * @param texture defines the texture to update
  85657. * @param data defines the data to store
  85658. * @param format defines the data format
  85659. * @param invertY defines if data must be stored with Y axis inverted
  85660. * @param compression defines the used compression (can be null)
  85661. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85662. */
  85663. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85664. /**
  85665. * Creates a new raw 3D texture
  85666. * @param data defines the data used to create the texture
  85667. * @param width defines the width of the texture
  85668. * @param height defines the height of the texture
  85669. * @param depth defines the depth of the texture
  85670. * @param format defines the format of the texture
  85671. * @param generateMipMaps defines if the engine must generate mip levels
  85672. * @param invertY defines if data must be stored with Y axis inverted
  85673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85674. * @param compression defines the compressed used (can be null)
  85675. * @param textureType defines the compressed used (can be null)
  85676. * @returns a new raw 3D texture (stored in an InternalTexture)
  85677. */
  85678. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85679. private _prepareWebGLTextureContinuation;
  85680. private _prepareWebGLTexture;
  85681. private _convertRGBtoRGBATextureData;
  85682. /** @hidden */
  85683. _releaseFramebufferObjects(texture: InternalTexture): void;
  85684. /** @hidden */
  85685. _releaseTexture(texture: InternalTexture): void;
  85686. private setProgram;
  85687. private _boundUniforms;
  85688. /**
  85689. * Binds an effect to the webGL context
  85690. * @param effect defines the effect to bind
  85691. */
  85692. bindSamplers(effect: Effect): void;
  85693. private _moveBoundTextureOnTop;
  85694. private _getCorrectTextureChannel;
  85695. private _linkTrackers;
  85696. private _removeDesignatedSlot;
  85697. private _activateCurrentTexture;
  85698. /** @hidden */
  85699. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85700. /** @hidden */
  85701. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85702. /**
  85703. * Sets a texture to the webGL context from a postprocess
  85704. * @param channel defines the channel to use
  85705. * @param postProcess defines the source postprocess
  85706. */
  85707. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85708. /**
  85709. * Binds the output of the passed in post process to the texture channel specified
  85710. * @param channel The channel the texture should be bound to
  85711. * @param postProcess The post process which's output should be bound
  85712. */
  85713. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85714. /**
  85715. * Unbind all textures from the webGL context
  85716. */
  85717. unbindAllTextures(): void;
  85718. /**
  85719. * Sets a texture to the according uniform.
  85720. * @param channel The texture channel
  85721. * @param uniform The uniform to set
  85722. * @param texture The texture to apply
  85723. */
  85724. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85725. /**
  85726. * Sets a depth stencil texture from a render target to the according uniform.
  85727. * @param channel The texture channel
  85728. * @param uniform The uniform to set
  85729. * @param texture The render target texture containing the depth stencil texture to apply
  85730. */
  85731. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85732. private _bindSamplerUniformToChannel;
  85733. private _getTextureWrapMode;
  85734. private _setTexture;
  85735. /**
  85736. * Sets an array of texture to the webGL context
  85737. * @param channel defines the channel where the texture array must be set
  85738. * @param uniform defines the associated uniform location
  85739. * @param textures defines the array of textures to bind
  85740. */
  85741. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85742. /** @hidden */
  85743. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85744. private _setTextureParameterFloat;
  85745. private _setTextureParameterInteger;
  85746. /**
  85747. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85748. * @param x defines the x coordinate of the rectangle where pixels must be read
  85749. * @param y defines the y coordinate of the rectangle where pixels must be read
  85750. * @param width defines the width of the rectangle where pixels must be read
  85751. * @param height defines the height of the rectangle where pixels must be read
  85752. * @returns a Uint8Array containing RGBA colors
  85753. */
  85754. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85755. /**
  85756. * Add an externaly attached data from its key.
  85757. * This method call will fail and return false, if such key already exists.
  85758. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85759. * @param key the unique key that identifies the data
  85760. * @param data the data object to associate to the key for this Engine instance
  85761. * @return true if no such key were already present and the data was added successfully, false otherwise
  85762. */
  85763. addExternalData<T>(key: string, data: T): boolean;
  85764. /**
  85765. * Get an externaly attached data from its key
  85766. * @param key the unique key that identifies the data
  85767. * @return the associated data, if present (can be null), or undefined if not present
  85768. */
  85769. getExternalData<T>(key: string): T;
  85770. /**
  85771. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85772. * @param key the unique key that identifies the data
  85773. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85774. * @return the associated data, can be null if the factory returned null.
  85775. */
  85776. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85777. /**
  85778. * Remove an externaly attached data from the Engine instance
  85779. * @param key the unique key that identifies the data
  85780. * @return true if the data was successfully removed, false if it doesn't exist
  85781. */
  85782. removeExternalData(key: string): boolean;
  85783. /**
  85784. * Unbind all vertex attributes from the webGL context
  85785. */
  85786. unbindAllAttributes(): void;
  85787. /**
  85788. * 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
  85789. */
  85790. releaseEffects(): void;
  85791. /**
  85792. * Dispose and release all associated resources
  85793. */
  85794. dispose(): void;
  85795. /**
  85796. * Display the loading screen
  85797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85798. */
  85799. displayLoadingUI(): void;
  85800. /**
  85801. * Hide the loading screen
  85802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85803. */
  85804. hideLoadingUI(): void;
  85805. /**
  85806. * Gets the current loading screen object
  85807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85808. */
  85809. /**
  85810. * Sets the current loading screen object
  85811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85812. */
  85813. loadingScreen: ILoadingScreen;
  85814. /**
  85815. * Sets the current loading screen text
  85816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85817. */
  85818. loadingUIText: string;
  85819. /**
  85820. * Sets the current loading screen background color
  85821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85822. */
  85823. loadingUIBackgroundColor: string;
  85824. /**
  85825. * Attach a new callback raised when context lost event is fired
  85826. * @param callback defines the callback to call
  85827. */
  85828. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85829. /**
  85830. * Attach a new callback raised when context restored event is fired
  85831. * @param callback defines the callback to call
  85832. */
  85833. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85834. /**
  85835. * Gets the source code of the vertex shader associated with a specific webGL program
  85836. * @param program defines the program to use
  85837. * @returns a string containing the source code of the vertex shader associated with the program
  85838. */
  85839. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85840. /**
  85841. * Gets the source code of the fragment shader associated with a specific webGL program
  85842. * @param program defines the program to use
  85843. * @returns a string containing the source code of the fragment shader associated with the program
  85844. */
  85845. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85846. /**
  85847. * Get the current error code of the webGL context
  85848. * @returns the error code
  85849. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85850. */
  85851. getError(): number;
  85852. /**
  85853. * Gets the current framerate
  85854. * @returns a number representing the framerate
  85855. */
  85856. getFps(): number;
  85857. /**
  85858. * Gets the time spent between current and previous frame
  85859. * @returns a number representing the delta time in ms
  85860. */
  85861. getDeltaTime(): number;
  85862. private _measureFps;
  85863. /** @hidden */
  85864. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85865. private _canRenderToFloatFramebuffer;
  85866. private _canRenderToHalfFloatFramebuffer;
  85867. private _canRenderToFramebuffer;
  85868. /** @hidden */
  85869. _getWebGLTextureType(type: number): number;
  85870. private _getInternalFormat;
  85871. /** @hidden */
  85872. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85873. /** @hidden */
  85874. _getRGBAMultiSampleBufferFormat(type: number): number;
  85875. /** @hidden */
  85876. _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;
  85877. /** @hidden */
  85878. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85879. private _partialLoadFile;
  85880. private _cascadeLoadFiles;
  85881. /**
  85882. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85883. * @returns true if the engine can be created
  85884. * @ignorenaming
  85885. */
  85886. static isSupported(): boolean;
  85887. }
  85888. }
  85889. declare module BABYLON {
  85890. /**
  85891. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85892. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85893. */
  85894. export class EffectFallbacks {
  85895. private _defines;
  85896. private _currentRank;
  85897. private _maxRank;
  85898. private _mesh;
  85899. /**
  85900. * Removes the fallback from the bound mesh.
  85901. */
  85902. unBindMesh(): void;
  85903. /**
  85904. * Adds a fallback on the specified property.
  85905. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85906. * @param define The name of the define in the shader
  85907. */
  85908. addFallback(rank: number, define: string): void;
  85909. /**
  85910. * Sets the mesh to use CPU skinning when needing to fallback.
  85911. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85912. * @param mesh The mesh to use the fallbacks.
  85913. */
  85914. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85915. /**
  85916. * Checks to see if more fallbacks are still availible.
  85917. */
  85918. readonly isMoreFallbacks: boolean;
  85919. /**
  85920. * Removes the defines that shoould be removed when falling back.
  85921. * @param currentDefines defines the current define statements for the shader.
  85922. * @param effect defines the current effect we try to compile
  85923. * @returns The resulting defines with defines of the current rank removed.
  85924. */
  85925. reduce(currentDefines: string, effect: Effect): string;
  85926. }
  85927. /**
  85928. * Options to be used when creating an effect.
  85929. */
  85930. export class EffectCreationOptions {
  85931. /**
  85932. * Atrributes that will be used in the shader.
  85933. */
  85934. attributes: string[];
  85935. /**
  85936. * Uniform varible names that will be set in the shader.
  85937. */
  85938. uniformsNames: string[];
  85939. /**
  85940. * Uniform buffer varible names that will be set in the shader.
  85941. */
  85942. uniformBuffersNames: string[];
  85943. /**
  85944. * Sampler texture variable names that will be set in the shader.
  85945. */
  85946. samplers: string[];
  85947. /**
  85948. * Define statements that will be set in the shader.
  85949. */
  85950. defines: any;
  85951. /**
  85952. * Possible fallbacks for this effect to improve performance when needed.
  85953. */
  85954. fallbacks: Nullable<EffectFallbacks>;
  85955. /**
  85956. * Callback that will be called when the shader is compiled.
  85957. */
  85958. onCompiled: Nullable<(effect: Effect) => void>;
  85959. /**
  85960. * Callback that will be called if an error occurs during shader compilation.
  85961. */
  85962. onError: Nullable<(effect: Effect, errors: string) => void>;
  85963. /**
  85964. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85965. */
  85966. indexParameters: any;
  85967. /**
  85968. * Max number of lights that can be used in the shader.
  85969. */
  85970. maxSimultaneousLights: number;
  85971. /**
  85972. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85973. */
  85974. transformFeedbackVaryings: Nullable<string[]>;
  85975. }
  85976. /**
  85977. * Effect containing vertex and fragment shader that can be executed on an object.
  85978. */
  85979. export class Effect {
  85980. /**
  85981. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85982. */
  85983. static ShadersRepository: string;
  85984. /**
  85985. * Name of the effect.
  85986. */
  85987. name: any;
  85988. /**
  85989. * String container all the define statements that should be set on the shader.
  85990. */
  85991. defines: string;
  85992. /**
  85993. * Callback that will be called when the shader is compiled.
  85994. */
  85995. onCompiled: Nullable<(effect: Effect) => void>;
  85996. /**
  85997. * Callback that will be called if an error occurs during shader compilation.
  85998. */
  85999. onError: Nullable<(effect: Effect, errors: string) => void>;
  86000. /**
  86001. * Callback that will be called when effect is bound.
  86002. */
  86003. onBind: Nullable<(effect: Effect) => void>;
  86004. /**
  86005. * Unique ID of the effect.
  86006. */
  86007. uniqueId: number;
  86008. /**
  86009. * Observable that will be called when the shader is compiled.
  86010. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  86011. */
  86012. onCompileObservable: Observable<Effect>;
  86013. /**
  86014. * Observable that will be called if an error occurs during shader compilation.
  86015. */
  86016. onErrorObservable: Observable<Effect>;
  86017. /** @hidden */
  86018. _onBindObservable: Nullable<Observable<Effect>>;
  86019. /**
  86020. * Observable that will be called when effect is bound.
  86021. */
  86022. readonly onBindObservable: Observable<Effect>;
  86023. /** @hidden */
  86024. _bonesComputationForcedToCPU: boolean;
  86025. private static _uniqueIdSeed;
  86026. private _engine;
  86027. private _uniformBuffersNames;
  86028. private _uniformsNames;
  86029. private _samplers;
  86030. private _isReady;
  86031. private _compilationError;
  86032. private _attributesNames;
  86033. private _attributes;
  86034. private _uniforms;
  86035. /**
  86036. * Key for the effect.
  86037. * @hidden
  86038. */
  86039. _key: string;
  86040. private _indexParameters;
  86041. private _fallbacks;
  86042. private _vertexSourceCode;
  86043. private _fragmentSourceCode;
  86044. private _vertexSourceCodeOverride;
  86045. private _fragmentSourceCodeOverride;
  86046. private _transformFeedbackVaryings;
  86047. /**
  86048. * Compiled shader to webGL program.
  86049. * @hidden
  86050. */
  86051. _program: WebGLProgram;
  86052. private _valueCache;
  86053. private static _baseCache;
  86054. /**
  86055. * Instantiates an effect.
  86056. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86057. * @param baseName Name of the effect.
  86058. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86059. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86060. * @param samplers List of sampler variables that will be passed to the shader.
  86061. * @param engine Engine to be used to render the effect
  86062. * @param defines Define statements to be added to the shader.
  86063. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86064. * @param onCompiled Callback that will be called when the shader is compiled.
  86065. * @param onError Callback that will be called if an error occurs during shader compilation.
  86066. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86067. */
  86068. 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);
  86069. /**
  86070. * Unique key for this effect
  86071. */
  86072. readonly key: string;
  86073. /**
  86074. * If the effect has been compiled and prepared.
  86075. * @returns if the effect is compiled and prepared.
  86076. */
  86077. isReady(): boolean;
  86078. /**
  86079. * The engine the effect was initialized with.
  86080. * @returns the engine.
  86081. */
  86082. getEngine(): Engine;
  86083. /**
  86084. * The compiled webGL program for the effect
  86085. * @returns the webGL program.
  86086. */
  86087. getProgram(): WebGLProgram;
  86088. /**
  86089. * The set of names of attribute variables for the shader.
  86090. * @returns An array of attribute names.
  86091. */
  86092. getAttributesNames(): string[];
  86093. /**
  86094. * Returns the attribute at the given index.
  86095. * @param index The index of the attribute.
  86096. * @returns The location of the attribute.
  86097. */
  86098. getAttributeLocation(index: number): number;
  86099. /**
  86100. * Returns the attribute based on the name of the variable.
  86101. * @param name of the attribute to look up.
  86102. * @returns the attribute location.
  86103. */
  86104. getAttributeLocationByName(name: string): number;
  86105. /**
  86106. * The number of attributes.
  86107. * @returns the numnber of attributes.
  86108. */
  86109. getAttributesCount(): number;
  86110. /**
  86111. * Gets the index of a uniform variable.
  86112. * @param uniformName of the uniform to look up.
  86113. * @returns the index.
  86114. */
  86115. getUniformIndex(uniformName: string): number;
  86116. /**
  86117. * Returns the attribute based on the name of the variable.
  86118. * @param uniformName of the uniform to look up.
  86119. * @returns the location of the uniform.
  86120. */
  86121. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86122. /**
  86123. * Returns an array of sampler variable names
  86124. * @returns The array of sampler variable neames.
  86125. */
  86126. getSamplers(): string[];
  86127. /**
  86128. * The error from the last compilation.
  86129. * @returns the error string.
  86130. */
  86131. getCompilationError(): string;
  86132. /**
  86133. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86134. * @param func The callback to be used.
  86135. */
  86136. executeWhenCompiled(func: (effect: Effect) => void): void;
  86137. private _checkIsReady;
  86138. /** @hidden */
  86139. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86140. /** @hidden */
  86141. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86142. /** @hidden */
  86143. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86144. private _processShaderConversion;
  86145. private _processIncludes;
  86146. private _processPrecision;
  86147. /**
  86148. * Recompiles the webGL program
  86149. * @param vertexSourceCode The source code for the vertex shader.
  86150. * @param fragmentSourceCode The source code for the fragment shader.
  86151. * @param onCompiled Callback called when completed.
  86152. * @param onError Callback called on error.
  86153. * @hidden
  86154. */
  86155. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86156. /**
  86157. * Gets the uniform locations of the the specified variable names
  86158. * @param names THe names of the variables to lookup.
  86159. * @returns Array of locations in the same order as variable names.
  86160. */
  86161. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86162. /**
  86163. * Prepares the effect
  86164. * @hidden
  86165. */
  86166. _prepareEffect(): void;
  86167. /**
  86168. * Checks if the effect is supported. (Must be called after compilation)
  86169. */
  86170. readonly isSupported: boolean;
  86171. /**
  86172. * Binds a texture to the engine to be used as output of the shader.
  86173. * @param channel Name of the output variable.
  86174. * @param texture Texture to bind.
  86175. * @hidden
  86176. */
  86177. _bindTexture(channel: string, texture: InternalTexture): void;
  86178. /**
  86179. * Sets a texture on the engine to be used in the shader.
  86180. * @param channel Name of the sampler variable.
  86181. * @param texture Texture to set.
  86182. */
  86183. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86184. /**
  86185. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86186. * @param channel Name of the sampler variable.
  86187. * @param texture Texture to set.
  86188. */
  86189. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86190. /**
  86191. * Sets an array of textures on the engine to be used in the shader.
  86192. * @param channel Name of the variable.
  86193. * @param textures Textures to set.
  86194. */
  86195. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86196. /**
  86197. * 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)
  86198. * @param channel Name of the sampler variable.
  86199. * @param postProcess Post process to get the input texture from.
  86200. */
  86201. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86202. /**
  86203. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86204. * 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)
  86205. * @param channel Name of the sampler variable.
  86206. * @param postProcess Post process to get the output texture from.
  86207. */
  86208. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86209. /** @hidden */
  86210. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86211. /** @hidden */
  86212. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86213. /** @hidden */
  86214. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86215. /** @hidden */
  86216. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86217. /**
  86218. * Binds a buffer to a uniform.
  86219. * @param buffer Buffer to bind.
  86220. * @param name Name of the uniform variable to bind to.
  86221. */
  86222. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86223. /**
  86224. * Binds block to a uniform.
  86225. * @param blockName Name of the block to bind.
  86226. * @param index Index to bind.
  86227. */
  86228. bindUniformBlock(blockName: string, index: number): void;
  86229. /**
  86230. * Sets an interger value on a uniform variable.
  86231. * @param uniformName Name of the variable.
  86232. * @param value Value to be set.
  86233. * @returns this effect.
  86234. */
  86235. setInt(uniformName: string, value: number): Effect;
  86236. /**
  86237. * Sets an int array on a uniform variable.
  86238. * @param uniformName Name of the variable.
  86239. * @param array array to be set.
  86240. * @returns this effect.
  86241. */
  86242. setIntArray(uniformName: string, array: Int32Array): Effect;
  86243. /**
  86244. * 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)
  86245. * @param uniformName Name of the variable.
  86246. * @param array array to be set.
  86247. * @returns this effect.
  86248. */
  86249. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86250. /**
  86251. * 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)
  86252. * @param uniformName Name of the variable.
  86253. * @param array array to be set.
  86254. * @returns this effect.
  86255. */
  86256. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86257. /**
  86258. * 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)
  86259. * @param uniformName Name of the variable.
  86260. * @param array array to be set.
  86261. * @returns this effect.
  86262. */
  86263. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86264. /**
  86265. * Sets an float array on a uniform variable.
  86266. * @param uniformName Name of the variable.
  86267. * @param array array to be set.
  86268. * @returns this effect.
  86269. */
  86270. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86271. /**
  86272. * 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)
  86273. * @param uniformName Name of the variable.
  86274. * @param array array to be set.
  86275. * @returns this effect.
  86276. */
  86277. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86278. /**
  86279. * 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)
  86280. * @param uniformName Name of the variable.
  86281. * @param array array to be set.
  86282. * @returns this effect.
  86283. */
  86284. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86285. /**
  86286. * 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)
  86287. * @param uniformName Name of the variable.
  86288. * @param array array to be set.
  86289. * @returns this effect.
  86290. */
  86291. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86292. /**
  86293. * Sets an array on a uniform variable.
  86294. * @param uniformName Name of the variable.
  86295. * @param array array to be set.
  86296. * @returns this effect.
  86297. */
  86298. setArray(uniformName: string, array: number[]): Effect;
  86299. /**
  86300. * 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)
  86301. * @param uniformName Name of the variable.
  86302. * @param array array to be set.
  86303. * @returns this effect.
  86304. */
  86305. setArray2(uniformName: string, array: number[]): Effect;
  86306. /**
  86307. * 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)
  86308. * @param uniformName Name of the variable.
  86309. * @param array array to be set.
  86310. * @returns this effect.
  86311. */
  86312. setArray3(uniformName: string, array: number[]): Effect;
  86313. /**
  86314. * 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)
  86315. * @param uniformName Name of the variable.
  86316. * @param array array to be set.
  86317. * @returns this effect.
  86318. */
  86319. setArray4(uniformName: string, array: number[]): Effect;
  86320. /**
  86321. * Sets matrices on a uniform variable.
  86322. * @param uniformName Name of the variable.
  86323. * @param matrices matrices to be set.
  86324. * @returns this effect.
  86325. */
  86326. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86327. /**
  86328. * Sets matrix on a uniform variable.
  86329. * @param uniformName Name of the variable.
  86330. * @param matrix matrix to be set.
  86331. * @returns this effect.
  86332. */
  86333. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86334. /**
  86335. * 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)
  86336. * @param uniformName Name of the variable.
  86337. * @param matrix matrix to be set.
  86338. * @returns this effect.
  86339. */
  86340. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86341. /**
  86342. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86343. * @param uniformName Name of the variable.
  86344. * @param matrix matrix to be set.
  86345. * @returns this effect.
  86346. */
  86347. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86348. /**
  86349. * Sets a float on a uniform variable.
  86350. * @param uniformName Name of the variable.
  86351. * @param value value to be set.
  86352. * @returns this effect.
  86353. */
  86354. setFloat(uniformName: string, value: number): Effect;
  86355. /**
  86356. * Sets a boolean on a uniform variable.
  86357. * @param uniformName Name of the variable.
  86358. * @param bool value to be set.
  86359. * @returns this effect.
  86360. */
  86361. setBool(uniformName: string, bool: boolean): Effect;
  86362. /**
  86363. * Sets a Vector2 on a uniform variable.
  86364. * @param uniformName Name of the variable.
  86365. * @param vector2 vector2 to be set.
  86366. * @returns this effect.
  86367. */
  86368. setVector2(uniformName: string, vector2: Vector2): Effect;
  86369. /**
  86370. * Sets a float2 on a uniform variable.
  86371. * @param uniformName Name of the variable.
  86372. * @param x First float in float2.
  86373. * @param y Second float in float2.
  86374. * @returns this effect.
  86375. */
  86376. setFloat2(uniformName: string, x: number, y: number): Effect;
  86377. /**
  86378. * Sets a Vector3 on a uniform variable.
  86379. * @param uniformName Name of the variable.
  86380. * @param vector3 Value to be set.
  86381. * @returns this effect.
  86382. */
  86383. setVector3(uniformName: string, vector3: Vector3): Effect;
  86384. /**
  86385. * Sets a float3 on a uniform variable.
  86386. * @param uniformName Name of the variable.
  86387. * @param x First float in float3.
  86388. * @param y Second float in float3.
  86389. * @param z Third float in float3.
  86390. * @returns this effect.
  86391. */
  86392. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86393. /**
  86394. * Sets a Vector4 on a uniform variable.
  86395. * @param uniformName Name of the variable.
  86396. * @param vector4 Value to be set.
  86397. * @returns this effect.
  86398. */
  86399. setVector4(uniformName: string, vector4: Vector4): Effect;
  86400. /**
  86401. * Sets a float4 on a uniform variable.
  86402. * @param uniformName Name of the variable.
  86403. * @param x First float in float4.
  86404. * @param y Second float in float4.
  86405. * @param z Third float in float4.
  86406. * @param w Fourth float in float4.
  86407. * @returns this effect.
  86408. */
  86409. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86410. /**
  86411. * Sets a Color3 on a uniform variable.
  86412. * @param uniformName Name of the variable.
  86413. * @param color3 Value to be set.
  86414. * @returns this effect.
  86415. */
  86416. setColor3(uniformName: string, color3: Color3): Effect;
  86417. /**
  86418. * Sets a Color4 on a uniform variable.
  86419. * @param uniformName Name of the variable.
  86420. * @param color3 Value to be set.
  86421. * @param alpha Alpha value to be set.
  86422. * @returns this effect.
  86423. */
  86424. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86425. /**
  86426. * Sets a Color4 on a uniform variable
  86427. * @param uniformName defines the name of the variable
  86428. * @param color4 defines the value to be set
  86429. * @returns this effect.
  86430. */
  86431. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86432. /**
  86433. * This function will add a new shader to the shader store
  86434. * @param name the name of the shader
  86435. * @param pixelShader optional pixel shader content
  86436. * @param vertexShader optional vertex shader content
  86437. */
  86438. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86439. /**
  86440. * Store of each shader (The can be looked up using effect.key)
  86441. */
  86442. static ShadersStore: {
  86443. [key: string]: string;
  86444. };
  86445. /**
  86446. * Store of each included file for a shader (The can be looked up using effect.key)
  86447. */
  86448. static IncludesShadersStore: {
  86449. [key: string]: string;
  86450. };
  86451. /**
  86452. * Resets the cache of effects.
  86453. */
  86454. static ResetCache(): void;
  86455. }
  86456. }
  86457. declare module BABYLON {
  86458. /**
  86459. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86460. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86461. * 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;
  86462. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86463. */
  86464. export class ColorCurves {
  86465. private _dirty;
  86466. private _tempColor;
  86467. private _globalCurve;
  86468. private _highlightsCurve;
  86469. private _midtonesCurve;
  86470. private _shadowsCurve;
  86471. private _positiveCurve;
  86472. private _negativeCurve;
  86473. private _globalHue;
  86474. private _globalDensity;
  86475. private _globalSaturation;
  86476. private _globalExposure;
  86477. /**
  86478. * Gets the global Hue value.
  86479. * 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).
  86480. */
  86481. /**
  86482. * Sets the global Hue value.
  86483. * 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).
  86484. */
  86485. globalHue: number;
  86486. /**
  86487. * Gets the global Density value.
  86488. * 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.
  86489. * Values less than zero provide a filter of opposite hue.
  86490. */
  86491. /**
  86492. * Sets the global Density value.
  86493. * 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.
  86494. * Values less than zero provide a filter of opposite hue.
  86495. */
  86496. globalDensity: number;
  86497. /**
  86498. * Gets the global Saturation value.
  86499. * 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.
  86500. */
  86501. /**
  86502. * Sets the global Saturation value.
  86503. * 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.
  86504. */
  86505. globalSaturation: number;
  86506. /**
  86507. * Gets the global Exposure value.
  86508. * 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.
  86509. */
  86510. /**
  86511. * Sets the global Exposure value.
  86512. * 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.
  86513. */
  86514. globalExposure: number;
  86515. private _highlightsHue;
  86516. private _highlightsDensity;
  86517. private _highlightsSaturation;
  86518. private _highlightsExposure;
  86519. /**
  86520. * Gets the highlights Hue value.
  86521. * 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).
  86522. */
  86523. /**
  86524. * Sets the highlights Hue value.
  86525. * 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).
  86526. */
  86527. highlightsHue: number;
  86528. /**
  86529. * Gets the highlights Density value.
  86530. * 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.
  86531. * Values less than zero provide a filter of opposite hue.
  86532. */
  86533. /**
  86534. * Sets the highlights Density value.
  86535. * 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.
  86536. * Values less than zero provide a filter of opposite hue.
  86537. */
  86538. highlightsDensity: number;
  86539. /**
  86540. * Gets the highlights Saturation value.
  86541. * 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.
  86542. */
  86543. /**
  86544. * Sets the highlights Saturation value.
  86545. * 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.
  86546. */
  86547. highlightsSaturation: number;
  86548. /**
  86549. * Gets the highlights Exposure value.
  86550. * 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.
  86551. */
  86552. /**
  86553. * Sets the highlights Exposure value.
  86554. * 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.
  86555. */
  86556. highlightsExposure: number;
  86557. private _midtonesHue;
  86558. private _midtonesDensity;
  86559. private _midtonesSaturation;
  86560. private _midtonesExposure;
  86561. /**
  86562. * Gets the midtones Hue value.
  86563. * 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).
  86564. */
  86565. /**
  86566. * Sets the midtones Hue value.
  86567. * 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).
  86568. */
  86569. midtonesHue: number;
  86570. /**
  86571. * Gets the midtones Density value.
  86572. * 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.
  86573. * Values less than zero provide a filter of opposite hue.
  86574. */
  86575. /**
  86576. * Sets the midtones Density value.
  86577. * 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.
  86578. * Values less than zero provide a filter of opposite hue.
  86579. */
  86580. midtonesDensity: number;
  86581. /**
  86582. * Gets the midtones Saturation value.
  86583. * 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.
  86584. */
  86585. /**
  86586. * Sets the midtones Saturation value.
  86587. * 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.
  86588. */
  86589. midtonesSaturation: number;
  86590. /**
  86591. * Gets the midtones Exposure value.
  86592. * 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.
  86593. */
  86594. /**
  86595. * Sets the midtones Exposure value.
  86596. * 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.
  86597. */
  86598. midtonesExposure: number;
  86599. private _shadowsHue;
  86600. private _shadowsDensity;
  86601. private _shadowsSaturation;
  86602. private _shadowsExposure;
  86603. /**
  86604. * Gets the shadows Hue value.
  86605. * 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).
  86606. */
  86607. /**
  86608. * Sets the shadows Hue value.
  86609. * 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).
  86610. */
  86611. shadowsHue: number;
  86612. /**
  86613. * Gets the shadows Density value.
  86614. * 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.
  86615. * Values less than zero provide a filter of opposite hue.
  86616. */
  86617. /**
  86618. * Sets the shadows Density value.
  86619. * 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.
  86620. * Values less than zero provide a filter of opposite hue.
  86621. */
  86622. shadowsDensity: number;
  86623. /**
  86624. * Gets the shadows Saturation value.
  86625. * 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.
  86626. */
  86627. /**
  86628. * Sets the shadows Saturation value.
  86629. * 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.
  86630. */
  86631. shadowsSaturation: number;
  86632. /**
  86633. * Gets the shadows Exposure value.
  86634. * 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.
  86635. */
  86636. /**
  86637. * Sets the shadows Exposure value.
  86638. * 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.
  86639. */
  86640. shadowsExposure: number;
  86641. /**
  86642. * Returns the class name
  86643. * @returns The class name
  86644. */
  86645. getClassName(): string;
  86646. /**
  86647. * Binds the color curves to the shader.
  86648. * @param colorCurves The color curve to bind
  86649. * @param effect The effect to bind to
  86650. * @param positiveUniform The positive uniform shader parameter
  86651. * @param neutralUniform The neutral uniform shader parameter
  86652. * @param negativeUniform The negative uniform shader parameter
  86653. */
  86654. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86655. /**
  86656. * Prepare the list of uniforms associated with the ColorCurves effects.
  86657. * @param uniformsList The list of uniforms used in the effect
  86658. */
  86659. static PrepareUniforms(uniformsList: string[]): void;
  86660. /**
  86661. * Returns color grading data based on a hue, density, saturation and exposure value.
  86662. * @param filterHue The hue of the color filter.
  86663. * @param filterDensity The density of the color filter.
  86664. * @param saturation The saturation.
  86665. * @param exposure The exposure.
  86666. * @param result The result data container.
  86667. */
  86668. private getColorGradingDataToRef;
  86669. /**
  86670. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86671. * @param value The input slider value in range [-100,100].
  86672. * @returns Adjusted value.
  86673. */
  86674. private static applyColorGradingSliderNonlinear;
  86675. /**
  86676. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86677. * @param hue The hue (H) input.
  86678. * @param saturation The saturation (S) input.
  86679. * @param brightness The brightness (B) input.
  86680. * @result An RGBA color represented as Vector4.
  86681. */
  86682. private static fromHSBToRef;
  86683. /**
  86684. * Returns a value clamped between min and max
  86685. * @param value The value to clamp
  86686. * @param min The minimum of value
  86687. * @param max The maximum of value
  86688. * @returns The clamped value.
  86689. */
  86690. private static clamp;
  86691. /**
  86692. * Clones the current color curve instance.
  86693. * @return The cloned curves
  86694. */
  86695. clone(): ColorCurves;
  86696. /**
  86697. * Serializes the current color curve instance to a json representation.
  86698. * @return a JSON representation
  86699. */
  86700. serialize(): any;
  86701. /**
  86702. * Parses the color curve from a json representation.
  86703. * @param source the JSON source to parse
  86704. * @return The parsed curves
  86705. */
  86706. static Parse(source: any): ColorCurves;
  86707. }
  86708. }
  86709. declare module BABYLON {
  86710. /**
  86711. * Interface to follow in your material defines to integrate easily the
  86712. * Image proccessing functions.
  86713. * @hidden
  86714. */
  86715. export interface IImageProcessingConfigurationDefines {
  86716. IMAGEPROCESSING: boolean;
  86717. VIGNETTE: boolean;
  86718. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86719. VIGNETTEBLENDMODEOPAQUE: boolean;
  86720. TONEMAPPING: boolean;
  86721. TONEMAPPING_ACES: boolean;
  86722. CONTRAST: boolean;
  86723. EXPOSURE: boolean;
  86724. COLORCURVES: boolean;
  86725. COLORGRADING: boolean;
  86726. COLORGRADING3D: boolean;
  86727. SAMPLER3DGREENDEPTH: boolean;
  86728. SAMPLER3DBGRMAP: boolean;
  86729. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86730. }
  86731. /**
  86732. * @hidden
  86733. */
  86734. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86735. IMAGEPROCESSING: boolean;
  86736. VIGNETTE: boolean;
  86737. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86738. VIGNETTEBLENDMODEOPAQUE: boolean;
  86739. TONEMAPPING: boolean;
  86740. TONEMAPPING_ACES: boolean;
  86741. CONTRAST: boolean;
  86742. COLORCURVES: boolean;
  86743. COLORGRADING: boolean;
  86744. COLORGRADING3D: boolean;
  86745. SAMPLER3DGREENDEPTH: boolean;
  86746. SAMPLER3DBGRMAP: boolean;
  86747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86748. EXPOSURE: boolean;
  86749. constructor();
  86750. }
  86751. /**
  86752. * This groups together the common properties used for image processing either in direct forward pass
  86753. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86754. * or not.
  86755. */
  86756. export class ImageProcessingConfiguration {
  86757. /**
  86758. * Default tone mapping applied in BabylonJS.
  86759. */
  86760. static readonly TONEMAPPING_STANDARD: number;
  86761. /**
  86762. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86763. * to other engines rendering to increase portability.
  86764. */
  86765. static readonly TONEMAPPING_ACES: number;
  86766. /**
  86767. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86768. */
  86769. colorCurves: Nullable<ColorCurves>;
  86770. private _colorCurvesEnabled;
  86771. /**
  86772. * Gets wether the color curves effect is enabled.
  86773. */
  86774. /**
  86775. * Sets wether the color curves effect is enabled.
  86776. */
  86777. colorCurvesEnabled: boolean;
  86778. private _colorGradingTexture;
  86779. /**
  86780. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86781. */
  86782. /**
  86783. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86784. */
  86785. colorGradingTexture: Nullable<BaseTexture>;
  86786. private _colorGradingEnabled;
  86787. /**
  86788. * Gets wether the color grading effect is enabled.
  86789. */
  86790. /**
  86791. * Sets wether the color grading effect is enabled.
  86792. */
  86793. colorGradingEnabled: boolean;
  86794. private _colorGradingWithGreenDepth;
  86795. /**
  86796. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86797. */
  86798. /**
  86799. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86800. */
  86801. colorGradingWithGreenDepth: boolean;
  86802. private _colorGradingBGR;
  86803. /**
  86804. * Gets wether the color grading texture contains BGR values.
  86805. */
  86806. /**
  86807. * Sets wether the color grading texture contains BGR values.
  86808. */
  86809. colorGradingBGR: boolean;
  86810. /** @hidden */
  86811. _exposure: number;
  86812. /**
  86813. * Gets the Exposure used in the effect.
  86814. */
  86815. /**
  86816. * Sets the Exposure used in the effect.
  86817. */
  86818. exposure: number;
  86819. private _toneMappingEnabled;
  86820. /**
  86821. * Gets wether the tone mapping effect is enabled.
  86822. */
  86823. /**
  86824. * Sets wether the tone mapping effect is enabled.
  86825. */
  86826. toneMappingEnabled: boolean;
  86827. private _toneMappingType;
  86828. /**
  86829. * Gets the type of tone mapping effect.
  86830. */
  86831. /**
  86832. * Sets the type of tone mapping effect used in BabylonJS.
  86833. */
  86834. toneMappingType: number;
  86835. protected _contrast: number;
  86836. /**
  86837. * Gets the contrast used in the effect.
  86838. */
  86839. /**
  86840. * Sets the contrast used in the effect.
  86841. */
  86842. contrast: number;
  86843. /**
  86844. * Vignette stretch size.
  86845. */
  86846. vignetteStretch: number;
  86847. /**
  86848. * Vignette centre X Offset.
  86849. */
  86850. vignetteCentreX: number;
  86851. /**
  86852. * Vignette centre Y Offset.
  86853. */
  86854. vignetteCentreY: number;
  86855. /**
  86856. * Vignette weight or intensity of the vignette effect.
  86857. */
  86858. vignetteWeight: number;
  86859. /**
  86860. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86861. * if vignetteEnabled is set to true.
  86862. */
  86863. vignetteColor: Color4;
  86864. /**
  86865. * Camera field of view used by the Vignette effect.
  86866. */
  86867. vignetteCameraFov: number;
  86868. private _vignetteBlendMode;
  86869. /**
  86870. * Gets the vignette blend mode allowing different kind of effect.
  86871. */
  86872. /**
  86873. * Sets the vignette blend mode allowing different kind of effect.
  86874. */
  86875. vignetteBlendMode: number;
  86876. private _vignetteEnabled;
  86877. /**
  86878. * Gets wether the vignette effect is enabled.
  86879. */
  86880. /**
  86881. * Sets wether the vignette effect is enabled.
  86882. */
  86883. vignetteEnabled: boolean;
  86884. private _applyByPostProcess;
  86885. /**
  86886. * Gets wether the image processing is applied through a post process or not.
  86887. */
  86888. /**
  86889. * Sets wether the image processing is applied through a post process or not.
  86890. */
  86891. applyByPostProcess: boolean;
  86892. private _isEnabled;
  86893. /**
  86894. * Gets wether the image processing is enabled or not.
  86895. */
  86896. /**
  86897. * Sets wether the image processing is enabled or not.
  86898. */
  86899. isEnabled: boolean;
  86900. /**
  86901. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86902. */
  86903. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86904. /**
  86905. * Method called each time the image processing information changes requires to recompile the effect.
  86906. */
  86907. protected _updateParameters(): void;
  86908. /**
  86909. * Gets the current class name.
  86910. * @return "ImageProcessingConfiguration"
  86911. */
  86912. getClassName(): string;
  86913. /**
  86914. * Prepare the list of uniforms associated with the Image Processing effects.
  86915. * @param uniforms The list of uniforms used in the effect
  86916. * @param defines the list of defines currently in use
  86917. */
  86918. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86919. /**
  86920. * Prepare the list of samplers associated with the Image Processing effects.
  86921. * @param samplersList The list of uniforms used in the effect
  86922. * @param defines the list of defines currently in use
  86923. */
  86924. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86925. /**
  86926. * Prepare the list of defines associated to the shader.
  86927. * @param defines the list of defines to complete
  86928. * @param forPostProcess Define if we are currently in post process mode or not
  86929. */
  86930. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86931. /**
  86932. * Returns true if all the image processing information are ready.
  86933. * @returns True if ready, otherwise, false
  86934. */
  86935. isReady(): boolean;
  86936. /**
  86937. * Binds the image processing to the shader.
  86938. * @param effect The effect to bind to
  86939. * @param aspectRatio Define the current aspect ratio of the effect
  86940. */
  86941. bind(effect: Effect, aspectRatio?: number): void;
  86942. /**
  86943. * Clones the current image processing instance.
  86944. * @return The cloned image processing
  86945. */
  86946. clone(): ImageProcessingConfiguration;
  86947. /**
  86948. * Serializes the current image processing instance to a json representation.
  86949. * @return a JSON representation
  86950. */
  86951. serialize(): any;
  86952. /**
  86953. * Parses the image processing from a json representation.
  86954. * @param source the JSON source to parse
  86955. * @return The parsed image processing
  86956. */
  86957. static Parse(source: any): ImageProcessingConfiguration;
  86958. private static _VIGNETTEMODE_MULTIPLY;
  86959. private static _VIGNETTEMODE_OPAQUE;
  86960. /**
  86961. * Used to apply the vignette as a mix with the pixel color.
  86962. */
  86963. static readonly VIGNETTEMODE_MULTIPLY: number;
  86964. /**
  86965. * Used to apply the vignette as a replacement of the pixel color.
  86966. */
  86967. static readonly VIGNETTEMODE_OPAQUE: number;
  86968. }
  86969. }
  86970. declare module BABYLON {
  86971. /**
  86972. * This represents all the required information to add a fresnel effect on a material:
  86973. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86974. */
  86975. export class FresnelParameters {
  86976. private _isEnabled;
  86977. /**
  86978. * Define if the fresnel effect is enable or not.
  86979. */
  86980. isEnabled: boolean;
  86981. /**
  86982. * Define the color used on edges (grazing angle)
  86983. */
  86984. leftColor: Color3;
  86985. /**
  86986. * Define the color used on center
  86987. */
  86988. rightColor: Color3;
  86989. /**
  86990. * Define bias applied to computed fresnel term
  86991. */
  86992. bias: number;
  86993. /**
  86994. * Defined the power exponent applied to fresnel term
  86995. */
  86996. power: number;
  86997. /**
  86998. * Clones the current fresnel and its valuues
  86999. * @returns a clone fresnel configuration
  87000. */
  87001. clone(): FresnelParameters;
  87002. /**
  87003. * Serializes the current fresnel parameters to a JSON representation.
  87004. * @return the JSON serialization
  87005. */
  87006. serialize(): any;
  87007. /**
  87008. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  87009. * @param parsedFresnelParameters Define the JSON representation
  87010. * @returns the parsed parameters
  87011. */
  87012. static Parse(parsedFresnelParameters: any): FresnelParameters;
  87013. }
  87014. }
  87015. declare module BABYLON {
  87016. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  87017. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87018. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87019. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87020. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87021. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87022. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87023. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87024. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87025. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87026. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87027. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87028. /**
  87029. * Decorator used to define property that can be serialized as reference to a camera
  87030. * @param sourceName defines the name of the property to decorate
  87031. */
  87032. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87033. /**
  87034. * Class used to help serialization objects
  87035. */
  87036. export class SerializationHelper {
  87037. /** hidden */
  87038. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87039. /** hidden */
  87040. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87041. /** hidden */
  87042. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87043. /** hidden */
  87044. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87045. /**
  87046. * Appends the serialized animations from the source animations
  87047. * @param source Source containing the animations
  87048. * @param destination Target to store the animations
  87049. */
  87050. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87051. /**
  87052. * Static function used to serialized a specific entity
  87053. * @param entity defines the entity to serialize
  87054. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87055. * @returns a JSON compatible object representing the serialization of the entity
  87056. */
  87057. static Serialize<T>(entity: T, serializationObject?: any): any;
  87058. /**
  87059. * Creates a new entity from a serialization data object
  87060. * @param creationFunction defines a function used to instanciated the new entity
  87061. * @param source defines the source serialization data
  87062. * @param scene defines the hosting scene
  87063. * @param rootUrl defines the root url for resources
  87064. * @returns a new entity
  87065. */
  87066. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87067. /**
  87068. * Clones an object
  87069. * @param creationFunction defines the function used to instanciate the new object
  87070. * @param source defines the source object
  87071. * @returns the cloned object
  87072. */
  87073. static Clone<T>(creationFunction: () => T, source: T): T;
  87074. /**
  87075. * Instanciates a new object based on a source one (some data will be shared between both object)
  87076. * @param creationFunction defines the function used to instanciate the new object
  87077. * @param source defines the source object
  87078. * @returns the new object
  87079. */
  87080. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87081. }
  87082. }
  87083. declare module BABYLON {
  87084. /**
  87085. * This is the base class of all the camera used in the application.
  87086. * @see http://doc.babylonjs.com/features/cameras
  87087. */
  87088. export class Camera extends Node {
  87089. /** @hidden */
  87090. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87091. /**
  87092. * This is the default projection mode used by the cameras.
  87093. * It helps recreating a feeling of perspective and better appreciate depth.
  87094. * This is the best way to simulate real life cameras.
  87095. */
  87096. static readonly PERSPECTIVE_CAMERA: number;
  87097. /**
  87098. * This helps creating camera with an orthographic mode.
  87099. * 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.
  87100. */
  87101. static readonly ORTHOGRAPHIC_CAMERA: number;
  87102. /**
  87103. * This is the default FOV mode for perspective cameras.
  87104. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87105. */
  87106. static readonly FOVMODE_VERTICAL_FIXED: number;
  87107. /**
  87108. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87109. */
  87110. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87111. /**
  87112. * This specifies ther is no need for a camera rig.
  87113. * Basically only one eye is rendered corresponding to the camera.
  87114. */
  87115. static readonly RIG_MODE_NONE: number;
  87116. /**
  87117. * Simulates a camera Rig with one blue eye and one red eye.
  87118. * This can be use with 3d blue and red glasses.
  87119. */
  87120. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87121. /**
  87122. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87123. */
  87124. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87125. /**
  87126. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87127. */
  87128. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87129. /**
  87130. * Defines that both eyes of the camera will be rendered over under each other.
  87131. */
  87132. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87133. /**
  87134. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87135. */
  87136. static readonly RIG_MODE_VR: number;
  87137. /**
  87138. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87139. */
  87140. static readonly RIG_MODE_WEBVR: number;
  87141. /**
  87142. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87143. */
  87144. static readonly RIG_MODE_CUSTOM: number;
  87145. /**
  87146. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87147. */
  87148. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87149. /**
  87150. * @hidden
  87151. * Might be removed once multiview will be a thing
  87152. */
  87153. static UseAlternateWebVRRendering: boolean;
  87154. /**
  87155. * Define the input manager associated with the camera.
  87156. */
  87157. inputs: CameraInputsManager<Camera>;
  87158. /** @hidden */
  87159. _position: Vector3;
  87160. /**
  87161. * Define the current local position of the camera in the scene
  87162. */
  87163. position: Vector3;
  87164. /**
  87165. * The vector the camera should consider as up.
  87166. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87167. */
  87168. upVector: Vector3;
  87169. /**
  87170. * Define the current limit on the left side for an orthographic camera
  87171. * In scene unit
  87172. */
  87173. orthoLeft: Nullable<number>;
  87174. /**
  87175. * Define the current limit on the right side for an orthographic camera
  87176. * In scene unit
  87177. */
  87178. orthoRight: Nullable<number>;
  87179. /**
  87180. * Define the current limit on the bottom side for an orthographic camera
  87181. * In scene unit
  87182. */
  87183. orthoBottom: Nullable<number>;
  87184. /**
  87185. * Define the current limit on the top side for an orthographic camera
  87186. * In scene unit
  87187. */
  87188. orthoTop: Nullable<number>;
  87189. /**
  87190. * Field Of View is set in Radians. (default is 0.8)
  87191. */
  87192. fov: number;
  87193. /**
  87194. * Define the minimum distance the camera can see from.
  87195. * This is important to note that the depth buffer are not infinite and the closer it starts
  87196. * the more your scene might encounter depth fighting issue.
  87197. */
  87198. minZ: number;
  87199. /**
  87200. * Define the maximum distance the camera can see to.
  87201. * This is important to note that the depth buffer are not infinite and the further it end
  87202. * the more your scene might encounter depth fighting issue.
  87203. */
  87204. maxZ: number;
  87205. /**
  87206. * Define the default inertia of the camera.
  87207. * This helps giving a smooth feeling to the camera movement.
  87208. */
  87209. inertia: number;
  87210. /**
  87211. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87212. */
  87213. mode: number;
  87214. /**
  87215. * Define wether the camera is intermediate.
  87216. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87217. */
  87218. isIntermediate: boolean;
  87219. /**
  87220. * Define the viewport of the camera.
  87221. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87222. */
  87223. viewport: Viewport;
  87224. /**
  87225. * Restricts the camera to viewing objects with the same layerMask.
  87226. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87227. */
  87228. layerMask: number;
  87229. /**
  87230. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87231. */
  87232. fovMode: number;
  87233. /**
  87234. * Rig mode of the camera.
  87235. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87236. * This is normally controlled byt the camera themselves as internal use.
  87237. */
  87238. cameraRigMode: number;
  87239. /**
  87240. * Defines the distance between both "eyes" in case of a RIG
  87241. */
  87242. interaxialDistance: number;
  87243. /**
  87244. * Defines if stereoscopic rendering is done side by side or over under.
  87245. */
  87246. isStereoscopicSideBySide: boolean;
  87247. /**
  87248. * 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
  87249. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87250. * else in the scene.
  87251. */
  87252. customRenderTargets: RenderTargetTexture[];
  87253. /**
  87254. * When set, the camera will render to this render target instead of the default canvas
  87255. */
  87256. outputRenderTarget: Nullable<RenderTargetTexture>;
  87257. /**
  87258. * Observable triggered when the camera view matrix has changed.
  87259. */
  87260. onViewMatrixChangedObservable: Observable<Camera>;
  87261. /**
  87262. * Observable triggered when the camera Projection matrix has changed.
  87263. */
  87264. onProjectionMatrixChangedObservable: Observable<Camera>;
  87265. /**
  87266. * Observable triggered when the inputs have been processed.
  87267. */
  87268. onAfterCheckInputsObservable: Observable<Camera>;
  87269. /**
  87270. * Observable triggered when reset has been called and applied to the camera.
  87271. */
  87272. onRestoreStateObservable: Observable<Camera>;
  87273. /** @hidden */
  87274. _cameraRigParams: any;
  87275. /** @hidden */
  87276. _rigCameras: Camera[];
  87277. /** @hidden */
  87278. _rigPostProcess: Nullable<PostProcess>;
  87279. protected _webvrViewMatrix: Matrix;
  87280. /** @hidden */
  87281. _skipRendering: boolean;
  87282. /** @hidden */
  87283. _alternateCamera: Camera;
  87284. /** @hidden */
  87285. _projectionMatrix: Matrix;
  87286. /** @hidden */
  87287. _postProcesses: Nullable<PostProcess>[];
  87288. /** @hidden */
  87289. _activeMeshes: SmartArray<AbstractMesh>;
  87290. protected _globalPosition: Vector3;
  87291. /** hidden */
  87292. _computedViewMatrix: Matrix;
  87293. private _doNotComputeProjectionMatrix;
  87294. private _transformMatrix;
  87295. private _frustumPlanes;
  87296. private _refreshFrustumPlanes;
  87297. private _storedFov;
  87298. private _stateStored;
  87299. /**
  87300. * Instantiates a new camera object.
  87301. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87302. * @see http://doc.babylonjs.com/features/cameras
  87303. * @param name Defines the name of the camera in the scene
  87304. * @param position Defines the position of the camera
  87305. * @param scene Defines the scene the camera belongs too
  87306. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87307. */
  87308. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87309. /**
  87310. * Store current camera state (fov, position, etc..)
  87311. * @returns the camera
  87312. */
  87313. storeState(): Camera;
  87314. /**
  87315. * Restores the camera state values if it has been stored. You must call storeState() first
  87316. */
  87317. protected _restoreStateValues(): boolean;
  87318. /**
  87319. * Restored camera state. You must call storeState() first.
  87320. * @returns true if restored and false otherwise
  87321. */
  87322. restoreState(): boolean;
  87323. /**
  87324. * Gets the class name of the camera.
  87325. * @returns the class name
  87326. */
  87327. getClassName(): string;
  87328. /** @hidden */
  87329. readonly _isCamera: boolean;
  87330. /**
  87331. * Gets a string representation of the camera useful for debug purpose.
  87332. * @param fullDetails Defines that a more verboe level of logging is required
  87333. * @returns the string representation
  87334. */
  87335. toString(fullDetails?: boolean): string;
  87336. /**
  87337. * Gets the current world space position of the camera.
  87338. */
  87339. readonly globalPosition: Vector3;
  87340. /**
  87341. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87342. * @returns the active meshe list
  87343. */
  87344. getActiveMeshes(): SmartArray<AbstractMesh>;
  87345. /**
  87346. * Check wether a mesh is part of the current active mesh list of the camera
  87347. * @param mesh Defines the mesh to check
  87348. * @returns true if active, false otherwise
  87349. */
  87350. isActiveMesh(mesh: Mesh): boolean;
  87351. /**
  87352. * Is this camera ready to be used/rendered
  87353. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87354. * @return true if the camera is ready
  87355. */
  87356. isReady(completeCheck?: boolean): boolean;
  87357. /** @hidden */
  87358. _initCache(): void;
  87359. /** @hidden */
  87360. _updateCache(ignoreParentClass?: boolean): void;
  87361. /** @hidden */
  87362. _isSynchronized(): boolean;
  87363. /** @hidden */
  87364. _isSynchronizedViewMatrix(): boolean;
  87365. /** @hidden */
  87366. _isSynchronizedProjectionMatrix(): boolean;
  87367. /**
  87368. * Attach the input controls to a specific dom element to get the input from.
  87369. * @param element Defines the element the controls should be listened from
  87370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87371. */
  87372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87373. /**
  87374. * Detach the current controls from the specified dom element.
  87375. * @param element Defines the element to stop listening the inputs from
  87376. */
  87377. detachControl(element: HTMLElement): void;
  87378. /**
  87379. * Update the camera state according to the different inputs gathered during the frame.
  87380. */
  87381. update(): void;
  87382. /** @hidden */
  87383. _checkInputs(): void;
  87384. /** @hidden */
  87385. readonly rigCameras: Camera[];
  87386. /**
  87387. * Gets the post process used by the rig cameras
  87388. */
  87389. readonly rigPostProcess: Nullable<PostProcess>;
  87390. /**
  87391. * Internal, gets the first post proces.
  87392. * @returns the first post process to be run on this camera.
  87393. */
  87394. _getFirstPostProcess(): Nullable<PostProcess>;
  87395. private _cascadePostProcessesToRigCams;
  87396. /**
  87397. * Attach a post process to the camera.
  87398. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87399. * @param postProcess The post process to attach to the camera
  87400. * @param insertAt The position of the post process in case several of them are in use in the scene
  87401. * @returns the position the post process has been inserted at
  87402. */
  87403. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87404. /**
  87405. * Detach a post process to the camera.
  87406. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87407. * @param postProcess The post process to detach from the camera
  87408. */
  87409. detachPostProcess(postProcess: PostProcess): void;
  87410. /**
  87411. * Gets the current world matrix of the camera
  87412. */
  87413. getWorldMatrix(): Matrix;
  87414. /** @hidden */
  87415. _getViewMatrix(): Matrix;
  87416. /**
  87417. * Gets the current view matrix of the camera.
  87418. * @param force forces the camera to recompute the matrix without looking at the cached state
  87419. * @returns the view matrix
  87420. */
  87421. getViewMatrix(force?: boolean): Matrix;
  87422. /**
  87423. * Freeze the projection matrix.
  87424. * It will prevent the cache check of the camera projection compute and can speed up perf
  87425. * if no parameter of the camera are meant to change
  87426. * @param projection Defines manually a projection if necessary
  87427. */
  87428. freezeProjectionMatrix(projection?: Matrix): void;
  87429. /**
  87430. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87431. */
  87432. unfreezeProjectionMatrix(): void;
  87433. /**
  87434. * Gets the current projection matrix of the camera.
  87435. * @param force forces the camera to recompute the matrix without looking at the cached state
  87436. * @returns the projection matrix
  87437. */
  87438. getProjectionMatrix(force?: boolean): Matrix;
  87439. /**
  87440. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87441. * @returns a Matrix
  87442. */
  87443. getTransformationMatrix(): Matrix;
  87444. private _updateFrustumPlanes;
  87445. /**
  87446. * Checks if a cullable object (mesh...) is in the camera frustum
  87447. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87448. * @param target The object to check
  87449. * @returns true if the object is in frustum otherwise false
  87450. */
  87451. isInFrustum(target: ICullable): boolean;
  87452. /**
  87453. * Checks if a cullable object (mesh...) is in the camera frustum
  87454. * Unlike isInFrustum this cheks the full bounding box
  87455. * @param target The object to check
  87456. * @returns true if the object is in frustum otherwise false
  87457. */
  87458. isCompletelyInFrustum(target: ICullable): boolean;
  87459. /**
  87460. * Gets a ray in the forward direction from the camera.
  87461. * @param length Defines the length of the ray to create
  87462. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87463. * @param origin Defines the start point of the ray which defaults to the camera position
  87464. * @returns the forward ray
  87465. */
  87466. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87467. /**
  87468. * Releases resources associated with this node.
  87469. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87470. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87471. */
  87472. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87473. /** @hidden */
  87474. _isLeftCamera: boolean;
  87475. /**
  87476. * Gets the left camera of a rig setup in case of Rigged Camera
  87477. */
  87478. readonly isLeftCamera: boolean;
  87479. /** @hidden */
  87480. _isRightCamera: boolean;
  87481. /**
  87482. * Gets the right camera of a rig setup in case of Rigged Camera
  87483. */
  87484. readonly isRightCamera: boolean;
  87485. /**
  87486. * Gets the left camera of a rig setup in case of Rigged Camera
  87487. */
  87488. readonly leftCamera: Nullable<FreeCamera>;
  87489. /**
  87490. * Gets the right camera of a rig setup in case of Rigged Camera
  87491. */
  87492. readonly rightCamera: Nullable<FreeCamera>;
  87493. /**
  87494. * Gets the left camera target of a rig setup in case of Rigged Camera
  87495. * @returns the target position
  87496. */
  87497. getLeftTarget(): Nullable<Vector3>;
  87498. /**
  87499. * Gets the right camera target of a rig setup in case of Rigged Camera
  87500. * @returns the target position
  87501. */
  87502. getRightTarget(): Nullable<Vector3>;
  87503. /**
  87504. * @hidden
  87505. */
  87506. setCameraRigMode(mode: number, rigParams: any): void;
  87507. /** @hidden */
  87508. static _setStereoscopicRigMode(camera: Camera): void;
  87509. /** @hidden */
  87510. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87511. /** @hidden */
  87512. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87513. /** @hidden */
  87514. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87515. /** @hidden */
  87516. _getVRProjectionMatrix(): Matrix;
  87517. protected _updateCameraRotationMatrix(): void;
  87518. protected _updateWebVRCameraRotationMatrix(): void;
  87519. /**
  87520. * This function MUST be overwritten by the different WebVR cameras available.
  87521. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87522. * @hidden
  87523. */
  87524. _getWebVRProjectionMatrix(): Matrix;
  87525. /**
  87526. * This function MUST be overwritten by the different WebVR cameras available.
  87527. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87528. * @hidden
  87529. */
  87530. _getWebVRViewMatrix(): Matrix;
  87531. /** @hidden */
  87532. setCameraRigParameter(name: string, value: any): void;
  87533. /**
  87534. * needs to be overridden by children so sub has required properties to be copied
  87535. * @hidden
  87536. */
  87537. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87538. /**
  87539. * May need to be overridden by children
  87540. * @hidden
  87541. */
  87542. _updateRigCameras(): void;
  87543. /** @hidden */
  87544. _setupInputs(): void;
  87545. /**
  87546. * Serialiaze the camera setup to a json represention
  87547. * @returns the JSON representation
  87548. */
  87549. serialize(): any;
  87550. /**
  87551. * Clones the current camera.
  87552. * @param name The cloned camera name
  87553. * @returns the cloned camera
  87554. */
  87555. clone(name: string): Camera;
  87556. /**
  87557. * Gets the direction of the camera relative to a given local axis.
  87558. * @param localAxis Defines the reference axis to provide a relative direction.
  87559. * @return the direction
  87560. */
  87561. getDirection(localAxis: Vector3): Vector3;
  87562. /**
  87563. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87564. * @param localAxis Defines the reference axis to provide a relative direction.
  87565. * @param result Defines the vector to store the result in
  87566. */
  87567. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87568. /**
  87569. * Gets a camera constructor for a given camera type
  87570. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87571. * @param name The name of the camera the result will be able to instantiate
  87572. * @param scene The scene the result will construct the camera in
  87573. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87574. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87575. * @returns a factory method to construc the camera
  87576. */
  87577. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87578. /**
  87579. * Compute the world matrix of the camera.
  87580. * @returns the camera workd matrix
  87581. */
  87582. computeWorldMatrix(): Matrix;
  87583. /**
  87584. * Parse a JSON and creates the camera from the parsed information
  87585. * @param parsedCamera The JSON to parse
  87586. * @param scene The scene to instantiate the camera in
  87587. * @returns the newly constructed camera
  87588. */
  87589. static Parse(parsedCamera: any, scene: Scene): Camera;
  87590. }
  87591. }
  87592. declare module BABYLON {
  87593. /**
  87594. * Interface for any object that can request an animation frame
  87595. */
  87596. export interface ICustomAnimationFrameRequester {
  87597. /**
  87598. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87599. */
  87600. renderFunction?: Function;
  87601. /**
  87602. * Called to request the next frame to render to
  87603. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87604. */
  87605. requestAnimationFrame: Function;
  87606. /**
  87607. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87608. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87609. */
  87610. requestID?: number;
  87611. }
  87612. /**
  87613. * Interface containing an array of animations
  87614. */
  87615. export interface IAnimatable {
  87616. /**
  87617. * Array of animations
  87618. */
  87619. animations: Array<Animation>;
  87620. }
  87621. /** Interface used by value gradients (color, factor, ...) */
  87622. export interface IValueGradient {
  87623. /**
  87624. * Gets or sets the gradient value (between 0 and 1)
  87625. */
  87626. gradient: number;
  87627. }
  87628. /** Class used to store color4 gradient */
  87629. export class ColorGradient implements IValueGradient {
  87630. /**
  87631. * Gets or sets the gradient value (between 0 and 1)
  87632. */
  87633. gradient: number;
  87634. /**
  87635. * Gets or sets first associated color
  87636. */
  87637. color1: Color4;
  87638. /**
  87639. * Gets or sets second associated color
  87640. */
  87641. color2?: Color4;
  87642. /**
  87643. * Will get a color picked randomly between color1 and color2.
  87644. * If color2 is undefined then color1 will be used
  87645. * @param result defines the target Color4 to store the result in
  87646. */
  87647. getColorToRef(result: Color4): void;
  87648. }
  87649. /** Class used to store color 3 gradient */
  87650. export class Color3Gradient implements IValueGradient {
  87651. /**
  87652. * Gets or sets the gradient value (between 0 and 1)
  87653. */
  87654. gradient: number;
  87655. /**
  87656. * Gets or sets the associated color
  87657. */
  87658. color: Color3;
  87659. }
  87660. /** Class used to store factor gradient */
  87661. export class FactorGradient implements IValueGradient {
  87662. /**
  87663. * Gets or sets the gradient value (between 0 and 1)
  87664. */
  87665. gradient: number;
  87666. /**
  87667. * Gets or sets first associated factor
  87668. */
  87669. factor1: number;
  87670. /**
  87671. * Gets or sets second associated factor
  87672. */
  87673. factor2?: number;
  87674. /**
  87675. * Will get a number picked randomly between factor1 and factor2.
  87676. * If factor2 is undefined then factor1 will be used
  87677. * @returns the picked number
  87678. */
  87679. getFactor(): number;
  87680. }
  87681. /**
  87682. * @ignore
  87683. * Application error to support additional information when loading a file
  87684. */
  87685. export class LoadFileError extends Error {
  87686. /** defines the optional XHR request */
  87687. request?: XMLHttpRequest | undefined;
  87688. private static _setPrototypeOf;
  87689. /**
  87690. * Creates a new LoadFileError
  87691. * @param message defines the message of the error
  87692. * @param request defines the optional XHR request
  87693. */
  87694. constructor(message: string,
  87695. /** defines the optional XHR request */
  87696. request?: XMLHttpRequest | undefined);
  87697. }
  87698. /**
  87699. * Class used to define a retry strategy when error happens while loading assets
  87700. */
  87701. export class RetryStrategy {
  87702. /**
  87703. * Function used to defines an exponential back off strategy
  87704. * @param maxRetries defines the maximum number of retries (3 by default)
  87705. * @param baseInterval defines the interval between retries
  87706. * @returns the strategy function to use
  87707. */
  87708. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87709. }
  87710. /**
  87711. * File request interface
  87712. */
  87713. export interface IFileRequest {
  87714. /**
  87715. * Raised when the request is complete (success or error).
  87716. */
  87717. onCompleteObservable: Observable<IFileRequest>;
  87718. /**
  87719. * Aborts the request for a file.
  87720. */
  87721. abort: () => void;
  87722. }
  87723. /**
  87724. * Class containing a set of static utilities functions
  87725. */
  87726. export class Tools {
  87727. /**
  87728. * Gets or sets the base URL to use to load assets
  87729. */
  87730. static BaseUrl: string;
  87731. /**
  87732. * Enable/Disable Custom HTTP Request Headers globally.
  87733. * default = false
  87734. * @see CustomRequestHeaders
  87735. */
  87736. static UseCustomRequestHeaders: boolean;
  87737. /**
  87738. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87739. * i.e. when loading files, where the server/service expects an Authorization header.
  87740. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87741. */
  87742. static CustomRequestHeaders: {
  87743. [key: string]: string;
  87744. };
  87745. /**
  87746. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87747. */
  87748. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87749. /**
  87750. * Default behaviour for cors in the application.
  87751. * It can be a string if the expected behavior is identical in the entire app.
  87752. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87753. */
  87754. static CorsBehavior: string | ((url: string | string[]) => string);
  87755. /**
  87756. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87757. * @ignorenaming
  87758. */
  87759. static UseFallbackTexture: boolean;
  87760. /**
  87761. * Use this object to register external classes like custom textures or material
  87762. * to allow the laoders to instantiate them
  87763. */
  87764. static RegisteredExternalClasses: {
  87765. [key: string]: Object;
  87766. };
  87767. /**
  87768. * Texture content used if a texture cannot loaded
  87769. * @ignorenaming
  87770. */
  87771. static fallbackTexture: string;
  87772. /**
  87773. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87774. * @param u defines the coordinate on X axis
  87775. * @param v defines the coordinate on Y axis
  87776. * @param width defines the width of the source data
  87777. * @param height defines the height of the source data
  87778. * @param pixels defines the source byte array
  87779. * @param color defines the output color
  87780. */
  87781. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87782. /**
  87783. * Interpolates between a and b via alpha
  87784. * @param a The lower value (returned when alpha = 0)
  87785. * @param b The upper value (returned when alpha = 1)
  87786. * @param alpha The interpolation-factor
  87787. * @return The mixed value
  87788. */
  87789. static Mix(a: number, b: number, alpha: number): number;
  87790. /**
  87791. * Tries to instantiate a new object from a given class name
  87792. * @param className defines the class name to instantiate
  87793. * @returns the new object or null if the system was not able to do the instantiation
  87794. */
  87795. static Instantiate(className: string): any;
  87796. /**
  87797. * Provides a slice function that will work even on IE
  87798. * @param data defines the array to slice
  87799. * @param start defines the start of the data (optional)
  87800. * @param end defines the end of the data (optional)
  87801. * @returns the new sliced array
  87802. */
  87803. static Slice<T>(data: T, start?: number, end?: number): T;
  87804. /**
  87805. * Polyfill for setImmediate
  87806. * @param action defines the action to execute after the current execution block
  87807. */
  87808. static SetImmediate(action: () => void): void;
  87809. /**
  87810. * Function indicating if a number is an exponent of 2
  87811. * @param value defines the value to test
  87812. * @returns true if the value is an exponent of 2
  87813. */
  87814. static IsExponentOfTwo(value: number): boolean;
  87815. private static _tmpFloatArray;
  87816. /**
  87817. * Returns the nearest 32-bit single precision float representation of a Number
  87818. * @param value A Number. If the parameter is of a different type, it will get converted
  87819. * to a number or to NaN if it cannot be converted
  87820. * @returns number
  87821. */
  87822. static FloatRound(value: number): number;
  87823. /**
  87824. * Find the next highest power of two.
  87825. * @param x Number to start search from.
  87826. * @return Next highest power of two.
  87827. */
  87828. static CeilingPOT(x: number): number;
  87829. /**
  87830. * Find the next lowest power of two.
  87831. * @param x Number to start search from.
  87832. * @return Next lowest power of two.
  87833. */
  87834. static FloorPOT(x: number): number;
  87835. /**
  87836. * Find the nearest power of two.
  87837. * @param x Number to start search from.
  87838. * @return Next nearest power of two.
  87839. */
  87840. static NearestPOT(x: number): number;
  87841. /**
  87842. * Get the closest exponent of two
  87843. * @param value defines the value to approximate
  87844. * @param max defines the maximum value to return
  87845. * @param mode defines how to define the closest value
  87846. * @returns closest exponent of two of the given value
  87847. */
  87848. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87849. /**
  87850. * Extracts the filename from a path
  87851. * @param path defines the path to use
  87852. * @returns the filename
  87853. */
  87854. static GetFilename(path: string): string;
  87855. /**
  87856. * Extracts the "folder" part of a path (everything before the filename).
  87857. * @param uri The URI to extract the info from
  87858. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87859. * @returns The "folder" part of the path
  87860. */
  87861. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87862. /**
  87863. * Extracts text content from a DOM element hierarchy
  87864. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87865. */
  87866. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87867. /**
  87868. * Convert an angle in radians to degrees
  87869. * @param angle defines the angle to convert
  87870. * @returns the angle in degrees
  87871. */
  87872. static ToDegrees(angle: number): number;
  87873. /**
  87874. * Convert an angle in degrees to radians
  87875. * @param angle defines the angle to convert
  87876. * @returns the angle in radians
  87877. */
  87878. static ToRadians(angle: number): number;
  87879. /**
  87880. * Encode a buffer to a base64 string
  87881. * @param buffer defines the buffer to encode
  87882. * @returns the encoded string
  87883. */
  87884. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87885. /**
  87886. * Extracts minimum and maximum values from a list of indexed positions
  87887. * @param positions defines the positions to use
  87888. * @param indices defines the indices to the positions
  87889. * @param indexStart defines the start index
  87890. * @param indexCount defines the end index
  87891. * @param bias defines bias value to add to the result
  87892. * @return minimum and maximum values
  87893. */
  87894. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87895. minimum: Vector3;
  87896. maximum: Vector3;
  87897. };
  87898. /**
  87899. * Extracts minimum and maximum values from a list of positions
  87900. * @param positions defines the positions to use
  87901. * @param start defines the start index in the positions array
  87902. * @param count defines the number of positions to handle
  87903. * @param bias defines bias value to add to the result
  87904. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87905. * @return minimum and maximum values
  87906. */
  87907. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87908. minimum: Vector3;
  87909. maximum: Vector3;
  87910. };
  87911. /**
  87912. * Returns an array if obj is not an array
  87913. * @param obj defines the object to evaluate as an array
  87914. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87915. * @returns either obj directly if obj is an array or a new array containing obj
  87916. */
  87917. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87918. /**
  87919. * Gets the pointer prefix to use
  87920. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87921. */
  87922. static GetPointerPrefix(): string;
  87923. /**
  87924. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87925. * @param func - the function to be called
  87926. * @param requester - the object that will request the next frame. Falls back to window.
  87927. * @returns frame number
  87928. */
  87929. static QueueNewFrame(func: () => void, requester?: any): number;
  87930. /**
  87931. * Ask the browser to promote the current element to fullscreen rendering mode
  87932. * @param element defines the DOM element to promote
  87933. */
  87934. static RequestFullscreen(element: HTMLElement): void;
  87935. /**
  87936. * Asks the browser to exit fullscreen mode
  87937. */
  87938. static ExitFullscreen(): void;
  87939. /**
  87940. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87941. * @param url define the url we are trying
  87942. * @param element define the dom element where to configure the cors policy
  87943. */
  87944. static SetCorsBehavior(url: string | string[], element: {
  87945. crossOrigin: string | null;
  87946. }): void;
  87947. /**
  87948. * Removes unwanted characters from an url
  87949. * @param url defines the url to clean
  87950. * @returns the cleaned url
  87951. */
  87952. static CleanUrl(url: string): string;
  87953. /**
  87954. * Gets or sets a function used to pre-process url before using them to load assets
  87955. */
  87956. static PreprocessUrl: (url: string) => string;
  87957. /**
  87958. * Loads an image as an HTMLImageElement.
  87959. * @param input url string, ArrayBuffer, or Blob to load
  87960. * @param onLoad callback called when the image successfully loads
  87961. * @param onError callback called when the image fails to load
  87962. * @param offlineProvider offline provider for caching
  87963. * @returns the HTMLImageElement of the loaded image
  87964. */
  87965. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87966. /**
  87967. * Loads a file
  87968. * @param url url string, ArrayBuffer, or Blob to load
  87969. * @param onSuccess callback called when the file successfully loads
  87970. * @param onProgress callback called while file is loading (if the server supports this mode)
  87971. * @param offlineProvider defines the offline provider for caching
  87972. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87973. * @param onError callback called when the file fails to load
  87974. * @returns a file request object
  87975. */
  87976. 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;
  87977. /**
  87978. * Load a script (identified by an url). When the url returns, the
  87979. * content of this file is added into a new script element, attached to the DOM (body element)
  87980. * @param scriptUrl defines the url of the script to laod
  87981. * @param onSuccess defines the callback called when the script is loaded
  87982. * @param onError defines the callback to call if an error occurs
  87983. */
  87984. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87985. /**
  87986. * Loads a file from a blob
  87987. * @param fileToLoad defines the blob to use
  87988. * @param callback defines the callback to call when data is loaded
  87989. * @param progressCallback defines the callback to call during loading process
  87990. * @returns a file request object
  87991. */
  87992. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87993. /**
  87994. * Loads a file
  87995. * @param fileToLoad defines the file to load
  87996. * @param callback defines the callback to call when data is loaded
  87997. * @param progressCallBack defines the callback to call during loading process
  87998. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87999. * @returns a file request object
  88000. */
  88001. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  88002. /**
  88003. * Creates a data url from a given string content
  88004. * @param content defines the content to convert
  88005. * @returns the new data url link
  88006. */
  88007. static FileAsURL(content: string): string;
  88008. /**
  88009. * Format the given number to a specific decimal format
  88010. * @param value defines the number to format
  88011. * @param decimals defines the number of decimals to use
  88012. * @returns the formatted string
  88013. */
  88014. static Format(value: number, decimals?: number): string;
  88015. /**
  88016. * Checks if a given vector is inside a specific range
  88017. * @param v defines the vector to test
  88018. * @param min defines the minimum range
  88019. * @param max defines the maximum range
  88020. */
  88021. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88022. /**
  88023. * Tries to copy an object by duplicating every property
  88024. * @param source defines the source object
  88025. * @param destination defines the target object
  88026. * @param doNotCopyList defines a list of properties to avoid
  88027. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88028. */
  88029. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88030. /**
  88031. * Gets a boolean indicating if the given object has no own property
  88032. * @param obj defines the object to test
  88033. * @returns true if object has no own property
  88034. */
  88035. static IsEmpty(obj: any): boolean;
  88036. /**
  88037. * Function used to register events at window level
  88038. * @param events defines the events to register
  88039. */
  88040. static RegisterTopRootEvents(events: {
  88041. name: string;
  88042. handler: Nullable<(e: FocusEvent) => any>;
  88043. }[]): void;
  88044. /**
  88045. * Function used to unregister events from window level
  88046. * @param events defines the events to unregister
  88047. */
  88048. static UnregisterTopRootEvents(events: {
  88049. name: string;
  88050. handler: Nullable<(e: FocusEvent) => any>;
  88051. }[]): void;
  88052. /**
  88053. * @ignore
  88054. */
  88055. static _ScreenshotCanvas: HTMLCanvasElement;
  88056. /**
  88057. * Dumps the current bound framebuffer
  88058. * @param width defines the rendering width
  88059. * @param height defines the rendering height
  88060. * @param engine defines the hosting engine
  88061. * @param successCallback defines the callback triggered once the data are available
  88062. * @param mimeType defines the mime type of the result
  88063. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88064. */
  88065. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88066. /**
  88067. * Converts the canvas data to blob.
  88068. * This acts as a polyfill for browsers not supporting the to blob function.
  88069. * @param canvas Defines the canvas to extract the data from
  88070. * @param successCallback Defines the callback triggered once the data are available
  88071. * @param mimeType Defines the mime type of the result
  88072. */
  88073. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88074. /**
  88075. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88076. * @param successCallback defines the callback triggered once the data are available
  88077. * @param mimeType defines the mime type of the result
  88078. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88079. */
  88080. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88081. /**
  88082. * Downloads a blob in the browser
  88083. * @param blob defines the blob to download
  88084. * @param fileName defines the name of the downloaded file
  88085. */
  88086. static Download(blob: Blob, fileName: string): void;
  88087. /**
  88088. * Captures a screenshot of the current rendering
  88089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88090. * @param engine defines the rendering engine
  88091. * @param camera defines the source camera
  88092. * @param size This parameter can be set to a single number or to an object with the
  88093. * following (optional) properties: precision, width, height. If a single number is passed,
  88094. * it will be used for both width and height. If an object is passed, the screenshot size
  88095. * will be derived from the parameters. The precision property is a multiplier allowing
  88096. * rendering at a higher or lower resolution
  88097. * @param successCallback defines the callback receives a single parameter which contains the
  88098. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88099. * src parameter of an <img> to display it
  88100. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88101. * Check your browser for supported MIME types
  88102. */
  88103. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88104. /**
  88105. * Generates an image screenshot from the specified camera.
  88106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88107. * @param engine The engine to use for rendering
  88108. * @param camera The camera to use for rendering
  88109. * @param size This parameter can be set to a single number or to an object with the
  88110. * following (optional) properties: precision, width, height. If a single number is passed,
  88111. * it will be used for both width and height. If an object is passed, the screenshot size
  88112. * will be derived from the parameters. The precision property is a multiplier allowing
  88113. * rendering at a higher or lower resolution
  88114. * @param successCallback The callback receives a single parameter which contains the
  88115. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88116. * src parameter of an <img> to display it
  88117. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88118. * Check your browser for supported MIME types
  88119. * @param samples Texture samples (default: 1)
  88120. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88121. * @param fileName A name for for the downloaded file.
  88122. */
  88123. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88124. /**
  88125. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88126. * Be aware Math.random() could cause collisions, but:
  88127. * "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"
  88128. * @returns a pseudo random id
  88129. */
  88130. static RandomId(): string;
  88131. /**
  88132. * Test if the given uri is a base64 string
  88133. * @param uri The uri to test
  88134. * @return True if the uri is a base64 string or false otherwise
  88135. */
  88136. static IsBase64(uri: string): boolean;
  88137. /**
  88138. * Decode the given base64 uri.
  88139. * @param uri The uri to decode
  88140. * @return The decoded base64 data.
  88141. */
  88142. static DecodeBase64(uri: string): ArrayBuffer;
  88143. /**
  88144. * No log
  88145. */
  88146. static readonly NoneLogLevel: number;
  88147. /**
  88148. * Only message logs
  88149. */
  88150. static readonly MessageLogLevel: number;
  88151. /**
  88152. * Only warning logs
  88153. */
  88154. static readonly WarningLogLevel: number;
  88155. /**
  88156. * Only error logs
  88157. */
  88158. static readonly ErrorLogLevel: number;
  88159. /**
  88160. * All logs
  88161. */
  88162. static readonly AllLogLevel: number;
  88163. /**
  88164. * Gets a value indicating the number of loading errors
  88165. * @ignorenaming
  88166. */
  88167. static readonly errorsCount: number;
  88168. /**
  88169. * Callback called when a new log is added
  88170. */
  88171. static OnNewCacheEntry: (entry: string) => void;
  88172. /**
  88173. * Log a message to the console
  88174. * @param message defines the message to log
  88175. */
  88176. static Log(message: string): void;
  88177. /**
  88178. * Write a warning message to the console
  88179. * @param message defines the message to log
  88180. */
  88181. static Warn(message: string): void;
  88182. /**
  88183. * Write an error message to the console
  88184. * @param message defines the message to log
  88185. */
  88186. static Error(message: string): void;
  88187. /**
  88188. * Gets current log cache (list of logs)
  88189. */
  88190. static readonly LogCache: string;
  88191. /**
  88192. * Clears the log cache
  88193. */
  88194. static ClearLogCache(): void;
  88195. /**
  88196. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88197. */
  88198. static LogLevels: number;
  88199. /**
  88200. * Checks if the loaded document was accessed via `file:`-Protocol.
  88201. * @returns boolean
  88202. */
  88203. static IsFileURL(): boolean;
  88204. /**
  88205. * Checks if the window object exists
  88206. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88207. */
  88208. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88209. /**
  88210. * No performance log
  88211. */
  88212. static readonly PerformanceNoneLogLevel: number;
  88213. /**
  88214. * Use user marks to log performance
  88215. */
  88216. static readonly PerformanceUserMarkLogLevel: number;
  88217. /**
  88218. * Log performance to the console
  88219. */
  88220. static readonly PerformanceConsoleLogLevel: number;
  88221. private static _performance;
  88222. /**
  88223. * Sets the current performance log level
  88224. */
  88225. static PerformanceLogLevel: number;
  88226. private static _StartPerformanceCounterDisabled;
  88227. private static _EndPerformanceCounterDisabled;
  88228. private static _StartUserMark;
  88229. private static _EndUserMark;
  88230. private static _StartPerformanceConsole;
  88231. private static _EndPerformanceConsole;
  88232. /**
  88233. * Injects the @see CustomRequestHeaders into the given request
  88234. * @param request the request that should be used for injection
  88235. */
  88236. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  88237. /**
  88238. * Starts a performance counter
  88239. */
  88240. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88241. /**
  88242. * Ends a specific performance coutner
  88243. */
  88244. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88245. /**
  88246. * Gets either window.performance.now() if supported or Date.now() else
  88247. */
  88248. static readonly Now: number;
  88249. /**
  88250. * This method will return the name of the class used to create the instance of the given object.
  88251. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88252. * @param object the object to get the class name from
  88253. * @param isType defines if the object is actually a type
  88254. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88255. */
  88256. static GetClassName(object: any, isType?: boolean): string;
  88257. /**
  88258. * Gets the first element of an array satisfying a given predicate
  88259. * @param array defines the array to browse
  88260. * @param predicate defines the predicate to use
  88261. * @returns null if not found or the element
  88262. */
  88263. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88264. /**
  88265. * This method will return the name of the full name of the class, including its owning module (if any).
  88266. * 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).
  88267. * @param object the object to get the class name from
  88268. * @param isType defines if the object is actually a type
  88269. * @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.
  88270. * @ignorenaming
  88271. */
  88272. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88273. /**
  88274. * Returns a promise that resolves after the given amount of time.
  88275. * @param delay Number of milliseconds to delay
  88276. * @returns Promise that resolves after the given amount of time
  88277. */
  88278. static DelayAsync(delay: number): Promise<void>;
  88279. /**
  88280. * Gets the current gradient from an array of IValueGradient
  88281. * @param ratio defines the current ratio to get
  88282. * @param gradients defines the array of IValueGradient
  88283. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88284. */
  88285. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88286. }
  88287. /**
  88288. * This class is used to track a performance counter which is number based.
  88289. * The user has access to many properties which give statistics of different nature.
  88290. *
  88291. * The implementer can track two kinds of Performance Counter: time and count.
  88292. * 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.
  88293. * 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.
  88294. */
  88295. export class PerfCounter {
  88296. /**
  88297. * Gets or sets a global boolean to turn on and off all the counters
  88298. */
  88299. static Enabled: boolean;
  88300. /**
  88301. * Returns the smallest value ever
  88302. */
  88303. readonly min: number;
  88304. /**
  88305. * Returns the biggest value ever
  88306. */
  88307. readonly max: number;
  88308. /**
  88309. * Returns the average value since the performance counter is running
  88310. */
  88311. readonly average: number;
  88312. /**
  88313. * Returns the average value of the last second the counter was monitored
  88314. */
  88315. readonly lastSecAverage: number;
  88316. /**
  88317. * Returns the current value
  88318. */
  88319. readonly current: number;
  88320. /**
  88321. * Gets the accumulated total
  88322. */
  88323. readonly total: number;
  88324. /**
  88325. * Gets the total value count
  88326. */
  88327. readonly count: number;
  88328. /**
  88329. * Creates a new counter
  88330. */
  88331. constructor();
  88332. /**
  88333. * Call this method to start monitoring a new frame.
  88334. * 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.
  88335. */
  88336. fetchNewFrame(): void;
  88337. /**
  88338. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88339. * @param newCount the count value to add to the monitored count
  88340. * @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.
  88341. */
  88342. addCount(newCount: number, fetchResult: boolean): void;
  88343. /**
  88344. * Start monitoring this performance counter
  88345. */
  88346. beginMonitoring(): void;
  88347. /**
  88348. * Compute the time lapsed since the previous beginMonitoring() call.
  88349. * @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
  88350. */
  88351. endMonitoring(newFrame?: boolean): void;
  88352. private _fetchResult;
  88353. private _startMonitoringTime;
  88354. private _min;
  88355. private _max;
  88356. private _average;
  88357. private _current;
  88358. private _totalValueCount;
  88359. private _totalAccumulated;
  88360. private _lastSecAverage;
  88361. private _lastSecAccumulated;
  88362. private _lastSecTime;
  88363. private _lastSecValueCount;
  88364. }
  88365. /**
  88366. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88367. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88368. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88369. * @param name The name of the class, case should be preserved
  88370. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88371. */
  88372. export function className(name: string, module?: string): (target: Object) => void;
  88373. /**
  88374. * An implementation of a loop for asynchronous functions.
  88375. */
  88376. export class AsyncLoop {
  88377. /**
  88378. * Defines the number of iterations for the loop
  88379. */
  88380. iterations: number;
  88381. /**
  88382. * Defines the current index of the loop.
  88383. */
  88384. index: number;
  88385. private _done;
  88386. private _fn;
  88387. private _successCallback;
  88388. /**
  88389. * Constructor.
  88390. * @param iterations the number of iterations.
  88391. * @param func the function to run each iteration
  88392. * @param successCallback the callback that will be called upon succesful execution
  88393. * @param offset starting offset.
  88394. */
  88395. constructor(
  88396. /**
  88397. * Defines the number of iterations for the loop
  88398. */
  88399. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88400. /**
  88401. * Execute the next iteration. Must be called after the last iteration was finished.
  88402. */
  88403. executeNext(): void;
  88404. /**
  88405. * Break the loop and run the success callback.
  88406. */
  88407. breakLoop(): void;
  88408. /**
  88409. * Create and run an async loop.
  88410. * @param iterations the number of iterations.
  88411. * @param fn the function to run each iteration
  88412. * @param successCallback the callback that will be called upon succesful execution
  88413. * @param offset starting offset.
  88414. * @returns the created async loop object
  88415. */
  88416. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88417. /**
  88418. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88419. * @param iterations total number of iterations
  88420. * @param syncedIterations number of synchronous iterations in each async iteration.
  88421. * @param fn the function to call each iteration.
  88422. * @param callback a success call back that will be called when iterating stops.
  88423. * @param breakFunction a break condition (optional)
  88424. * @param timeout timeout settings for the setTimeout function. default - 0.
  88425. * @returns the created async loop object
  88426. */
  88427. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88428. }
  88429. }
  88430. declare module BABYLON {
  88431. /** @hidden */
  88432. export interface ICollisionCoordinator {
  88433. createCollider(): Collider;
  88434. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88435. init(scene: Scene): void;
  88436. }
  88437. /** @hidden */
  88438. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88439. private _scene;
  88440. private _scaledPosition;
  88441. private _scaledVelocity;
  88442. private _finalPosition;
  88443. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88444. createCollider(): Collider;
  88445. init(scene: Scene): void;
  88446. private _collideWithWorld;
  88447. }
  88448. }
  88449. declare module BABYLON {
  88450. /**
  88451. * This class defines the direct association between an animation and a target
  88452. */
  88453. export class TargetedAnimation {
  88454. /**
  88455. * Animation to perform
  88456. */
  88457. animation: Animation;
  88458. /**
  88459. * Target to animate
  88460. */
  88461. target: any;
  88462. }
  88463. /**
  88464. * Use this class to create coordinated animations on multiple targets
  88465. */
  88466. export class AnimationGroup implements IDisposable {
  88467. /** The name of the animation group */
  88468. name: string;
  88469. private _scene;
  88470. private _targetedAnimations;
  88471. private _animatables;
  88472. private _from;
  88473. private _to;
  88474. private _isStarted;
  88475. private _isPaused;
  88476. private _speedRatio;
  88477. /**
  88478. * Gets or sets the unique id of the node
  88479. */
  88480. uniqueId: number;
  88481. /**
  88482. * This observable will notify when one animation have ended
  88483. */
  88484. onAnimationEndObservable: Observable<TargetedAnimation>;
  88485. /**
  88486. * Observer raised when one animation loops
  88487. */
  88488. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88489. /**
  88490. * This observable will notify when all animations have ended.
  88491. */
  88492. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88493. /**
  88494. * This observable will notify when all animations have paused.
  88495. */
  88496. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88497. /**
  88498. * This observable will notify when all animations are playing.
  88499. */
  88500. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88501. /**
  88502. * Gets the first frame
  88503. */
  88504. readonly from: number;
  88505. /**
  88506. * Gets the last frame
  88507. */
  88508. readonly to: number;
  88509. /**
  88510. * Define if the animations are started
  88511. */
  88512. readonly isStarted: boolean;
  88513. /**
  88514. * Gets a value indicating that the current group is playing
  88515. */
  88516. readonly isPlaying: boolean;
  88517. /**
  88518. * Gets or sets the speed ratio to use for all animations
  88519. */
  88520. /**
  88521. * Gets or sets the speed ratio to use for all animations
  88522. */
  88523. speedRatio: number;
  88524. /**
  88525. * Gets the targeted animations for this animation group
  88526. */
  88527. readonly targetedAnimations: Array<TargetedAnimation>;
  88528. /**
  88529. * returning the list of animatables controlled by this animation group.
  88530. */
  88531. readonly animatables: Array<Animatable>;
  88532. /**
  88533. * Instantiates a new Animation Group.
  88534. * This helps managing several animations at once.
  88535. * @see http://doc.babylonjs.com/how_to/group
  88536. * @param name Defines the name of the group
  88537. * @param scene Defines the scene the group belongs to
  88538. */
  88539. constructor(
  88540. /** The name of the animation group */
  88541. name: string, scene?: Nullable<Scene>);
  88542. /**
  88543. * Add an animation (with its target) in the group
  88544. * @param animation defines the animation we want to add
  88545. * @param target defines the target of the animation
  88546. * @returns the TargetedAnimation object
  88547. */
  88548. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88549. /**
  88550. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88551. * It can add constant keys at begin or end
  88552. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88553. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88554. * @returns the animation group
  88555. */
  88556. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88557. /**
  88558. * Start all animations on given targets
  88559. * @param loop defines if animations must loop
  88560. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88561. * @param from defines the from key (optional)
  88562. * @param to defines the to key (optional)
  88563. * @returns the current animation group
  88564. */
  88565. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88566. /**
  88567. * Pause all animations
  88568. * @returns the animation group
  88569. */
  88570. pause(): AnimationGroup;
  88571. /**
  88572. * Play all animations to initial state
  88573. * This function will start() the animations if they were not started or will restart() them if they were paused
  88574. * @param loop defines if animations must loop
  88575. * @returns the animation group
  88576. */
  88577. play(loop?: boolean): AnimationGroup;
  88578. /**
  88579. * Reset all animations to initial state
  88580. * @returns the animation group
  88581. */
  88582. reset(): AnimationGroup;
  88583. /**
  88584. * Restart animations from key 0
  88585. * @returns the animation group
  88586. */
  88587. restart(): AnimationGroup;
  88588. /**
  88589. * Stop all animations
  88590. * @returns the animation group
  88591. */
  88592. stop(): AnimationGroup;
  88593. /**
  88594. * Set animation weight for all animatables
  88595. * @param weight defines the weight to use
  88596. * @return the animationGroup
  88597. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88598. */
  88599. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88600. /**
  88601. * Synchronize and normalize all animatables with a source animatable
  88602. * @param root defines the root animatable to synchronize with
  88603. * @return the animationGroup
  88604. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88605. */
  88606. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88607. /**
  88608. * Goes to a specific frame in this animation group
  88609. * @param frame the frame number to go to
  88610. * @return the animationGroup
  88611. */
  88612. goToFrame(frame: number): AnimationGroup;
  88613. /**
  88614. * Dispose all associated resources
  88615. */
  88616. dispose(): void;
  88617. private _checkAnimationGroupEnded;
  88618. /**
  88619. * Clone the current animation group and returns a copy
  88620. * @param newName defines the name of the new group
  88621. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88622. * @returns the new aniamtion group
  88623. */
  88624. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88625. /**
  88626. * Returns a new AnimationGroup object parsed from the source provided.
  88627. * @param parsedAnimationGroup defines the source
  88628. * @param scene defines the scene that will receive the animationGroup
  88629. * @returns a new AnimationGroup
  88630. */
  88631. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88632. /**
  88633. * Returns the string "AnimationGroup"
  88634. * @returns "AnimationGroup"
  88635. */
  88636. getClassName(): string;
  88637. /**
  88638. * Creates a detailled string about the object
  88639. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88640. * @returns a string representing the object
  88641. */
  88642. toString(fullDetails?: boolean): string;
  88643. }
  88644. }
  88645. declare module BABYLON {
  88646. /**
  88647. * Define an interface for all classes that will hold resources
  88648. */
  88649. export interface IDisposable {
  88650. /**
  88651. * Releases all held resources
  88652. */
  88653. dispose(): void;
  88654. }
  88655. /** Interface defining initialization parameters for Scene class */
  88656. export interface SceneOptions {
  88657. /**
  88658. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88659. * It will improve performance when the number of geometries becomes important.
  88660. */
  88661. useGeometryUniqueIdsMap?: boolean;
  88662. /**
  88663. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88664. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88665. */
  88666. useMaterialMeshMap?: boolean;
  88667. /**
  88668. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88669. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88670. */
  88671. useClonedMeshhMap?: boolean;
  88672. }
  88673. /**
  88674. * Represents a scene to be rendered by the engine.
  88675. * @see http://doc.babylonjs.com/features/scene
  88676. */
  88677. export class Scene extends AbstractScene implements IAnimatable {
  88678. private static _uniqueIdCounter;
  88679. /** The fog is deactivated */
  88680. static readonly FOGMODE_NONE: number;
  88681. /** The fog density is following an exponential function */
  88682. static readonly FOGMODE_EXP: number;
  88683. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88684. static readonly FOGMODE_EXP2: number;
  88685. /** The fog density is following a linear function. */
  88686. static readonly FOGMODE_LINEAR: number;
  88687. /**
  88688. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88689. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88690. */
  88691. static MinDeltaTime: number;
  88692. /**
  88693. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88694. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88695. */
  88696. static MaxDeltaTime: number;
  88697. /**
  88698. * Factory used to create the default material.
  88699. * @param name The name of the material to create
  88700. * @param scene The scene to create the material for
  88701. * @returns The default material
  88702. */
  88703. static DefaultMaterialFactory(scene: Scene): Material;
  88704. /**
  88705. * Factory used to create the a collision coordinator.
  88706. * @returns The collision coordinator
  88707. */
  88708. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88709. /** @hidden */
  88710. readonly _isScene: boolean;
  88711. /**
  88712. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88713. */
  88714. autoClear: boolean;
  88715. /**
  88716. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88717. */
  88718. autoClearDepthAndStencil: boolean;
  88719. /**
  88720. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88721. */
  88722. clearColor: Color4;
  88723. /**
  88724. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88725. */
  88726. ambientColor: Color3;
  88727. /** @hidden */
  88728. _environmentBRDFTexture: BaseTexture;
  88729. /** @hidden */
  88730. protected _environmentTexture: Nullable<BaseTexture>;
  88731. /**
  88732. * Texture used in all pbr material as the reflection texture.
  88733. * As in the majority of the scene they are the same (exception for multi room and so on),
  88734. * this is easier to reference from here than from all the materials.
  88735. */
  88736. /**
  88737. * Texture used in all pbr material as the reflection texture.
  88738. * As in the majority of the scene they are the same (exception for multi room and so on),
  88739. * this is easier to set here than in all the materials.
  88740. */
  88741. environmentTexture: Nullable<BaseTexture>;
  88742. /** @hidden */
  88743. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88744. /**
  88745. * Default image processing configuration used either in the rendering
  88746. * Forward main pass or through the imageProcessingPostProcess if present.
  88747. * As in the majority of the scene they are the same (exception for multi camera),
  88748. * this is easier to reference from here than from all the materials and post process.
  88749. *
  88750. * No setter as we it is a shared configuration, you can set the values instead.
  88751. */
  88752. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88753. private _forceWireframe;
  88754. /**
  88755. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88756. */
  88757. forceWireframe: boolean;
  88758. private _forcePointsCloud;
  88759. /**
  88760. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88761. */
  88762. forcePointsCloud: boolean;
  88763. /**
  88764. * Gets or sets the active clipplane 1
  88765. */
  88766. clipPlane: Nullable<Plane>;
  88767. /**
  88768. * Gets or sets the active clipplane 2
  88769. */
  88770. clipPlane2: Nullable<Plane>;
  88771. /**
  88772. * Gets or sets the active clipplane 3
  88773. */
  88774. clipPlane3: Nullable<Plane>;
  88775. /**
  88776. * Gets or sets the active clipplane 4
  88777. */
  88778. clipPlane4: Nullable<Plane>;
  88779. /**
  88780. * Gets or sets a boolean indicating if animations are enabled
  88781. */
  88782. animationsEnabled: boolean;
  88783. private _animationPropertiesOverride;
  88784. /**
  88785. * Gets or sets the animation properties override
  88786. */
  88787. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88788. /**
  88789. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88790. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88791. */
  88792. useConstantAnimationDeltaTime: boolean;
  88793. /**
  88794. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88795. * Please note that it requires to run a ray cast through the scene on every frame
  88796. */
  88797. constantlyUpdateMeshUnderPointer: boolean;
  88798. /**
  88799. * Defines the HTML cursor to use when hovering over interactive elements
  88800. */
  88801. hoverCursor: string;
  88802. /**
  88803. * Defines the HTML default cursor to use (empty by default)
  88804. */
  88805. defaultCursor: string;
  88806. /**
  88807. * This is used to call preventDefault() on pointer down
  88808. * in order to block unwanted artifacts like system double clicks
  88809. */
  88810. preventDefaultOnPointerDown: boolean;
  88811. /**
  88812. * This is used to call preventDefault() on pointer up
  88813. * in order to block unwanted artifacts like system double clicks
  88814. */
  88815. preventDefaultOnPointerUp: boolean;
  88816. /**
  88817. * Gets or sets user defined metadata
  88818. */
  88819. metadata: any;
  88820. /**
  88821. * For internal use only. Please do not use.
  88822. */
  88823. reservedDataStore: any;
  88824. /**
  88825. * Gets the name of the plugin used to load this scene (null by default)
  88826. */
  88827. loadingPluginName: string;
  88828. /**
  88829. * Use this array to add regular expressions used to disable offline support for specific urls
  88830. */
  88831. disableOfflineSupportExceptionRules: RegExp[];
  88832. /**
  88833. * An event triggered when the scene is disposed.
  88834. */
  88835. onDisposeObservable: Observable<Scene>;
  88836. private _onDisposeObserver;
  88837. /** Sets a function to be executed when this scene is disposed. */
  88838. onDispose: () => void;
  88839. /**
  88840. * An event triggered before rendering the scene (right after animations and physics)
  88841. */
  88842. onBeforeRenderObservable: Observable<Scene>;
  88843. private _onBeforeRenderObserver;
  88844. /** Sets a function to be executed before rendering this scene */
  88845. beforeRender: Nullable<() => void>;
  88846. /**
  88847. * An event triggered after rendering the scene
  88848. */
  88849. onAfterRenderObservable: Observable<Scene>;
  88850. private _onAfterRenderObserver;
  88851. /** Sets a function to be executed after rendering this scene */
  88852. afterRender: Nullable<() => void>;
  88853. /**
  88854. * An event triggered before animating the scene
  88855. */
  88856. onBeforeAnimationsObservable: Observable<Scene>;
  88857. /**
  88858. * An event triggered after animations processing
  88859. */
  88860. onAfterAnimationsObservable: Observable<Scene>;
  88861. /**
  88862. * An event triggered before draw calls are ready to be sent
  88863. */
  88864. onBeforeDrawPhaseObservable: Observable<Scene>;
  88865. /**
  88866. * An event triggered after draw calls have been sent
  88867. */
  88868. onAfterDrawPhaseObservable: Observable<Scene>;
  88869. /**
  88870. * An event triggered when the scene is ready
  88871. */
  88872. onReadyObservable: Observable<Scene>;
  88873. /**
  88874. * An event triggered before rendering a camera
  88875. */
  88876. onBeforeCameraRenderObservable: Observable<Camera>;
  88877. private _onBeforeCameraRenderObserver;
  88878. /** Sets a function to be executed before rendering a camera*/
  88879. beforeCameraRender: () => void;
  88880. /**
  88881. * An event triggered after rendering a camera
  88882. */
  88883. onAfterCameraRenderObservable: Observable<Camera>;
  88884. private _onAfterCameraRenderObserver;
  88885. /** Sets a function to be executed after rendering a camera*/
  88886. afterCameraRender: () => void;
  88887. /**
  88888. * An event triggered when active meshes evaluation is about to start
  88889. */
  88890. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88891. /**
  88892. * An event triggered when active meshes evaluation is done
  88893. */
  88894. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88895. /**
  88896. * An event triggered when particles rendering is about to start
  88897. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88898. */
  88899. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88900. /**
  88901. * An event triggered when particles rendering is done
  88902. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88903. */
  88904. onAfterParticlesRenderingObservable: Observable<Scene>;
  88905. /**
  88906. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88907. */
  88908. onDataLoadedObservable: Observable<Scene>;
  88909. /**
  88910. * An event triggered when a camera is created
  88911. */
  88912. onNewCameraAddedObservable: Observable<Camera>;
  88913. /**
  88914. * An event triggered when a camera is removed
  88915. */
  88916. onCameraRemovedObservable: Observable<Camera>;
  88917. /**
  88918. * An event triggered when a light is created
  88919. */
  88920. onNewLightAddedObservable: Observable<Light>;
  88921. /**
  88922. * An event triggered when a light is removed
  88923. */
  88924. onLightRemovedObservable: Observable<Light>;
  88925. /**
  88926. * An event triggered when a geometry is created
  88927. */
  88928. onNewGeometryAddedObservable: Observable<Geometry>;
  88929. /**
  88930. * An event triggered when a geometry is removed
  88931. */
  88932. onGeometryRemovedObservable: Observable<Geometry>;
  88933. /**
  88934. * An event triggered when a transform node is created
  88935. */
  88936. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88937. /**
  88938. * An event triggered when a transform node is removed
  88939. */
  88940. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88941. /**
  88942. * An event triggered when a mesh is created
  88943. */
  88944. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88945. /**
  88946. * An event triggered when a mesh is removed
  88947. */
  88948. onMeshRemovedObservable: Observable<AbstractMesh>;
  88949. /**
  88950. * An event triggered when a material is created
  88951. */
  88952. onNewMaterialAddedObservable: Observable<Material>;
  88953. /**
  88954. * An event triggered when a material is removed
  88955. */
  88956. onMaterialRemovedObservable: Observable<Material>;
  88957. /**
  88958. * An event triggered when a texture is created
  88959. */
  88960. onNewTextureAddedObservable: Observable<BaseTexture>;
  88961. /**
  88962. * An event triggered when a texture is removed
  88963. */
  88964. onTextureRemovedObservable: Observable<BaseTexture>;
  88965. /**
  88966. * An event triggered when render targets are about to be rendered
  88967. * Can happen multiple times per frame.
  88968. */
  88969. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88970. /**
  88971. * An event triggered when render targets were rendered.
  88972. * Can happen multiple times per frame.
  88973. */
  88974. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88975. /**
  88976. * An event triggered before calculating deterministic simulation step
  88977. */
  88978. onBeforeStepObservable: Observable<Scene>;
  88979. /**
  88980. * An event triggered after calculating deterministic simulation step
  88981. */
  88982. onAfterStepObservable: Observable<Scene>;
  88983. /**
  88984. * An event triggered when the activeCamera property is updated
  88985. */
  88986. onActiveCameraChanged: Observable<Scene>;
  88987. /**
  88988. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88989. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88990. * 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)
  88991. */
  88992. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88993. /**
  88994. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88995. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88996. * 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)
  88997. */
  88998. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88999. /**
  89000. * This Observable will when a mesh has been imported into the scene.
  89001. */
  89002. onMeshImportedObservable: Observable<AbstractMesh>;
  89003. /**
  89004. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  89005. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  89006. */
  89007. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  89008. /** @hidden */
  89009. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  89010. /**
  89011. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  89012. */
  89013. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  89014. /**
  89015. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  89016. */
  89017. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  89018. /**
  89019. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89020. */
  89021. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89022. private _onPointerMove;
  89023. private _onPointerDown;
  89024. private _onPointerUp;
  89025. /** Callback called when a pointer move is detected */
  89026. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89027. /** Callback called when a pointer down is detected */
  89028. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89029. /** Callback called when a pointer up is detected */
  89030. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89031. /** Callback called when a pointer pick is detected */
  89032. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89033. /**
  89034. * 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).
  89035. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89036. */
  89037. onPrePointerObservable: Observable<PointerInfoPre>;
  89038. /**
  89039. * Observable event triggered each time an input event is received from the rendering canvas
  89040. */
  89041. onPointerObservable: Observable<PointerInfo>;
  89042. /**
  89043. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89044. */
  89045. readonly unTranslatedPointer: Vector2;
  89046. /** The distance in pixel that you have to move to prevent some events */
  89047. static DragMovementThreshold: number;
  89048. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89049. static LongPressDelay: number;
  89050. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89051. static DoubleClickDelay: number;
  89052. /** If you need to check double click without raising a single click at first click, enable this flag */
  89053. static ExclusiveDoubleClickMode: boolean;
  89054. private _initClickEvent;
  89055. private _initActionManager;
  89056. private _delayedSimpleClick;
  89057. private _delayedSimpleClickTimeout;
  89058. private _previousDelayedSimpleClickTimeout;
  89059. private _meshPickProceed;
  89060. private _previousButtonPressed;
  89061. private _currentPickResult;
  89062. private _previousPickResult;
  89063. private _totalPointersPressed;
  89064. private _doubleClickOccured;
  89065. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89066. cameraToUseForPointers: Nullable<Camera>;
  89067. private _pointerX;
  89068. private _pointerY;
  89069. private _unTranslatedPointerX;
  89070. private _unTranslatedPointerY;
  89071. private _startingPointerPosition;
  89072. private _previousStartingPointerPosition;
  89073. private _startingPointerTime;
  89074. private _previousStartingPointerTime;
  89075. private _pointerCaptures;
  89076. private _timeAccumulator;
  89077. private _currentStepId;
  89078. private _currentInternalStep;
  89079. /** @hidden */
  89080. _mirroredCameraPosition: Nullable<Vector3>;
  89081. /**
  89082. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89083. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89084. */
  89085. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89086. /**
  89087. * Observable event triggered each time an keyboard event is received from the hosting window
  89088. */
  89089. onKeyboardObservable: Observable<KeyboardInfo>;
  89090. private _onKeyDown;
  89091. private _onKeyUp;
  89092. private _onCanvasFocusObserver;
  89093. private _onCanvasBlurObserver;
  89094. private _useRightHandedSystem;
  89095. /**
  89096. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89097. */
  89098. useRightHandedSystem: boolean;
  89099. /**
  89100. * Sets the step Id used by deterministic lock step
  89101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89102. * @param newStepId defines the step Id
  89103. */
  89104. setStepId(newStepId: number): void;
  89105. /**
  89106. * Gets the step Id used by deterministic lock step
  89107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89108. * @returns the step Id
  89109. */
  89110. getStepId(): number;
  89111. /**
  89112. * Gets the internal step used by deterministic lock step
  89113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89114. * @returns the internal step
  89115. */
  89116. getInternalStep(): number;
  89117. private _fogEnabled;
  89118. /**
  89119. * Gets or sets a boolean indicating if fog is enabled on this scene
  89120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89121. * (Default is true)
  89122. */
  89123. fogEnabled: boolean;
  89124. private _fogMode;
  89125. /**
  89126. * Gets or sets the fog mode to use
  89127. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89128. * | mode | value |
  89129. * | --- | --- |
  89130. * | FOGMODE_NONE | 0 |
  89131. * | FOGMODE_EXP | 1 |
  89132. * | FOGMODE_EXP2 | 2 |
  89133. * | FOGMODE_LINEAR | 3 |
  89134. */
  89135. fogMode: number;
  89136. /**
  89137. * Gets or sets the fog color to use
  89138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89139. * (Default is Color3(0.2, 0.2, 0.3))
  89140. */
  89141. fogColor: Color3;
  89142. /**
  89143. * Gets or sets the fog density to use
  89144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89145. * (Default is 0.1)
  89146. */
  89147. fogDensity: number;
  89148. /**
  89149. * Gets or sets the fog start distance to use
  89150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89151. * (Default is 0)
  89152. */
  89153. fogStart: number;
  89154. /**
  89155. * Gets or sets the fog end distance to use
  89156. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89157. * (Default is 1000)
  89158. */
  89159. fogEnd: number;
  89160. private _shadowsEnabled;
  89161. /**
  89162. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89163. */
  89164. shadowsEnabled: boolean;
  89165. private _lightsEnabled;
  89166. /**
  89167. * Gets or sets a boolean indicating if lights are enabled on this scene
  89168. */
  89169. lightsEnabled: boolean;
  89170. /** All of the active cameras added to this scene. */
  89171. activeCameras: Camera[];
  89172. private _activeCamera;
  89173. /** Gets or sets the current active camera */
  89174. activeCamera: Nullable<Camera>;
  89175. private _defaultMaterial;
  89176. /** The default material used on meshes when no material is affected */
  89177. /** The default material used on meshes when no material is affected */
  89178. defaultMaterial: Material;
  89179. private _texturesEnabled;
  89180. /**
  89181. * Gets or sets a boolean indicating if textures are enabled on this scene
  89182. */
  89183. texturesEnabled: boolean;
  89184. /**
  89185. * Gets or sets a boolean indicating if particles are enabled on this scene
  89186. */
  89187. particlesEnabled: boolean;
  89188. /**
  89189. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89190. */
  89191. spritesEnabled: boolean;
  89192. private _skeletonsEnabled;
  89193. /**
  89194. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89195. */
  89196. skeletonsEnabled: boolean;
  89197. /**
  89198. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89199. */
  89200. lensFlaresEnabled: boolean;
  89201. /**
  89202. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89203. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89204. */
  89205. collisionsEnabled: boolean;
  89206. private _collisionCoordinator;
  89207. /** @hidden */
  89208. readonly collisionCoordinator: ICollisionCoordinator;
  89209. /**
  89210. * Defines the gravity applied to this scene (used only for collisions)
  89211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89212. */
  89213. gravity: Vector3;
  89214. /**
  89215. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89216. */
  89217. postProcessesEnabled: boolean;
  89218. /**
  89219. * The list of postprocesses added to the scene
  89220. */
  89221. postProcesses: PostProcess[];
  89222. /**
  89223. * Gets the current postprocess manager
  89224. */
  89225. postProcessManager: PostProcessManager;
  89226. /**
  89227. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89228. */
  89229. renderTargetsEnabled: boolean;
  89230. /**
  89231. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89232. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89233. */
  89234. dumpNextRenderTargets: boolean;
  89235. /**
  89236. * The list of user defined render targets added to the scene
  89237. */
  89238. customRenderTargets: RenderTargetTexture[];
  89239. /**
  89240. * Defines if texture loading must be delayed
  89241. * If true, textures will only be loaded when they need to be rendered
  89242. */
  89243. useDelayedTextureLoading: boolean;
  89244. /**
  89245. * Gets the list of meshes imported to the scene through SceneLoader
  89246. */
  89247. importedMeshesFiles: String[];
  89248. /**
  89249. * Gets or sets a boolean indicating if probes are enabled on this scene
  89250. */
  89251. probesEnabled: boolean;
  89252. /**
  89253. * Gets or sets the current offline provider to use to store scene data
  89254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89255. */
  89256. offlineProvider: IOfflineProvider;
  89257. /**
  89258. * Gets or sets the action manager associated with the scene
  89259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89260. */
  89261. actionManager: AbstractActionManager;
  89262. private _meshesForIntersections;
  89263. /**
  89264. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89265. */
  89266. proceduralTexturesEnabled: boolean;
  89267. private _engine;
  89268. private _totalVertices;
  89269. /** @hidden */
  89270. _activeIndices: PerfCounter;
  89271. /** @hidden */
  89272. _activeParticles: PerfCounter;
  89273. /** @hidden */
  89274. _activeBones: PerfCounter;
  89275. private _animationRatio;
  89276. /** @hidden */
  89277. _animationTimeLast: number;
  89278. /** @hidden */
  89279. _animationTime: number;
  89280. /**
  89281. * Gets or sets a general scale for animation speed
  89282. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89283. */
  89284. animationTimeScale: number;
  89285. /** @hidden */
  89286. _cachedMaterial: Nullable<Material>;
  89287. /** @hidden */
  89288. _cachedEffect: Nullable<Effect>;
  89289. /** @hidden */
  89290. _cachedVisibility: Nullable<number>;
  89291. private _renderId;
  89292. private _frameId;
  89293. private _executeWhenReadyTimeoutId;
  89294. private _intermediateRendering;
  89295. private _viewUpdateFlag;
  89296. private _projectionUpdateFlag;
  89297. private _alternateViewUpdateFlag;
  89298. private _alternateProjectionUpdateFlag;
  89299. /** @hidden */
  89300. _toBeDisposed: Nullable<IDisposable>[];
  89301. private _activeRequests;
  89302. /** @hidden */
  89303. _pendingData: any[];
  89304. private _isDisposed;
  89305. /**
  89306. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89307. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89308. */
  89309. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89310. private _activeMeshes;
  89311. private _processedMaterials;
  89312. private _renderTargets;
  89313. /** @hidden */
  89314. _activeParticleSystems: SmartArray<IParticleSystem>;
  89315. private _activeSkeletons;
  89316. private _softwareSkinnedMeshes;
  89317. private _renderingManager;
  89318. /** @hidden */
  89319. _activeAnimatables: Animatable[];
  89320. private _transformMatrix;
  89321. private _sceneUbo;
  89322. private _alternateSceneUbo;
  89323. private _viewMatrix;
  89324. private _projectionMatrix;
  89325. private _alternateViewMatrix;
  89326. private _alternateProjectionMatrix;
  89327. private _alternateTransformMatrix;
  89328. private _useAlternateCameraConfiguration;
  89329. private _alternateRendering;
  89330. private _wheelEventName;
  89331. /** @hidden */
  89332. _forcedViewPosition: Nullable<Vector3>;
  89333. /** @hidden */
  89334. readonly _isAlternateRenderingEnabled: boolean;
  89335. private _frustumPlanes;
  89336. /**
  89337. * Gets the list of frustum planes (built from the active camera)
  89338. */
  89339. readonly frustumPlanes: Plane[];
  89340. /**
  89341. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89342. * This is useful if there are more lights that the maximum simulteanous authorized
  89343. */
  89344. requireLightSorting: boolean;
  89345. /** @hidden */
  89346. readonly useMaterialMeshMap: boolean;
  89347. /** @hidden */
  89348. readonly useClonedMeshhMap: boolean;
  89349. private _pointerOverMesh;
  89350. private _pickedDownMesh;
  89351. private _pickedUpMesh;
  89352. private _externalData;
  89353. private _uid;
  89354. /**
  89355. * @hidden
  89356. * Backing store of defined scene components.
  89357. */
  89358. _components: ISceneComponent[];
  89359. /**
  89360. * @hidden
  89361. * Backing store of defined scene components.
  89362. */
  89363. _serializableComponents: ISceneSerializableComponent[];
  89364. /**
  89365. * List of components to register on the next registration step.
  89366. */
  89367. private _transientComponents;
  89368. /**
  89369. * Registers the transient components if needed.
  89370. */
  89371. private _registerTransientComponents;
  89372. /**
  89373. * @hidden
  89374. * Add a component to the scene.
  89375. * Note that the ccomponent could be registered on th next frame if this is called after
  89376. * the register component stage.
  89377. * @param component Defines the component to add to the scene
  89378. */
  89379. _addComponent(component: ISceneComponent): void;
  89380. /**
  89381. * @hidden
  89382. * Gets a component from the scene.
  89383. * @param name defines the name of the component to retrieve
  89384. * @returns the component or null if not present
  89385. */
  89386. _getComponent(name: string): Nullable<ISceneComponent>;
  89387. /**
  89388. * @hidden
  89389. * Defines the actions happening before camera updates.
  89390. */
  89391. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89392. /**
  89393. * @hidden
  89394. * Defines the actions happening before clear the canvas.
  89395. */
  89396. _beforeClearStage: Stage<SimpleStageAction>;
  89397. /**
  89398. * @hidden
  89399. * Defines the actions when collecting render targets for the frame.
  89400. */
  89401. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89402. /**
  89403. * @hidden
  89404. * Defines the actions happening for one camera in the frame.
  89405. */
  89406. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89407. /**
  89408. * @hidden
  89409. * Defines the actions happening during the per mesh ready checks.
  89410. */
  89411. _isReadyForMeshStage: Stage<MeshStageAction>;
  89412. /**
  89413. * @hidden
  89414. * Defines the actions happening before evaluate active mesh checks.
  89415. */
  89416. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89417. /**
  89418. * @hidden
  89419. * Defines the actions happening during the evaluate sub mesh checks.
  89420. */
  89421. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89422. /**
  89423. * @hidden
  89424. * Defines the actions happening during the active mesh stage.
  89425. */
  89426. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89427. /**
  89428. * @hidden
  89429. * Defines the actions happening during the per camera render target step.
  89430. */
  89431. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89432. /**
  89433. * @hidden
  89434. * Defines the actions happening just before the active camera is drawing.
  89435. */
  89436. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89437. /**
  89438. * @hidden
  89439. * Defines the actions happening just before a render target is drawing.
  89440. */
  89441. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89442. /**
  89443. * @hidden
  89444. * Defines the actions happening just before a rendering group is drawing.
  89445. */
  89446. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89447. /**
  89448. * @hidden
  89449. * Defines the actions happening just before a mesh is drawing.
  89450. */
  89451. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89452. /**
  89453. * @hidden
  89454. * Defines the actions happening just after a mesh has been drawn.
  89455. */
  89456. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89457. /**
  89458. * @hidden
  89459. * Defines the actions happening just after a rendering group has been drawn.
  89460. */
  89461. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89462. /**
  89463. * @hidden
  89464. * Defines the actions happening just after the active camera has been drawn.
  89465. */
  89466. _afterCameraDrawStage: Stage<CameraStageAction>;
  89467. /**
  89468. * @hidden
  89469. * Defines the actions happening just after a render target has been drawn.
  89470. */
  89471. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89472. /**
  89473. * @hidden
  89474. * Defines the actions happening just after rendering all cameras and computing intersections.
  89475. */
  89476. _afterRenderStage: Stage<SimpleStageAction>;
  89477. /**
  89478. * @hidden
  89479. * Defines the actions happening when a pointer move event happens.
  89480. */
  89481. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89482. /**
  89483. * @hidden
  89484. * Defines the actions happening when a pointer down event happens.
  89485. */
  89486. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89487. /**
  89488. * @hidden
  89489. * Defines the actions happening when a pointer up event happens.
  89490. */
  89491. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89492. /**
  89493. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89494. */
  89495. private geometriesByUniqueId;
  89496. /**
  89497. * Creates a new Scene
  89498. * @param engine defines the engine to use to render this scene
  89499. * @param options defines the scene options
  89500. */
  89501. constructor(engine: Engine, options?: SceneOptions);
  89502. private _defaultMeshCandidates;
  89503. /**
  89504. * @hidden
  89505. */
  89506. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89507. private _defaultSubMeshCandidates;
  89508. /**
  89509. * @hidden
  89510. */
  89511. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89512. /**
  89513. * Sets the default candidate providers for the scene.
  89514. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89515. * and getCollidingSubMeshCandidates to their default function
  89516. */
  89517. setDefaultCandidateProviders(): void;
  89518. /**
  89519. * Gets the mesh that is currently under the pointer
  89520. */
  89521. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89522. /**
  89523. * Gets or sets the current on-screen X position of the pointer
  89524. */
  89525. pointerX: number;
  89526. /**
  89527. * Gets or sets the current on-screen Y position of the pointer
  89528. */
  89529. pointerY: number;
  89530. /**
  89531. * Gets the cached material (ie. the latest rendered one)
  89532. * @returns the cached material
  89533. */
  89534. getCachedMaterial(): Nullable<Material>;
  89535. /**
  89536. * Gets the cached effect (ie. the latest rendered one)
  89537. * @returns the cached effect
  89538. */
  89539. getCachedEffect(): Nullable<Effect>;
  89540. /**
  89541. * Gets the cached visibility state (ie. the latest rendered one)
  89542. * @returns the cached visibility state
  89543. */
  89544. getCachedVisibility(): Nullable<number>;
  89545. /**
  89546. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89547. * @param material defines the current material
  89548. * @param effect defines the current effect
  89549. * @param visibility defines the current visibility state
  89550. * @returns true if one parameter is not cached
  89551. */
  89552. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89553. /**
  89554. * Gets the engine associated with the scene
  89555. * @returns an Engine
  89556. */
  89557. getEngine(): Engine;
  89558. /**
  89559. * Gets the total number of vertices rendered per frame
  89560. * @returns the total number of vertices rendered per frame
  89561. */
  89562. getTotalVertices(): number;
  89563. /**
  89564. * Gets the performance counter for total vertices
  89565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89566. */
  89567. readonly totalVerticesPerfCounter: PerfCounter;
  89568. /**
  89569. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89570. * @returns the total number of active indices rendered per frame
  89571. */
  89572. getActiveIndices(): number;
  89573. /**
  89574. * Gets the performance counter for active indices
  89575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89576. */
  89577. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89578. /**
  89579. * Gets the total number of active particles rendered per frame
  89580. * @returns the total number of active particles rendered per frame
  89581. */
  89582. getActiveParticles(): number;
  89583. /**
  89584. * Gets the performance counter for active particles
  89585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89586. */
  89587. readonly activeParticlesPerfCounter: PerfCounter;
  89588. /**
  89589. * Gets the total number of active bones rendered per frame
  89590. * @returns the total number of active bones rendered per frame
  89591. */
  89592. getActiveBones(): number;
  89593. /**
  89594. * Gets the performance counter for active bones
  89595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89596. */
  89597. readonly activeBonesPerfCounter: PerfCounter;
  89598. /**
  89599. * Gets the array of active meshes
  89600. * @returns an array of AbstractMesh
  89601. */
  89602. getActiveMeshes(): SmartArray<AbstractMesh>;
  89603. /**
  89604. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89605. * @returns a number
  89606. */
  89607. getAnimationRatio(): number;
  89608. /**
  89609. * Gets an unique Id for the current render phase
  89610. * @returns a number
  89611. */
  89612. getRenderId(): number;
  89613. /**
  89614. * Gets an unique Id for the current frame
  89615. * @returns a number
  89616. */
  89617. getFrameId(): number;
  89618. /** Call this function if you want to manually increment the render Id*/
  89619. incrementRenderId(): void;
  89620. private _updatePointerPosition;
  89621. private _createUbo;
  89622. private _createAlternateUbo;
  89623. private _setRayOnPointerInfo;
  89624. /**
  89625. * Use this method to simulate a pointer move on a mesh
  89626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89629. * @returns the current scene
  89630. */
  89631. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89632. private _processPointerMove;
  89633. private _checkPrePointerObservable;
  89634. /**
  89635. * Use this method to simulate a pointer down on a mesh
  89636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89639. * @returns the current scene
  89640. */
  89641. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89642. private _processPointerDown;
  89643. /**
  89644. * Use this method to simulate a pointer up on a mesh
  89645. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89646. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89647. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89648. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89649. * @returns the current scene
  89650. */
  89651. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89652. private _processPointerUp;
  89653. /**
  89654. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89655. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89656. * @returns true if the pointer was captured
  89657. */
  89658. isPointerCaptured(pointerId?: number): boolean;
  89659. /** @hidden */
  89660. _isPointerSwiping(): boolean;
  89661. /**
  89662. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89663. * @param attachUp defines if you want to attach events to pointerup
  89664. * @param attachDown defines if you want to attach events to pointerdown
  89665. * @param attachMove defines if you want to attach events to pointermove
  89666. */
  89667. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89668. /** Detaches all event handlers*/
  89669. detachControl(): void;
  89670. /**
  89671. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89672. * Delay loaded resources are not taking in account
  89673. * @return true if all required resources are ready
  89674. */
  89675. isReady(): boolean;
  89676. /** Resets all cached information relative to material (including effect and visibility) */
  89677. resetCachedMaterial(): void;
  89678. /**
  89679. * Registers a function to be called before every frame render
  89680. * @param func defines the function to register
  89681. */
  89682. registerBeforeRender(func: () => void): void;
  89683. /**
  89684. * Unregisters a function called before every frame render
  89685. * @param func defines the function to unregister
  89686. */
  89687. unregisterBeforeRender(func: () => void): void;
  89688. /**
  89689. * Registers a function to be called after every frame render
  89690. * @param func defines the function to register
  89691. */
  89692. registerAfterRender(func: () => void): void;
  89693. /**
  89694. * Unregisters a function called after every frame render
  89695. * @param func defines the function to unregister
  89696. */
  89697. unregisterAfterRender(func: () => void): void;
  89698. private _executeOnceBeforeRender;
  89699. /**
  89700. * The provided function will run before render once and will be disposed afterwards.
  89701. * A timeout delay can be provided so that the function will be executed in N ms.
  89702. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89703. * @param func The function to be executed.
  89704. * @param timeout optional delay in ms
  89705. */
  89706. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89707. /** @hidden */
  89708. _addPendingData(data: any): void;
  89709. /** @hidden */
  89710. _removePendingData(data: any): void;
  89711. /**
  89712. * Returns the number of items waiting to be loaded
  89713. * @returns the number of items waiting to be loaded
  89714. */
  89715. getWaitingItemsCount(): number;
  89716. /**
  89717. * Returns a boolean indicating if the scene is still loading data
  89718. */
  89719. readonly isLoading: boolean;
  89720. /**
  89721. * Registers a function to be executed when the scene is ready
  89722. * @param {Function} func - the function to be executed
  89723. */
  89724. executeWhenReady(func: () => void): void;
  89725. /**
  89726. * Returns a promise that resolves when the scene is ready
  89727. * @returns A promise that resolves when the scene is ready
  89728. */
  89729. whenReadyAsync(): Promise<void>;
  89730. /** @hidden */
  89731. _checkIsReady(): void;
  89732. /**
  89733. * Gets all animatable attached to the scene
  89734. */
  89735. readonly animatables: Animatable[];
  89736. /**
  89737. * Resets the last animation time frame.
  89738. * Useful to override when animations start running when loading a scene for the first time.
  89739. */
  89740. resetLastAnimationTimeFrame(): void;
  89741. /** @hidden */
  89742. _switchToAlternateCameraConfiguration(active: boolean): void;
  89743. /**
  89744. * Gets the current view matrix
  89745. * @returns a Matrix
  89746. */
  89747. getViewMatrix(): Matrix;
  89748. /**
  89749. * Gets the current projection matrix
  89750. * @returns a Matrix
  89751. */
  89752. getProjectionMatrix(): Matrix;
  89753. /**
  89754. * Gets the current transform matrix
  89755. * @returns a Matrix made of View * Projection
  89756. */
  89757. getTransformMatrix(): Matrix;
  89758. /**
  89759. * Sets the current transform matrix
  89760. * @param view defines the View matrix to use
  89761. * @param projection defines the Projection matrix to use
  89762. */
  89763. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89764. /** @hidden */
  89765. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89766. /**
  89767. * Gets the uniform buffer used to store scene data
  89768. * @returns a UniformBuffer
  89769. */
  89770. getSceneUniformBuffer(): UniformBuffer;
  89771. /**
  89772. * Gets an unique (relatively to the current scene) Id
  89773. * @returns an unique number for the scene
  89774. */
  89775. getUniqueId(): number;
  89776. /**
  89777. * Add a mesh to the list of scene's meshes
  89778. * @param newMesh defines the mesh to add
  89779. * @param recursive if all child meshes should also be added to the scene
  89780. */
  89781. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89782. /**
  89783. * Remove a mesh for the list of scene's meshes
  89784. * @param toRemove defines the mesh to remove
  89785. * @param recursive if all child meshes should also be removed from the scene
  89786. * @returns the index where the mesh was in the mesh list
  89787. */
  89788. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89789. /**
  89790. * Add a transform node to the list of scene's transform nodes
  89791. * @param newTransformNode defines the transform node to add
  89792. */
  89793. addTransformNode(newTransformNode: TransformNode): void;
  89794. /**
  89795. * Remove a transform node for the list of scene's transform nodes
  89796. * @param toRemove defines the transform node to remove
  89797. * @returns the index where the transform node was in the transform node list
  89798. */
  89799. removeTransformNode(toRemove: TransformNode): number;
  89800. /**
  89801. * Remove a skeleton for the list of scene's skeletons
  89802. * @param toRemove defines the skeleton to remove
  89803. * @returns the index where the skeleton was in the skeleton list
  89804. */
  89805. removeSkeleton(toRemove: Skeleton): number;
  89806. /**
  89807. * Remove a morph target for the list of scene's morph targets
  89808. * @param toRemove defines the morph target to remove
  89809. * @returns the index where the morph target was in the morph target list
  89810. */
  89811. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89812. /**
  89813. * Remove a light for the list of scene's lights
  89814. * @param toRemove defines the light to remove
  89815. * @returns the index where the light was in the light list
  89816. */
  89817. removeLight(toRemove: Light): number;
  89818. /**
  89819. * Remove a camera for the list of scene's cameras
  89820. * @param toRemove defines the camera to remove
  89821. * @returns the index where the camera was in the camera list
  89822. */
  89823. removeCamera(toRemove: Camera): number;
  89824. /**
  89825. * Remove a particle system for the list of scene's particle systems
  89826. * @param toRemove defines the particle system to remove
  89827. * @returns the index where the particle system was in the particle system list
  89828. */
  89829. removeParticleSystem(toRemove: IParticleSystem): number;
  89830. /**
  89831. * Remove a animation for the list of scene's animations
  89832. * @param toRemove defines the animation to remove
  89833. * @returns the index where the animation was in the animation list
  89834. */
  89835. removeAnimation(toRemove: Animation): number;
  89836. /**
  89837. * Removes the given animation group from this scene.
  89838. * @param toRemove The animation group to remove
  89839. * @returns The index of the removed animation group
  89840. */
  89841. removeAnimationGroup(toRemove: AnimationGroup): number;
  89842. /**
  89843. * Removes the given multi-material from this scene.
  89844. * @param toRemove The multi-material to remove
  89845. * @returns The index of the removed multi-material
  89846. */
  89847. removeMultiMaterial(toRemove: MultiMaterial): number;
  89848. /**
  89849. * Removes the given material from this scene.
  89850. * @param toRemove The material to remove
  89851. * @returns The index of the removed material
  89852. */
  89853. removeMaterial(toRemove: Material): number;
  89854. /**
  89855. * Removes the given action manager from this scene.
  89856. * @param toRemove The action manager to remove
  89857. * @returns The index of the removed action manager
  89858. */
  89859. removeActionManager(toRemove: AbstractActionManager): number;
  89860. /**
  89861. * Removes the given texture from this scene.
  89862. * @param toRemove The texture to remove
  89863. * @returns The index of the removed texture
  89864. */
  89865. removeTexture(toRemove: BaseTexture): number;
  89866. /**
  89867. * Adds the given light to this scene
  89868. * @param newLight The light to add
  89869. */
  89870. addLight(newLight: Light): void;
  89871. /**
  89872. * Sorts the list list based on light priorities
  89873. */
  89874. sortLightsByPriority(): void;
  89875. /**
  89876. * Adds the given camera to this scene
  89877. * @param newCamera The camera to add
  89878. */
  89879. addCamera(newCamera: Camera): void;
  89880. /**
  89881. * Adds the given skeleton to this scene
  89882. * @param newSkeleton The skeleton to add
  89883. */
  89884. addSkeleton(newSkeleton: Skeleton): void;
  89885. /**
  89886. * Adds the given particle system to this scene
  89887. * @param newParticleSystem The particle system to add
  89888. */
  89889. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89890. /**
  89891. * Adds the given animation to this scene
  89892. * @param newAnimation The animation to add
  89893. */
  89894. addAnimation(newAnimation: Animation): void;
  89895. /**
  89896. * Adds the given animation group to this scene.
  89897. * @param newAnimationGroup The animation group to add
  89898. */
  89899. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89900. /**
  89901. * Adds the given multi-material to this scene
  89902. * @param newMultiMaterial The multi-material to add
  89903. */
  89904. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89905. /**
  89906. * Adds the given material to this scene
  89907. * @param newMaterial The material to add
  89908. */
  89909. addMaterial(newMaterial: Material): void;
  89910. /**
  89911. * Adds the given morph target to this scene
  89912. * @param newMorphTargetManager The morph target to add
  89913. */
  89914. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89915. /**
  89916. * Adds the given geometry to this scene
  89917. * @param newGeometry The geometry to add
  89918. */
  89919. addGeometry(newGeometry: Geometry): void;
  89920. /**
  89921. * Adds the given action manager to this scene
  89922. * @param newActionManager The action manager to add
  89923. */
  89924. addActionManager(newActionManager: AbstractActionManager): void;
  89925. /**
  89926. * Adds the given texture to this scene.
  89927. * @param newTexture The texture to add
  89928. */
  89929. addTexture(newTexture: BaseTexture): void;
  89930. /**
  89931. * Switch active camera
  89932. * @param newCamera defines the new active camera
  89933. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89934. */
  89935. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89936. /**
  89937. * sets the active camera of the scene using its ID
  89938. * @param id defines the camera's ID
  89939. * @return the new active camera or null if none found.
  89940. */
  89941. setActiveCameraByID(id: string): Nullable<Camera>;
  89942. /**
  89943. * sets the active camera of the scene using its name
  89944. * @param name defines the camera's name
  89945. * @returns the new active camera or null if none found.
  89946. */
  89947. setActiveCameraByName(name: string): Nullable<Camera>;
  89948. /**
  89949. * get an animation group using its name
  89950. * @param name defines the material's name
  89951. * @return the animation group or null if none found.
  89952. */
  89953. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89954. /**
  89955. * get a material using its id
  89956. * @param id defines the material's ID
  89957. * @return the material or null if none found.
  89958. */
  89959. getMaterialByID(id: string): Nullable<Material>;
  89960. /**
  89961. * Gets a material using its name
  89962. * @param name defines the material's name
  89963. * @return the material or null if none found.
  89964. */
  89965. getMaterialByName(name: string): Nullable<Material>;
  89966. /**
  89967. * Gets a camera using its id
  89968. * @param id defines the id to look for
  89969. * @returns the camera or null if not found
  89970. */
  89971. getCameraByID(id: string): Nullable<Camera>;
  89972. /**
  89973. * Gets a camera using its unique id
  89974. * @param uniqueId defines the unique id to look for
  89975. * @returns the camera or null if not found
  89976. */
  89977. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89978. /**
  89979. * Gets a camera using its name
  89980. * @param name defines the camera's name
  89981. * @return the camera or null if none found.
  89982. */
  89983. getCameraByName(name: string): Nullable<Camera>;
  89984. /**
  89985. * Gets a bone using its id
  89986. * @param id defines the bone's id
  89987. * @return the bone or null if not found
  89988. */
  89989. getBoneByID(id: string): Nullable<Bone>;
  89990. /**
  89991. * Gets a bone using its id
  89992. * @param name defines the bone's name
  89993. * @return the bone or null if not found
  89994. */
  89995. getBoneByName(name: string): Nullable<Bone>;
  89996. /**
  89997. * Gets a light node using its name
  89998. * @param name defines the the light's name
  89999. * @return the light or null if none found.
  90000. */
  90001. getLightByName(name: string): Nullable<Light>;
  90002. /**
  90003. * Gets a light node using its id
  90004. * @param id defines the light's id
  90005. * @return the light or null if none found.
  90006. */
  90007. getLightByID(id: string): Nullable<Light>;
  90008. /**
  90009. * Gets a light node using its scene-generated unique ID
  90010. * @param uniqueId defines the light's unique id
  90011. * @return the light or null if none found.
  90012. */
  90013. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  90014. /**
  90015. * Gets a particle system by id
  90016. * @param id defines the particle system id
  90017. * @return the corresponding system or null if none found
  90018. */
  90019. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90020. /**
  90021. * Gets a geometry using its ID
  90022. * @param id defines the geometry's id
  90023. * @return the geometry or null if none found.
  90024. */
  90025. getGeometryByID(id: string): Nullable<Geometry>;
  90026. private _getGeometryByUniqueID;
  90027. /**
  90028. * Add a new geometry to this scene
  90029. * @param geometry defines the geometry to be added to the scene.
  90030. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90031. * @return a boolean defining if the geometry was added or not
  90032. */
  90033. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90034. /**
  90035. * Removes an existing geometry
  90036. * @param geometry defines the geometry to be removed from the scene
  90037. * @return a boolean defining if the geometry was removed or not
  90038. */
  90039. removeGeometry(geometry: Geometry): boolean;
  90040. /**
  90041. * Gets the list of geometries attached to the scene
  90042. * @returns an array of Geometry
  90043. */
  90044. getGeometries(): Geometry[];
  90045. /**
  90046. * Gets the first added mesh found of a given ID
  90047. * @param id defines the id to search for
  90048. * @return the mesh found or null if not found at all
  90049. */
  90050. getMeshByID(id: string): Nullable<AbstractMesh>;
  90051. /**
  90052. * Gets a list of meshes using their id
  90053. * @param id defines the id to search for
  90054. * @returns a list of meshes
  90055. */
  90056. getMeshesByID(id: string): Array<AbstractMesh>;
  90057. /**
  90058. * Gets the first added transform node found of a given ID
  90059. * @param id defines the id to search for
  90060. * @return the found transform node or null if not found at all.
  90061. */
  90062. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90063. /**
  90064. * Gets a list of transform nodes using their id
  90065. * @param id defines the id to search for
  90066. * @returns a list of transform nodes
  90067. */
  90068. getTransformNodesByID(id: string): Array<TransformNode>;
  90069. /**
  90070. * Gets a mesh with its auto-generated unique id
  90071. * @param uniqueId defines the unique id to search for
  90072. * @return the found mesh or null if not found at all.
  90073. */
  90074. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90075. /**
  90076. * Gets a the last added mesh using a given id
  90077. * @param id defines the id to search for
  90078. * @return the found mesh or null if not found at all.
  90079. */
  90080. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90081. /**
  90082. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90083. * @param id defines the id to search for
  90084. * @return the found node or null if not found at all
  90085. */
  90086. getLastEntryByID(id: string): Nullable<Node>;
  90087. /**
  90088. * Gets a node (Mesh, Camera, Light) using a given id
  90089. * @param id defines the id to search for
  90090. * @return the found node or null if not found at all
  90091. */
  90092. getNodeByID(id: string): Nullable<Node>;
  90093. /**
  90094. * Gets a node (Mesh, Camera, Light) using a given name
  90095. * @param name defines the name to search for
  90096. * @return the found node or null if not found at all.
  90097. */
  90098. getNodeByName(name: string): Nullable<Node>;
  90099. /**
  90100. * Gets a mesh using a given name
  90101. * @param name defines the name to search for
  90102. * @return the found mesh or null if not found at all.
  90103. */
  90104. getMeshByName(name: string): Nullable<AbstractMesh>;
  90105. /**
  90106. * Gets a transform node using a given name
  90107. * @param name defines the name to search for
  90108. * @return the found transform node or null if not found at all.
  90109. */
  90110. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90111. /**
  90112. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90113. * @param id defines the id to search for
  90114. * @return the found skeleton or null if not found at all.
  90115. */
  90116. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90117. /**
  90118. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90119. * @param id defines the id to search for
  90120. * @return the found skeleton or null if not found at all.
  90121. */
  90122. getSkeletonById(id: string): Nullable<Skeleton>;
  90123. /**
  90124. * Gets a skeleton using a given name
  90125. * @param name defines the name to search for
  90126. * @return the found skeleton or null if not found at all.
  90127. */
  90128. getSkeletonByName(name: string): Nullable<Skeleton>;
  90129. /**
  90130. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90131. * @param id defines the id to search for
  90132. * @return the found morph target manager or null if not found at all.
  90133. */
  90134. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90135. /**
  90136. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90137. * @param id defines the id to search for
  90138. * @return the found morph target or null if not found at all.
  90139. */
  90140. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90141. /**
  90142. * Gets a boolean indicating if the given mesh is active
  90143. * @param mesh defines the mesh to look for
  90144. * @returns true if the mesh is in the active list
  90145. */
  90146. isActiveMesh(mesh: AbstractMesh): boolean;
  90147. /**
  90148. * Return a unique id as a string which can serve as an identifier for the scene
  90149. */
  90150. readonly uid: string;
  90151. /**
  90152. * Add an externaly attached data from its key.
  90153. * This method call will fail and return false, if such key already exists.
  90154. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90155. * @param key the unique key that identifies the data
  90156. * @param data the data object to associate to the key for this Engine instance
  90157. * @return true if no such key were already present and the data was added successfully, false otherwise
  90158. */
  90159. addExternalData<T>(key: string, data: T): boolean;
  90160. /**
  90161. * Get an externaly attached data from its key
  90162. * @param key the unique key that identifies the data
  90163. * @return the associated data, if present (can be null), or undefined if not present
  90164. */
  90165. getExternalData<T>(key: string): Nullable<T>;
  90166. /**
  90167. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90168. * @param key the unique key that identifies the data
  90169. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90170. * @return the associated data, can be null if the factory returned null.
  90171. */
  90172. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90173. /**
  90174. * Remove an externaly attached data from the Engine instance
  90175. * @param key the unique key that identifies the data
  90176. * @return true if the data was successfully removed, false if it doesn't exist
  90177. */
  90178. removeExternalData(key: string): boolean;
  90179. private _evaluateSubMesh;
  90180. /**
  90181. * Clear the processed materials smart array preventing retention point in material dispose.
  90182. */
  90183. freeProcessedMaterials(): void;
  90184. private _preventFreeActiveMeshesAndRenderingGroups;
  90185. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90186. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90187. * when disposing several meshes in a row or a hierarchy of meshes.
  90188. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90189. */
  90190. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90191. /**
  90192. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90193. */
  90194. freeActiveMeshes(): void;
  90195. /**
  90196. * Clear the info related to rendering groups preventing retention points during dispose.
  90197. */
  90198. freeRenderingGroups(): void;
  90199. /** @hidden */
  90200. _isInIntermediateRendering(): boolean;
  90201. /**
  90202. * Lambda returning the list of potentially active meshes.
  90203. */
  90204. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90205. /**
  90206. * Lambda returning the list of potentially active sub meshes.
  90207. */
  90208. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90209. /**
  90210. * Lambda returning the list of potentially intersecting sub meshes.
  90211. */
  90212. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90213. /**
  90214. * Lambda returning the list of potentially colliding sub meshes.
  90215. */
  90216. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90217. private _activeMeshesFrozen;
  90218. /**
  90219. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90220. * @returns the current scene
  90221. */
  90222. freezeActiveMeshes(): Scene;
  90223. /**
  90224. * Use this function to restart evaluating active meshes on every frame
  90225. * @returns the current scene
  90226. */
  90227. unfreezeActiveMeshes(): Scene;
  90228. private _evaluateActiveMeshes;
  90229. private _activeMesh;
  90230. /**
  90231. * Update the transform matrix to update from the current active camera
  90232. * @param force defines a boolean used to force the update even if cache is up to date
  90233. */
  90234. updateTransformMatrix(force?: boolean): void;
  90235. /**
  90236. * 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)
  90237. * @param alternateCamera defines the camera to use
  90238. */
  90239. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90240. /** @hidden */
  90241. _allowPostProcessClearColor: boolean;
  90242. private _renderForCamera;
  90243. private _processSubCameras;
  90244. private _checkIntersections;
  90245. /** @hidden */
  90246. _advancePhysicsEngineStep(step: number): void;
  90247. /**
  90248. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90249. */
  90250. getDeterministicFrameTime: () => number;
  90251. /** @hidden */
  90252. _animate(): void;
  90253. /**
  90254. * Render the scene
  90255. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90256. */
  90257. render(updateCameras?: boolean): void;
  90258. /**
  90259. * Freeze all materials
  90260. * A frozen material will not be updatable but should be faster to render
  90261. */
  90262. freezeMaterials(): void;
  90263. /**
  90264. * Unfreeze all materials
  90265. * A frozen material will not be updatable but should be faster to render
  90266. */
  90267. unfreezeMaterials(): void;
  90268. /**
  90269. * Releases all held ressources
  90270. */
  90271. dispose(): void;
  90272. /**
  90273. * Gets if the scene is already disposed
  90274. */
  90275. readonly isDisposed: boolean;
  90276. /**
  90277. * Call this function to reduce memory footprint of the scene.
  90278. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90279. */
  90280. clearCachedVertexData(): void;
  90281. /**
  90282. * This function will remove the local cached buffer data from texture.
  90283. * It will save memory but will prevent the texture from being rebuilt
  90284. */
  90285. cleanCachedTextureBuffer(): void;
  90286. /**
  90287. * Get the world extend vectors with an optional filter
  90288. *
  90289. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90290. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90291. */
  90292. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90293. min: Vector3;
  90294. max: Vector3;
  90295. };
  90296. /**
  90297. * Creates a ray that can be used to pick in the scene
  90298. * @param x defines the x coordinate of the origin (on-screen)
  90299. * @param y defines the y coordinate of the origin (on-screen)
  90300. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90301. * @param camera defines the camera to use for the picking
  90302. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90303. * @returns a Ray
  90304. */
  90305. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90306. /**
  90307. * Creates a ray that can be used to pick in the scene
  90308. * @param x defines the x coordinate of the origin (on-screen)
  90309. * @param y defines the y coordinate of the origin (on-screen)
  90310. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90311. * @param result defines the ray where to store the picking ray
  90312. * @param camera defines the camera to use for the picking
  90313. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90314. * @returns the current scene
  90315. */
  90316. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90317. /**
  90318. * Creates a ray that can be used to pick in the scene
  90319. * @param x defines the x coordinate of the origin (on-screen)
  90320. * @param y defines the y coordinate of the origin (on-screen)
  90321. * @param camera defines the camera to use for the picking
  90322. * @returns a Ray
  90323. */
  90324. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90325. /**
  90326. * Creates a ray that can be used to pick in the scene
  90327. * @param x defines the x coordinate of the origin (on-screen)
  90328. * @param y defines the y coordinate of the origin (on-screen)
  90329. * @param result defines the ray where to store the picking ray
  90330. * @param camera defines the camera to use for the picking
  90331. * @returns the current scene
  90332. */
  90333. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90334. /** Launch a ray to try to pick a mesh in the scene
  90335. * @param x position on screen
  90336. * @param y position on screen
  90337. * @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
  90338. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90339. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90340. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90341. * @returns a PickingInfo
  90342. */
  90343. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90344. /** Use the given ray to pick a mesh in the scene
  90345. * @param ray The ray to use to pick meshes
  90346. * @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
  90347. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90348. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90349. * @returns a PickingInfo
  90350. */
  90351. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90352. /**
  90353. * Launch a ray to try to pick a mesh in the scene
  90354. * @param x X position on screen
  90355. * @param y Y position on screen
  90356. * @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
  90357. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90359. * @returns an array of PickingInfo
  90360. */
  90361. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90362. /**
  90363. * Launch a ray to try to pick a mesh in the scene
  90364. * @param ray Ray to use
  90365. * @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
  90366. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90367. * @returns an array of PickingInfo
  90368. */
  90369. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90370. /**
  90371. * Force the value of meshUnderPointer
  90372. * @param mesh defines the mesh to use
  90373. */
  90374. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90375. /**
  90376. * Gets the mesh under the pointer
  90377. * @returns a Mesh or null if no mesh is under the pointer
  90378. */
  90379. getPointerOverMesh(): Nullable<AbstractMesh>;
  90380. /** @hidden */
  90381. _rebuildGeometries(): void;
  90382. /** @hidden */
  90383. _rebuildTextures(): void;
  90384. private _getByTags;
  90385. /**
  90386. * Get a list of meshes by tags
  90387. * @param tagsQuery defines the tags query to use
  90388. * @param forEach defines a predicate used to filter results
  90389. * @returns an array of Mesh
  90390. */
  90391. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90392. /**
  90393. * Get a list of cameras by tags
  90394. * @param tagsQuery defines the tags query to use
  90395. * @param forEach defines a predicate used to filter results
  90396. * @returns an array of Camera
  90397. */
  90398. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90399. /**
  90400. * Get a list of lights by tags
  90401. * @param tagsQuery defines the tags query to use
  90402. * @param forEach defines a predicate used to filter results
  90403. * @returns an array of Light
  90404. */
  90405. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90406. /**
  90407. * Get a list of materials by tags
  90408. * @param tagsQuery defines the tags query to use
  90409. * @param forEach defines a predicate used to filter results
  90410. * @returns an array of Material
  90411. */
  90412. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90413. /**
  90414. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90415. * This allowed control for front to back rendering or reversly depending of the special needs.
  90416. *
  90417. * @param renderingGroupId The rendering group id corresponding to its index
  90418. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90419. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90420. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90421. */
  90422. 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;
  90423. /**
  90424. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90425. *
  90426. * @param renderingGroupId The rendering group id corresponding to its index
  90427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90428. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90429. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90430. */
  90431. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90432. /**
  90433. * Gets the current auto clear configuration for one rendering group of the rendering
  90434. * manager.
  90435. * @param index the rendering group index to get the information for
  90436. * @returns The auto clear setup for the requested rendering group
  90437. */
  90438. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90439. private _blockMaterialDirtyMechanism;
  90440. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90441. blockMaterialDirtyMechanism: boolean;
  90442. /**
  90443. * Will flag all materials as dirty to trigger new shader compilation
  90444. * @param flag defines the flag used to specify which material part must be marked as dirty
  90445. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90446. */
  90447. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90448. /** @hidden */
  90449. _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;
  90450. /** @hidden */
  90451. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90452. }
  90453. }
  90454. declare module BABYLON {
  90455. /**
  90456. * Set of assets to keep when moving a scene into an asset container.
  90457. */
  90458. export class KeepAssets extends AbstractScene {
  90459. }
  90460. /**
  90461. * Container with a set of assets that can be added or removed from a scene.
  90462. */
  90463. export class AssetContainer extends AbstractScene {
  90464. /**
  90465. * The scene the AssetContainer belongs to.
  90466. */
  90467. scene: Scene;
  90468. /**
  90469. * Instantiates an AssetContainer.
  90470. * @param scene The scene the AssetContainer belongs to.
  90471. */
  90472. constructor(scene: Scene);
  90473. /**
  90474. * Adds all the assets from the container to the scene.
  90475. */
  90476. addAllToScene(): void;
  90477. /**
  90478. * Removes all the assets in the container from the scene
  90479. */
  90480. removeAllFromScene(): void;
  90481. /**
  90482. * Disposes all the assets in the container
  90483. */
  90484. dispose(): void;
  90485. private _moveAssets;
  90486. /**
  90487. * Removes all the assets contained in the scene and adds them to the container.
  90488. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90489. */
  90490. moveAllFromScene(keepAssets?: KeepAssets): void;
  90491. /**
  90492. * 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.
  90493. * @returns the root mesh
  90494. */
  90495. createRootMesh(): Mesh;
  90496. }
  90497. }
  90498. declare module BABYLON {
  90499. /**
  90500. * Defines how the parser contract is defined.
  90501. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90502. */
  90503. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90504. /**
  90505. * Defines how the individual parser contract is defined.
  90506. * These parser can parse an individual asset
  90507. */
  90508. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90509. /**
  90510. * Base class of the scene acting as a container for the different elements composing a scene.
  90511. * This class is dynamically extended by the different components of the scene increasing
  90512. * flexibility and reducing coupling
  90513. */
  90514. export abstract class AbstractScene {
  90515. /**
  90516. * Stores the list of available parsers in the application.
  90517. */
  90518. private static _BabylonFileParsers;
  90519. /**
  90520. * Stores the list of available individual parsers in the application.
  90521. */
  90522. private static _IndividualBabylonFileParsers;
  90523. /**
  90524. * Adds a parser in the list of available ones
  90525. * @param name Defines the name of the parser
  90526. * @param parser Defines the parser to add
  90527. */
  90528. static AddParser(name: string, parser: BabylonFileParser): void;
  90529. /**
  90530. * Gets a general parser from the list of avaialble ones
  90531. * @param name Defines the name of the parser
  90532. * @returns the requested parser or null
  90533. */
  90534. static GetParser(name: string): Nullable<BabylonFileParser>;
  90535. /**
  90536. * Adds n individual parser in the list of available ones
  90537. * @param name Defines the name of the parser
  90538. * @param parser Defines the parser to add
  90539. */
  90540. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90541. /**
  90542. * Gets an individual parser from the list of avaialble ones
  90543. * @param name Defines the name of the parser
  90544. * @returns the requested parser or null
  90545. */
  90546. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90547. /**
  90548. * Parser json data and populate both a scene and its associated container object
  90549. * @param jsonData Defines the data to parse
  90550. * @param scene Defines the scene to parse the data for
  90551. * @param container Defines the container attached to the parsing sequence
  90552. * @param rootUrl Defines the root url of the data
  90553. */
  90554. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90555. /**
  90556. * Gets the list of root nodes (ie. nodes with no parent)
  90557. */
  90558. rootNodes: Node[];
  90559. /** All of the cameras added to this scene
  90560. * @see http://doc.babylonjs.com/babylon101/cameras
  90561. */
  90562. cameras: Camera[];
  90563. /**
  90564. * All of the lights added to this scene
  90565. * @see http://doc.babylonjs.com/babylon101/lights
  90566. */
  90567. lights: Light[];
  90568. /**
  90569. * All of the (abstract) meshes added to this scene
  90570. */
  90571. meshes: AbstractMesh[];
  90572. /**
  90573. * The list of skeletons added to the scene
  90574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90575. */
  90576. skeletons: Skeleton[];
  90577. /**
  90578. * All of the particle systems added to this scene
  90579. * @see http://doc.babylonjs.com/babylon101/particles
  90580. */
  90581. particleSystems: IParticleSystem[];
  90582. /**
  90583. * Gets a list of Animations associated with the scene
  90584. */
  90585. animations: Animation[];
  90586. /**
  90587. * All of the animation groups added to this scene
  90588. * @see http://doc.babylonjs.com/how_to/group
  90589. */
  90590. animationGroups: AnimationGroup[];
  90591. /**
  90592. * All of the multi-materials added to this scene
  90593. * @see http://doc.babylonjs.com/how_to/multi_materials
  90594. */
  90595. multiMaterials: MultiMaterial[];
  90596. /**
  90597. * All of the materials added to this scene
  90598. * In the context of a Scene, it is not supposed to be modified manually.
  90599. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90600. * Note also that the order of the Material wihin the array is not significant and might change.
  90601. * @see http://doc.babylonjs.com/babylon101/materials
  90602. */
  90603. materials: Material[];
  90604. /**
  90605. * The list of morph target managers added to the scene
  90606. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90607. */
  90608. morphTargetManagers: MorphTargetManager[];
  90609. /**
  90610. * The list of geometries used in the scene.
  90611. */
  90612. geometries: Geometry[];
  90613. /**
  90614. * All of the tranform nodes added to this scene
  90615. * In the context of a Scene, it is not supposed to be modified manually.
  90616. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90617. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90618. * @see http://doc.babylonjs.com/how_to/transformnode
  90619. */
  90620. transformNodes: TransformNode[];
  90621. /**
  90622. * ActionManagers available on the scene.
  90623. */
  90624. actionManagers: AbstractActionManager[];
  90625. /**
  90626. * Textures to keep.
  90627. */
  90628. textures: BaseTexture[];
  90629. }
  90630. }
  90631. declare module BABYLON {
  90632. /**
  90633. * Defines a sound that can be played in the application.
  90634. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90636. */
  90637. export class Sound {
  90638. /**
  90639. * The name of the sound in the scene.
  90640. */
  90641. name: string;
  90642. /**
  90643. * Does the sound autoplay once loaded.
  90644. */
  90645. autoplay: boolean;
  90646. /**
  90647. * Does the sound loop after it finishes playing once.
  90648. */
  90649. loop: boolean;
  90650. /**
  90651. * Does the sound use a custom attenuation curve to simulate the falloff
  90652. * happening when the source gets further away from the camera.
  90653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90654. */
  90655. useCustomAttenuation: boolean;
  90656. /**
  90657. * The sound track id this sound belongs to.
  90658. */
  90659. soundTrackId: number;
  90660. /**
  90661. * Is this sound currently played.
  90662. */
  90663. isPlaying: boolean;
  90664. /**
  90665. * Is this sound currently paused.
  90666. */
  90667. isPaused: boolean;
  90668. /**
  90669. * Does this sound enables spatial sound.
  90670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90671. */
  90672. spatialSound: boolean;
  90673. /**
  90674. * Define the reference distance the sound should be heard perfectly.
  90675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90676. */
  90677. refDistance: number;
  90678. /**
  90679. * Define the roll off factor of spatial sounds.
  90680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90681. */
  90682. rolloffFactor: number;
  90683. /**
  90684. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90686. */
  90687. maxDistance: number;
  90688. /**
  90689. * Define the distance attenuation model the sound will follow.
  90690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90691. */
  90692. distanceModel: string;
  90693. /**
  90694. * @hidden
  90695. * Back Compat
  90696. **/
  90697. onended: () => any;
  90698. /**
  90699. * Observable event when the current playing sound finishes.
  90700. */
  90701. onEndedObservable: Observable<Sound>;
  90702. private _panningModel;
  90703. private _playbackRate;
  90704. private _streaming;
  90705. private _startTime;
  90706. private _startOffset;
  90707. private _position;
  90708. /** @hidden */
  90709. _positionInEmitterSpace: boolean;
  90710. private _localDirection;
  90711. private _volume;
  90712. private _isReadyToPlay;
  90713. private _isDirectional;
  90714. private _readyToPlayCallback;
  90715. private _audioBuffer;
  90716. private _soundSource;
  90717. private _streamingSource;
  90718. private _soundPanner;
  90719. private _soundGain;
  90720. private _inputAudioNode;
  90721. private _outputAudioNode;
  90722. private _coneInnerAngle;
  90723. private _coneOuterAngle;
  90724. private _coneOuterGain;
  90725. private _scene;
  90726. private _connectedTransformNode;
  90727. private _customAttenuationFunction;
  90728. private _registerFunc;
  90729. private _isOutputConnected;
  90730. private _htmlAudioElement;
  90731. private _urlType;
  90732. /** @hidden */
  90733. static _SceneComponentInitialization: (scene: Scene) => void;
  90734. /**
  90735. * Create a sound and attach it to a scene
  90736. * @param name Name of your sound
  90737. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90738. * @param scene defines the scene the sound belongs to
  90739. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90740. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90741. */
  90742. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90743. /**
  90744. * Release the sound and its associated resources
  90745. */
  90746. dispose(): void;
  90747. /**
  90748. * Gets if the sounds is ready to be played or not.
  90749. * @returns true if ready, otherwise false
  90750. */
  90751. isReady(): boolean;
  90752. private _soundLoaded;
  90753. /**
  90754. * Sets the data of the sound from an audiobuffer
  90755. * @param audioBuffer The audioBuffer containing the data
  90756. */
  90757. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90758. /**
  90759. * Updates the current sounds options such as maxdistance, loop...
  90760. * @param options A JSON object containing values named as the object properties
  90761. */
  90762. updateOptions(options: any): void;
  90763. private _createSpatialParameters;
  90764. private _updateSpatialParameters;
  90765. /**
  90766. * Switch the panning model to HRTF:
  90767. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90769. */
  90770. switchPanningModelToHRTF(): void;
  90771. /**
  90772. * Switch the panning model to Equal Power:
  90773. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90775. */
  90776. switchPanningModelToEqualPower(): void;
  90777. private _switchPanningModel;
  90778. /**
  90779. * Connect this sound to a sound track audio node like gain...
  90780. * @param soundTrackAudioNode the sound track audio node to connect to
  90781. */
  90782. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90783. /**
  90784. * Transform this sound into a directional source
  90785. * @param coneInnerAngle Size of the inner cone in degree
  90786. * @param coneOuterAngle Size of the outer cone in degree
  90787. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90788. */
  90789. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90790. /**
  90791. * Gets or sets the inner angle for the directional cone.
  90792. */
  90793. /**
  90794. * Gets or sets the inner angle for the directional cone.
  90795. */
  90796. directionalConeInnerAngle: number;
  90797. /**
  90798. * Gets or sets the outer angle for the directional cone.
  90799. */
  90800. /**
  90801. * Gets or sets the outer angle for the directional cone.
  90802. */
  90803. directionalConeOuterAngle: number;
  90804. /**
  90805. * Sets the position of the emitter if spatial sound is enabled
  90806. * @param newPosition Defines the new posisiton
  90807. */
  90808. setPosition(newPosition: Vector3): void;
  90809. /**
  90810. * Sets the local direction of the emitter if spatial sound is enabled
  90811. * @param newLocalDirection Defines the new local direction
  90812. */
  90813. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90814. private _updateDirection;
  90815. /** @hidden */
  90816. updateDistanceFromListener(): void;
  90817. /**
  90818. * Sets a new custom attenuation function for the sound.
  90819. * @param callback Defines the function used for the attenuation
  90820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90821. */
  90822. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90823. /**
  90824. * Play the sound
  90825. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90826. * @param offset (optional) Start the sound setting it at a specific time
  90827. */
  90828. play(time?: number, offset?: number): void;
  90829. private _onended;
  90830. /**
  90831. * Stop the sound
  90832. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90833. */
  90834. stop(time?: number): void;
  90835. /**
  90836. * Put the sound in pause
  90837. */
  90838. pause(): void;
  90839. /**
  90840. * Sets a dedicated volume for this sounds
  90841. * @param newVolume Define the new volume of the sound
  90842. * @param time Define in how long the sound should be at this value
  90843. */
  90844. setVolume(newVolume: number, time?: number): void;
  90845. /**
  90846. * Set the sound play back rate
  90847. * @param newPlaybackRate Define the playback rate the sound should be played at
  90848. */
  90849. setPlaybackRate(newPlaybackRate: number): void;
  90850. /**
  90851. * Gets the volume of the sound.
  90852. * @returns the volume of the sound
  90853. */
  90854. getVolume(): number;
  90855. /**
  90856. * Attach the sound to a dedicated mesh
  90857. * @param transformNode The transform node to connect the sound with
  90858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90859. */
  90860. attachToMesh(transformNode: TransformNode): void;
  90861. /**
  90862. * Detach the sound from the previously attached mesh
  90863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90864. */
  90865. detachFromMesh(): void;
  90866. private _onRegisterAfterWorldMatrixUpdate;
  90867. /**
  90868. * Clone the current sound in the scene.
  90869. * @returns the new sound clone
  90870. */
  90871. clone(): Nullable<Sound>;
  90872. /**
  90873. * Gets the current underlying audio buffer containing the data
  90874. * @returns the audio buffer
  90875. */
  90876. getAudioBuffer(): Nullable<AudioBuffer>;
  90877. /**
  90878. * Serializes the Sound in a JSON representation
  90879. * @returns the JSON representation of the sound
  90880. */
  90881. serialize(): any;
  90882. /**
  90883. * Parse a JSON representation of a sound to innstantiate in a given scene
  90884. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90885. * @param scene Define the scene the new parsed sound should be created in
  90886. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90887. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90888. * @returns the newly parsed sound
  90889. */
  90890. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90891. }
  90892. }
  90893. declare module BABYLON {
  90894. /**
  90895. * This defines an action helpful to play a defined sound on a triggered action.
  90896. */
  90897. export class PlaySoundAction extends Action {
  90898. private _sound;
  90899. /**
  90900. * Instantiate the action
  90901. * @param triggerOptions defines the trigger options
  90902. * @param sound defines the sound to play
  90903. * @param condition defines the trigger related conditions
  90904. */
  90905. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90906. /** @hidden */
  90907. _prepare(): void;
  90908. /**
  90909. * Execute the action and play the sound.
  90910. */
  90911. execute(): void;
  90912. /**
  90913. * Serializes the actions and its related information.
  90914. * @param parent defines the object to serialize in
  90915. * @returns the serialized object
  90916. */
  90917. serialize(parent: any): any;
  90918. }
  90919. /**
  90920. * This defines an action helpful to stop a defined sound on a triggered action.
  90921. */
  90922. export class StopSoundAction extends Action {
  90923. private _sound;
  90924. /**
  90925. * Instantiate the action
  90926. * @param triggerOptions defines the trigger options
  90927. * @param sound defines the sound to stop
  90928. * @param condition defines the trigger related conditions
  90929. */
  90930. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90931. /** @hidden */
  90932. _prepare(): void;
  90933. /**
  90934. * Execute the action and stop the sound.
  90935. */
  90936. execute(): void;
  90937. /**
  90938. * Serializes the actions and its related information.
  90939. * @param parent defines the object to serialize in
  90940. * @returns the serialized object
  90941. */
  90942. serialize(parent: any): any;
  90943. }
  90944. }
  90945. declare module BABYLON {
  90946. /**
  90947. * This defines an action responsible to change the value of a property
  90948. * by interpolating between its current value and the newly set one once triggered.
  90949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90950. */
  90951. export class InterpolateValueAction extends Action {
  90952. /**
  90953. * Defines the path of the property where the value should be interpolated
  90954. */
  90955. propertyPath: string;
  90956. /**
  90957. * Defines the target value at the end of the interpolation.
  90958. */
  90959. value: any;
  90960. /**
  90961. * Defines the time it will take for the property to interpolate to the value.
  90962. */
  90963. duration: number;
  90964. /**
  90965. * Defines if the other scene animations should be stopped when the action has been triggered
  90966. */
  90967. stopOtherAnimations?: boolean;
  90968. /**
  90969. * Defines a callback raised once the interpolation animation has been done.
  90970. */
  90971. onInterpolationDone?: () => void;
  90972. /**
  90973. * Observable triggered once the interpolation animation has been done.
  90974. */
  90975. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90976. private _target;
  90977. private _effectiveTarget;
  90978. private _property;
  90979. /**
  90980. * Instantiate the action
  90981. * @param triggerOptions defines the trigger options
  90982. * @param target defines the object containing the value to interpolate
  90983. * @param propertyPath defines the path to the property in the target object
  90984. * @param value defines the target value at the end of the interpolation
  90985. * @param duration deines the time it will take for the property to interpolate to the value.
  90986. * @param condition defines the trigger related conditions
  90987. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90988. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90989. */
  90990. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90991. /** @hidden */
  90992. _prepare(): void;
  90993. /**
  90994. * Execute the action starts the value interpolation.
  90995. */
  90996. execute(): void;
  90997. /**
  90998. * Serializes the actions and its related information.
  90999. * @param parent defines the object to serialize in
  91000. * @returns the serialized object
  91001. */
  91002. serialize(parent: any): any;
  91003. }
  91004. }
  91005. declare module BABYLON {
  91006. /**
  91007. * Options allowed during the creation of a sound track.
  91008. */
  91009. export interface ISoundTrackOptions {
  91010. /**
  91011. * The volume the sound track should take during creation
  91012. */
  91013. volume?: number;
  91014. /**
  91015. * Define if the sound track is the main sound track of the scene
  91016. */
  91017. mainTrack?: boolean;
  91018. }
  91019. /**
  91020. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91021. * It will be also used in a future release to apply effects on a specific track.
  91022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91023. */
  91024. export class SoundTrack {
  91025. /**
  91026. * The unique identifier of the sound track in the scene.
  91027. */
  91028. id: number;
  91029. /**
  91030. * The list of sounds included in the sound track.
  91031. */
  91032. soundCollection: Array<Sound>;
  91033. private _outputAudioNode;
  91034. private _scene;
  91035. private _isMainTrack;
  91036. private _connectedAnalyser;
  91037. private _options;
  91038. private _isInitialized;
  91039. /**
  91040. * Creates a new sound track.
  91041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91042. * @param scene Define the scene the sound track belongs to
  91043. * @param options
  91044. */
  91045. constructor(scene: Scene, options?: ISoundTrackOptions);
  91046. private _initializeSoundTrackAudioGraph;
  91047. /**
  91048. * Release the sound track and its associated resources
  91049. */
  91050. dispose(): void;
  91051. /**
  91052. * Adds a sound to this sound track
  91053. * @param sound define the cound to add
  91054. * @ignoreNaming
  91055. */
  91056. AddSound(sound: Sound): void;
  91057. /**
  91058. * Removes a sound to this sound track
  91059. * @param sound define the cound to remove
  91060. * @ignoreNaming
  91061. */
  91062. RemoveSound(sound: Sound): void;
  91063. /**
  91064. * Set a global volume for the full sound track.
  91065. * @param newVolume Define the new volume of the sound track
  91066. */
  91067. setVolume(newVolume: number): void;
  91068. /**
  91069. * Switch the panning model to HRTF:
  91070. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91072. */
  91073. switchPanningModelToHRTF(): void;
  91074. /**
  91075. * Switch the panning model to Equal Power:
  91076. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91078. */
  91079. switchPanningModelToEqualPower(): void;
  91080. /**
  91081. * Connect the sound track to an audio analyser allowing some amazing
  91082. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91084. * @param analyser The analyser to connect to the engine
  91085. */
  91086. connectToAnalyser(analyser: Analyser): void;
  91087. }
  91088. }
  91089. declare module BABYLON {
  91090. interface AbstractScene {
  91091. /**
  91092. * The list of sounds used in the scene.
  91093. */
  91094. sounds: Nullable<Array<Sound>>;
  91095. }
  91096. interface Scene {
  91097. /**
  91098. * @hidden
  91099. * Backing field
  91100. */
  91101. _mainSoundTrack: SoundTrack;
  91102. /**
  91103. * The main sound track played by the scene.
  91104. * It cotains your primary collection of sounds.
  91105. */
  91106. mainSoundTrack: SoundTrack;
  91107. /**
  91108. * The list of sound tracks added to the scene
  91109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91110. */
  91111. soundTracks: Nullable<Array<SoundTrack>>;
  91112. /**
  91113. * Gets a sound using a given name
  91114. * @param name defines the name to search for
  91115. * @return the found sound or null if not found at all.
  91116. */
  91117. getSoundByName(name: string): Nullable<Sound>;
  91118. /**
  91119. * Gets or sets if audio support is enabled
  91120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91121. */
  91122. audioEnabled: boolean;
  91123. /**
  91124. * Gets or sets if audio will be output to headphones
  91125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91126. */
  91127. headphone: boolean;
  91128. }
  91129. /**
  91130. * Defines the sound scene component responsible to manage any sounds
  91131. * in a given scene.
  91132. */
  91133. export class AudioSceneComponent implements ISceneSerializableComponent {
  91134. /**
  91135. * The component name helpfull to identify the component in the list of scene components.
  91136. */
  91137. readonly name: string;
  91138. /**
  91139. * The scene the component belongs to.
  91140. */
  91141. scene: Scene;
  91142. private _audioEnabled;
  91143. /**
  91144. * Gets whether audio is enabled or not.
  91145. * Please use related enable/disable method to switch state.
  91146. */
  91147. readonly audioEnabled: boolean;
  91148. private _headphone;
  91149. /**
  91150. * Gets whether audio is outputing to headphone or not.
  91151. * Please use the according Switch methods to change output.
  91152. */
  91153. readonly headphone: boolean;
  91154. /**
  91155. * Creates a new instance of the component for the given scene
  91156. * @param scene Defines the scene to register the component in
  91157. */
  91158. constructor(scene: Scene);
  91159. /**
  91160. * Registers the component in a given scene
  91161. */
  91162. register(): void;
  91163. /**
  91164. * Rebuilds the elements related to this component in case of
  91165. * context lost for instance.
  91166. */
  91167. rebuild(): void;
  91168. /**
  91169. * Serializes the component data to the specified json object
  91170. * @param serializationObject The object to serialize to
  91171. */
  91172. serialize(serializationObject: any): void;
  91173. /**
  91174. * Adds all the element from the container to the scene
  91175. * @param container the container holding the elements
  91176. */
  91177. addFromContainer(container: AbstractScene): void;
  91178. /**
  91179. * Removes all the elements in the container from the scene
  91180. * @param container contains the elements to remove
  91181. */
  91182. removeFromContainer(container: AbstractScene): void;
  91183. /**
  91184. * Disposes the component and the associated ressources.
  91185. */
  91186. dispose(): void;
  91187. /**
  91188. * Disables audio in the associated scene.
  91189. */
  91190. disableAudio(): void;
  91191. /**
  91192. * Enables audio in the associated scene.
  91193. */
  91194. enableAudio(): void;
  91195. /**
  91196. * Switch audio to headphone output.
  91197. */
  91198. switchAudioModeForHeadphones(): void;
  91199. /**
  91200. * Switch audio to normal speakers.
  91201. */
  91202. switchAudioModeForNormalSpeakers(): void;
  91203. private _afterRender;
  91204. }
  91205. }
  91206. declare module BABYLON {
  91207. /**
  91208. * Wraps one or more Sound objects and selects one with random weight for playback.
  91209. */
  91210. export class WeightedSound {
  91211. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91212. loop: boolean;
  91213. private _coneInnerAngle;
  91214. private _coneOuterAngle;
  91215. private _volume;
  91216. /** A Sound is currently playing. */
  91217. isPlaying: boolean;
  91218. /** A Sound is currently paused. */
  91219. isPaused: boolean;
  91220. private _sounds;
  91221. private _weights;
  91222. private _currentIndex?;
  91223. /**
  91224. * Creates a new WeightedSound from the list of sounds given.
  91225. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91226. * @param sounds Array of Sounds that will be selected from.
  91227. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91228. */
  91229. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91230. /**
  91231. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91232. */
  91233. /**
  91234. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91235. */
  91236. directionalConeInnerAngle: number;
  91237. /**
  91238. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91239. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91240. */
  91241. /**
  91242. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91243. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91244. */
  91245. directionalConeOuterAngle: number;
  91246. /**
  91247. * Playback volume.
  91248. */
  91249. /**
  91250. * Playback volume.
  91251. */
  91252. volume: number;
  91253. private _onended;
  91254. /**
  91255. * Suspend playback
  91256. */
  91257. pause(): void;
  91258. /**
  91259. * Stop playback
  91260. */
  91261. stop(): void;
  91262. /**
  91263. * Start playback.
  91264. * @param startOffset Position the clip head at a specific time in seconds.
  91265. */
  91266. play(startOffset?: number): void;
  91267. }
  91268. }
  91269. declare module BABYLON {
  91270. /**
  91271. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91273. */
  91274. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91275. /**
  91276. * Gets the name of the behavior.
  91277. */
  91278. readonly name: string;
  91279. /**
  91280. * The easing function used by animations
  91281. */
  91282. static EasingFunction: BackEase;
  91283. /**
  91284. * The easing mode used by animations
  91285. */
  91286. static EasingMode: number;
  91287. /**
  91288. * The duration of the animation, in milliseconds
  91289. */
  91290. transitionDuration: number;
  91291. /**
  91292. * Length of the distance animated by the transition when lower radius is reached
  91293. */
  91294. lowerRadiusTransitionRange: number;
  91295. /**
  91296. * Length of the distance animated by the transition when upper radius is reached
  91297. */
  91298. upperRadiusTransitionRange: number;
  91299. private _autoTransitionRange;
  91300. /**
  91301. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91302. */
  91303. /**
  91304. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91305. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91306. */
  91307. autoTransitionRange: boolean;
  91308. private _attachedCamera;
  91309. private _onAfterCheckInputsObserver;
  91310. private _onMeshTargetChangedObserver;
  91311. /**
  91312. * Initializes the behavior.
  91313. */
  91314. init(): void;
  91315. /**
  91316. * Attaches the behavior to its arc rotate camera.
  91317. * @param camera Defines the camera to attach the behavior to
  91318. */
  91319. attach(camera: ArcRotateCamera): void;
  91320. /**
  91321. * Detaches the behavior from its current arc rotate camera.
  91322. */
  91323. detach(): void;
  91324. private _radiusIsAnimating;
  91325. private _radiusBounceTransition;
  91326. private _animatables;
  91327. private _cachedWheelPrecision;
  91328. /**
  91329. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91330. * @param radiusLimit The limit to check against.
  91331. * @return Bool to indicate if at limit.
  91332. */
  91333. private _isRadiusAtLimit;
  91334. /**
  91335. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91336. * @param radiusDelta The delta by which to animate to. Can be negative.
  91337. */
  91338. private _applyBoundRadiusAnimation;
  91339. /**
  91340. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91341. */
  91342. protected _clearAnimationLocks(): void;
  91343. /**
  91344. * Stops and removes all animations that have been applied to the camera
  91345. */
  91346. stopAllAnimations(): void;
  91347. }
  91348. }
  91349. declare module BABYLON {
  91350. /**
  91351. * 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.
  91352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91353. */
  91354. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91355. /**
  91356. * Gets the name of the behavior.
  91357. */
  91358. readonly name: string;
  91359. private _mode;
  91360. private _radiusScale;
  91361. private _positionScale;
  91362. private _defaultElevation;
  91363. private _elevationReturnTime;
  91364. private _elevationReturnWaitTime;
  91365. private _zoomStopsAnimation;
  91366. private _framingTime;
  91367. /**
  91368. * The easing function used by animations
  91369. */
  91370. static EasingFunction: ExponentialEase;
  91371. /**
  91372. * The easing mode used by animations
  91373. */
  91374. static EasingMode: number;
  91375. /**
  91376. * Sets the current mode used by the behavior
  91377. */
  91378. /**
  91379. * Gets current mode used by the behavior.
  91380. */
  91381. mode: number;
  91382. /**
  91383. * Sets the scale applied to the radius (1 by default)
  91384. */
  91385. /**
  91386. * Gets the scale applied to the radius
  91387. */
  91388. radiusScale: number;
  91389. /**
  91390. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91391. */
  91392. /**
  91393. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91394. */
  91395. positionScale: number;
  91396. /**
  91397. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91398. * behaviour is triggered, in radians.
  91399. */
  91400. /**
  91401. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91402. * behaviour is triggered, in radians.
  91403. */
  91404. defaultElevation: number;
  91405. /**
  91406. * Sets the time (in milliseconds) taken to return to the default beta position.
  91407. * Negative value indicates camera should not return to default.
  91408. */
  91409. /**
  91410. * Gets the time (in milliseconds) taken to return to the default beta position.
  91411. * Negative value indicates camera should not return to default.
  91412. */
  91413. elevationReturnTime: number;
  91414. /**
  91415. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91416. */
  91417. /**
  91418. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91419. */
  91420. elevationReturnWaitTime: number;
  91421. /**
  91422. * Sets the flag that indicates if user zooming should stop animation.
  91423. */
  91424. /**
  91425. * Gets the flag that indicates if user zooming should stop animation.
  91426. */
  91427. zoomStopsAnimation: boolean;
  91428. /**
  91429. * Sets the transition time when framing the mesh, in milliseconds
  91430. */
  91431. /**
  91432. * Gets the transition time when framing the mesh, in milliseconds
  91433. */
  91434. framingTime: number;
  91435. /**
  91436. * Define if the behavior should automatically change the configured
  91437. * camera limits and sensibilities.
  91438. */
  91439. autoCorrectCameraLimitsAndSensibility: boolean;
  91440. private _onPrePointerObservableObserver;
  91441. private _onAfterCheckInputsObserver;
  91442. private _onMeshTargetChangedObserver;
  91443. private _attachedCamera;
  91444. private _isPointerDown;
  91445. private _lastInteractionTime;
  91446. /**
  91447. * Initializes the behavior.
  91448. */
  91449. init(): void;
  91450. /**
  91451. * Attaches the behavior to its arc rotate camera.
  91452. * @param camera Defines the camera to attach the behavior to
  91453. */
  91454. attach(camera: ArcRotateCamera): void;
  91455. /**
  91456. * Detaches the behavior from its current arc rotate camera.
  91457. */
  91458. detach(): void;
  91459. private _animatables;
  91460. private _betaIsAnimating;
  91461. private _betaTransition;
  91462. private _radiusTransition;
  91463. private _vectorTransition;
  91464. /**
  91465. * Targets the given mesh and updates zoom level accordingly.
  91466. * @param mesh The mesh to target.
  91467. * @param radius Optional. If a cached radius position already exists, overrides default.
  91468. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91469. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91470. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91471. */
  91472. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91473. /**
  91474. * Targets the given mesh with its children and updates zoom level accordingly.
  91475. * @param mesh The mesh to target.
  91476. * @param radius Optional. If a cached radius position already exists, overrides default.
  91477. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91478. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91479. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91480. */
  91481. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91482. /**
  91483. * Targets the given meshes with their children and updates zoom level accordingly.
  91484. * @param meshes The mesh to target.
  91485. * @param radius Optional. If a cached radius position already exists, overrides default.
  91486. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91489. */
  91490. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91491. /**
  91492. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91493. * @param minimumWorld Determines the smaller position of the bounding box extend
  91494. * @param maximumWorld Determines the bigger position of the bounding box extend
  91495. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91496. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91497. */
  91498. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91499. /**
  91500. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91501. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91502. * frustum width.
  91503. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91504. * to fully enclose the mesh in the viewing frustum.
  91505. */
  91506. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91507. /**
  91508. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91509. * is automatically returned to its default position (expected to be above ground plane).
  91510. */
  91511. private _maintainCameraAboveGround;
  91512. /**
  91513. * Returns the frustum slope based on the canvas ratio and camera FOV
  91514. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91515. */
  91516. private _getFrustumSlope;
  91517. /**
  91518. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91519. */
  91520. private _clearAnimationLocks;
  91521. /**
  91522. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91523. */
  91524. private _applyUserInteraction;
  91525. /**
  91526. * Stops and removes all animations that have been applied to the camera
  91527. */
  91528. stopAllAnimations(): void;
  91529. /**
  91530. * Gets a value indicating if the user is moving the camera
  91531. */
  91532. readonly isUserIsMoving: boolean;
  91533. /**
  91534. * The camera can move all the way towards the mesh.
  91535. */
  91536. static IgnoreBoundsSizeMode: number;
  91537. /**
  91538. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91539. */
  91540. static FitFrustumSidesMode: number;
  91541. }
  91542. }
  91543. declare module BABYLON {
  91544. /**
  91545. * Base class for Camera Pointer Inputs.
  91546. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91547. * for example usage.
  91548. */
  91549. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91550. /**
  91551. * Defines the camera the input is attached to.
  91552. */
  91553. abstract camera: Camera;
  91554. /**
  91555. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91556. */
  91557. protected _altKey: boolean;
  91558. protected _ctrlKey: boolean;
  91559. protected _metaKey: boolean;
  91560. protected _shiftKey: boolean;
  91561. /**
  91562. * Which mouse buttons were pressed at time of last mouse event.
  91563. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91564. */
  91565. protected _buttonsPressed: number;
  91566. /**
  91567. * Defines the buttons associated with the input to handle camera move.
  91568. */
  91569. buttons: number[];
  91570. /**
  91571. * Attach the input controls to a specific dom element to get the input from.
  91572. * @param element Defines the element the controls should be listened from
  91573. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91574. */
  91575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91576. /**
  91577. * Detach the current controls from the specified dom element.
  91578. * @param element Defines the element to stop listening the inputs from
  91579. */
  91580. detachControl(element: Nullable<HTMLElement>): void;
  91581. /**
  91582. * Gets the class name of the current input.
  91583. * @returns the class name
  91584. */
  91585. getClassName(): string;
  91586. /**
  91587. * Get the friendly name associated with the input class.
  91588. * @returns the input friendly name
  91589. */
  91590. getSimpleName(): string;
  91591. /**
  91592. * Called on pointer POINTERDOUBLETAP event.
  91593. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91594. */
  91595. protected onDoubleTap(type: string): void;
  91596. /**
  91597. * Called on pointer POINTERMOVE event if only a single touch is active.
  91598. * Override this method to provide functionality.
  91599. */
  91600. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91601. /**
  91602. * Called on pointer POINTERMOVE event if multiple touches are active.
  91603. * Override this method to provide functionality.
  91604. */
  91605. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91606. /**
  91607. * Called on JS contextmenu event.
  91608. * Override this method to provide functionality.
  91609. */
  91610. protected onContextMenu(evt: PointerEvent): void;
  91611. /**
  91612. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91613. * press.
  91614. * Override this method to provide functionality.
  91615. */
  91616. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91617. /**
  91618. * Called each time a new POINTERUP event occurs. Ie, for each button
  91619. * release.
  91620. * Override this method to provide functionality.
  91621. */
  91622. protected onButtonUp(evt: PointerEvent): void;
  91623. /**
  91624. * Called when window becomes inactive.
  91625. * Override this method to provide functionality.
  91626. */
  91627. protected onLostFocus(): void;
  91628. private _pointerInput;
  91629. private _observer;
  91630. private _onLostFocus;
  91631. }
  91632. }
  91633. declare module BABYLON {
  91634. /**
  91635. * Manage the pointers inputs to control an arc rotate camera.
  91636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91637. */
  91638. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91639. /**
  91640. * Defines the camera the input is attached to.
  91641. */
  91642. camera: ArcRotateCamera;
  91643. /**
  91644. * Gets the class name of the current input.
  91645. * @returns the class name
  91646. */
  91647. getClassName(): string;
  91648. /**
  91649. * Defines the buttons associated with the input to handle camera move.
  91650. */
  91651. buttons: number[];
  91652. /**
  91653. * Defines the pointer angular sensibility along the X axis or how fast is
  91654. * the camera rotating.
  91655. */
  91656. angularSensibilityX: number;
  91657. /**
  91658. * Defines the pointer angular sensibility along the Y axis or how fast is
  91659. * the camera rotating.
  91660. */
  91661. angularSensibilityY: number;
  91662. /**
  91663. * Defines the pointer pinch precision or how fast is the camera zooming.
  91664. */
  91665. pinchPrecision: number;
  91666. /**
  91667. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91668. * from 0.
  91669. * It defines the percentage of current camera.radius to use as delta when
  91670. * pinch zoom is used.
  91671. */
  91672. pinchDeltaPercentage: number;
  91673. /**
  91674. * Defines the pointer panning sensibility or how fast is the camera moving.
  91675. */
  91676. panningSensibility: number;
  91677. /**
  91678. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91679. */
  91680. multiTouchPanning: boolean;
  91681. /**
  91682. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91683. * zoom (pinch) through multitouch.
  91684. */
  91685. multiTouchPanAndZoom: boolean;
  91686. /**
  91687. * Revers pinch action direction.
  91688. */
  91689. pinchInwards: boolean;
  91690. private _isPanClick;
  91691. private _twoFingerActivityCount;
  91692. private _isPinching;
  91693. /**
  91694. * Called on pointer POINTERMOVE event if only a single touch is active.
  91695. */
  91696. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91697. /**
  91698. * Called on pointer POINTERDOUBLETAP event.
  91699. */
  91700. protected onDoubleTap(type: string): void;
  91701. /**
  91702. * Called on pointer POINTERMOVE event if multiple touches are active.
  91703. */
  91704. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91705. /**
  91706. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91707. * press.
  91708. */
  91709. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91710. /**
  91711. * Called each time a new POINTERUP event occurs. Ie, for each button
  91712. * release.
  91713. */
  91714. protected onButtonUp(evt: PointerEvent): void;
  91715. /**
  91716. * Called when window becomes inactive.
  91717. */
  91718. protected onLostFocus(): void;
  91719. }
  91720. }
  91721. declare module BABYLON {
  91722. /**
  91723. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91725. */
  91726. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91727. /**
  91728. * Defines the camera the input is attached to.
  91729. */
  91730. camera: ArcRotateCamera;
  91731. /**
  91732. * Defines the list of key codes associated with the up action (increase alpha)
  91733. */
  91734. keysUp: number[];
  91735. /**
  91736. * Defines the list of key codes associated with the down action (decrease alpha)
  91737. */
  91738. keysDown: number[];
  91739. /**
  91740. * Defines the list of key codes associated with the left action (increase beta)
  91741. */
  91742. keysLeft: number[];
  91743. /**
  91744. * Defines the list of key codes associated with the right action (decrease beta)
  91745. */
  91746. keysRight: number[];
  91747. /**
  91748. * Defines the list of key codes associated with the reset action.
  91749. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91750. */
  91751. keysReset: number[];
  91752. /**
  91753. * Defines the panning sensibility of the inputs.
  91754. * (How fast is the camera paning)
  91755. */
  91756. panningSensibility: number;
  91757. /**
  91758. * Defines the zooming sensibility of the inputs.
  91759. * (How fast is the camera zooming)
  91760. */
  91761. zoomingSensibility: number;
  91762. /**
  91763. * Defines wether maintaining the alt key down switch the movement mode from
  91764. * orientation to zoom.
  91765. */
  91766. useAltToZoom: boolean;
  91767. /**
  91768. * Rotation speed of the camera
  91769. */
  91770. angularSpeed: number;
  91771. private _keys;
  91772. private _ctrlPressed;
  91773. private _altPressed;
  91774. private _onCanvasBlurObserver;
  91775. private _onKeyboardObserver;
  91776. private _engine;
  91777. private _scene;
  91778. /**
  91779. * Attach the input controls to a specific dom element to get the input from.
  91780. * @param element Defines the element the controls should be listened from
  91781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91782. */
  91783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91784. /**
  91785. * Detach the current controls from the specified dom element.
  91786. * @param element Defines the element to stop listening the inputs from
  91787. */
  91788. detachControl(element: Nullable<HTMLElement>): void;
  91789. /**
  91790. * Update the current camera state depending on the inputs that have been used this frame.
  91791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91792. */
  91793. checkInputs(): void;
  91794. /**
  91795. * Gets the class name of the current intput.
  91796. * @returns the class name
  91797. */
  91798. getClassName(): string;
  91799. /**
  91800. * Get the friendly name associated with the input class.
  91801. * @returns the input friendly name
  91802. */
  91803. getSimpleName(): string;
  91804. }
  91805. }
  91806. declare module BABYLON {
  91807. /**
  91808. * Manage the mouse wheel inputs to control an arc rotate camera.
  91809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91810. */
  91811. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91812. /**
  91813. * Defines the camera the input is attached to.
  91814. */
  91815. camera: ArcRotateCamera;
  91816. /**
  91817. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91818. */
  91819. wheelPrecision: number;
  91820. /**
  91821. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91822. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91823. */
  91824. wheelDeltaPercentage: number;
  91825. private _wheel;
  91826. private _observer;
  91827. /**
  91828. * Attach the input controls to a specific dom element to get the input from.
  91829. * @param element Defines the element the controls should be listened from
  91830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91831. */
  91832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91833. /**
  91834. * Detach the current controls from the specified dom element.
  91835. * @param element Defines the element to stop listening the inputs from
  91836. */
  91837. detachControl(element: Nullable<HTMLElement>): void;
  91838. /**
  91839. * Gets the class name of the current intput.
  91840. * @returns the class name
  91841. */
  91842. getClassName(): string;
  91843. /**
  91844. * Get the friendly name associated with the input class.
  91845. * @returns the input friendly name
  91846. */
  91847. getSimpleName(): string;
  91848. }
  91849. }
  91850. declare module BABYLON {
  91851. /**
  91852. * Default Inputs manager for the ArcRotateCamera.
  91853. * It groups all the default supported inputs for ease of use.
  91854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91855. */
  91856. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91857. /**
  91858. * Instantiates a new ArcRotateCameraInputsManager.
  91859. * @param camera Defines the camera the inputs belong to
  91860. */
  91861. constructor(camera: ArcRotateCamera);
  91862. /**
  91863. * Add mouse wheel input support to the input manager.
  91864. * @returns the current input manager
  91865. */
  91866. addMouseWheel(): ArcRotateCameraInputsManager;
  91867. /**
  91868. * Add pointers input support to the input manager.
  91869. * @returns the current input manager
  91870. */
  91871. addPointers(): ArcRotateCameraInputsManager;
  91872. /**
  91873. * Add keyboard input support to the input manager.
  91874. * @returns the current input manager
  91875. */
  91876. addKeyboard(): ArcRotateCameraInputsManager;
  91877. }
  91878. }
  91879. declare module BABYLON {
  91880. /**
  91881. * This represents an orbital type of camera.
  91882. *
  91883. * 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.
  91884. * 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.
  91885. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91886. */
  91887. export class ArcRotateCamera extends TargetCamera {
  91888. /**
  91889. * Defines the rotation angle of the camera along the longitudinal axis.
  91890. */
  91891. alpha: number;
  91892. /**
  91893. * Defines the rotation angle of the camera along the latitudinal axis.
  91894. */
  91895. beta: number;
  91896. /**
  91897. * Defines the radius of the camera from it s target point.
  91898. */
  91899. radius: number;
  91900. protected _target: Vector3;
  91901. protected _targetHost: Nullable<AbstractMesh>;
  91902. /**
  91903. * Defines the target point of the camera.
  91904. * The camera looks towards it form the radius distance.
  91905. */
  91906. target: Vector3;
  91907. /**
  91908. * Define the current local position of the camera in the scene
  91909. */
  91910. position: Vector3;
  91911. /**
  91912. * Current inertia value on the longitudinal axis.
  91913. * The bigger this number the longer it will take for the camera to stop.
  91914. */
  91915. inertialAlphaOffset: number;
  91916. /**
  91917. * Current inertia value on the latitudinal axis.
  91918. * The bigger this number the longer it will take for the camera to stop.
  91919. */
  91920. inertialBetaOffset: number;
  91921. /**
  91922. * Current inertia value on the radius axis.
  91923. * The bigger this number the longer it will take for the camera to stop.
  91924. */
  91925. inertialRadiusOffset: number;
  91926. /**
  91927. * Minimum allowed angle on the longitudinal axis.
  91928. * This can help limiting how the Camera is able to move in the scene.
  91929. */
  91930. lowerAlphaLimit: Nullable<number>;
  91931. /**
  91932. * Maximum allowed angle on the longitudinal axis.
  91933. * This can help limiting how the Camera is able to move in the scene.
  91934. */
  91935. upperAlphaLimit: Nullable<number>;
  91936. /**
  91937. * Minimum allowed angle on the latitudinal axis.
  91938. * This can help limiting how the Camera is able to move in the scene.
  91939. */
  91940. lowerBetaLimit: number;
  91941. /**
  91942. * Maximum allowed angle on the latitudinal axis.
  91943. * This can help limiting how the Camera is able to move in the scene.
  91944. */
  91945. upperBetaLimit: number;
  91946. /**
  91947. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91948. * This can help limiting how the Camera is able to move in the scene.
  91949. */
  91950. lowerRadiusLimit: Nullable<number>;
  91951. /**
  91952. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91953. * This can help limiting how the Camera is able to move in the scene.
  91954. */
  91955. upperRadiusLimit: Nullable<number>;
  91956. /**
  91957. * Defines the current inertia value used during panning of the camera along the X axis.
  91958. */
  91959. inertialPanningX: number;
  91960. /**
  91961. * Defines the current inertia value used during panning of the camera along the Y axis.
  91962. */
  91963. inertialPanningY: number;
  91964. /**
  91965. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91966. * Basically if your fingers moves away from more than this distance you will be considered
  91967. * in pinch mode.
  91968. */
  91969. pinchToPanMaxDistance: number;
  91970. /**
  91971. * Defines the maximum distance the camera can pan.
  91972. * This could help keeping the cammera always in your scene.
  91973. */
  91974. panningDistanceLimit: Nullable<number>;
  91975. /**
  91976. * Defines the target of the camera before paning.
  91977. */
  91978. panningOriginTarget: Vector3;
  91979. /**
  91980. * Defines the value of the inertia used during panning.
  91981. * 0 would mean stop inertia and one would mean no decelleration at all.
  91982. */
  91983. panningInertia: number;
  91984. /**
  91985. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91986. */
  91987. angularSensibilityX: number;
  91988. /**
  91989. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91990. */
  91991. angularSensibilityY: number;
  91992. /**
  91993. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91994. */
  91995. pinchPrecision: number;
  91996. /**
  91997. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91998. * It will be used instead of pinchDeltaPrecision if different from 0.
  91999. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92000. */
  92001. pinchDeltaPercentage: number;
  92002. /**
  92003. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  92004. */
  92005. panningSensibility: number;
  92006. /**
  92007. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  92008. */
  92009. keysUp: number[];
  92010. /**
  92011. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  92012. */
  92013. keysDown: number[];
  92014. /**
  92015. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  92016. */
  92017. keysLeft: number[];
  92018. /**
  92019. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92020. */
  92021. keysRight: number[];
  92022. /**
  92023. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92024. */
  92025. wheelPrecision: number;
  92026. /**
  92027. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92028. * It will be used instead of pinchDeltaPrecision if different from 0.
  92029. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92030. */
  92031. wheelDeltaPercentage: number;
  92032. /**
  92033. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92034. */
  92035. zoomOnFactor: number;
  92036. /**
  92037. * Defines a screen offset for the camera position.
  92038. */
  92039. targetScreenOffset: Vector2;
  92040. /**
  92041. * Allows the camera to be completely reversed.
  92042. * If false the camera can not arrive upside down.
  92043. */
  92044. allowUpsideDown: boolean;
  92045. /**
  92046. * Define if double tap/click is used to restore the previously saved state of the camera.
  92047. */
  92048. useInputToRestoreState: boolean;
  92049. /** @hidden */
  92050. _viewMatrix: Matrix;
  92051. /** @hidden */
  92052. _useCtrlForPanning: boolean;
  92053. /** @hidden */
  92054. _panningMouseButton: number;
  92055. /**
  92056. * Defines the input associated to the camera.
  92057. */
  92058. inputs: ArcRotateCameraInputsManager;
  92059. /** @hidden */
  92060. _reset: () => void;
  92061. /**
  92062. * Defines the allowed panning axis.
  92063. */
  92064. panningAxis: Vector3;
  92065. protected _localDirection: Vector3;
  92066. protected _transformedDirection: Vector3;
  92067. private _bouncingBehavior;
  92068. /**
  92069. * Gets the bouncing behavior of the camera if it has been enabled.
  92070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92071. */
  92072. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92073. /**
  92074. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92075. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92076. */
  92077. useBouncingBehavior: boolean;
  92078. private _framingBehavior;
  92079. /**
  92080. * Gets the framing behavior of the camera if it has been enabled.
  92081. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92082. */
  92083. readonly framingBehavior: Nullable<FramingBehavior>;
  92084. /**
  92085. * Defines if the framing behavior of the camera is enabled on the camera.
  92086. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92087. */
  92088. useFramingBehavior: boolean;
  92089. private _autoRotationBehavior;
  92090. /**
  92091. * Gets the auto rotation behavior of the camera if it has been enabled.
  92092. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92093. */
  92094. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92095. /**
  92096. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92097. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92098. */
  92099. useAutoRotationBehavior: boolean;
  92100. /**
  92101. * Observable triggered when the mesh target has been changed on the camera.
  92102. */
  92103. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92104. /**
  92105. * Event raised when the camera is colliding with a mesh.
  92106. */
  92107. onCollide: (collidedMesh: AbstractMesh) => void;
  92108. /**
  92109. * Defines whether the camera should check collision with the objects oh the scene.
  92110. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92111. */
  92112. checkCollisions: boolean;
  92113. /**
  92114. * Defines the collision radius of the camera.
  92115. * This simulates a sphere around the camera.
  92116. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92117. */
  92118. collisionRadius: Vector3;
  92119. protected _collider: Collider;
  92120. protected _previousPosition: Vector3;
  92121. protected _collisionVelocity: Vector3;
  92122. protected _newPosition: Vector3;
  92123. protected _previousAlpha: number;
  92124. protected _previousBeta: number;
  92125. protected _previousRadius: number;
  92126. protected _collisionTriggered: boolean;
  92127. protected _targetBoundingCenter: Nullable<Vector3>;
  92128. private _computationVector;
  92129. private _tempAxisVector;
  92130. private _tempAxisRotationMatrix;
  92131. /**
  92132. * Instantiates a new ArcRotateCamera in a given scene
  92133. * @param name Defines the name of the camera
  92134. * @param alpha Defines the camera rotation along the logitudinal axis
  92135. * @param beta Defines the camera rotation along the latitudinal axis
  92136. * @param radius Defines the camera distance from its target
  92137. * @param target Defines the camera target
  92138. * @param scene Defines the scene the camera belongs to
  92139. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92140. */
  92141. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92142. /** @hidden */
  92143. _initCache(): void;
  92144. /** @hidden */
  92145. _updateCache(ignoreParentClass?: boolean): void;
  92146. protected _getTargetPosition(): Vector3;
  92147. private _storedAlpha;
  92148. private _storedBeta;
  92149. private _storedRadius;
  92150. private _storedTarget;
  92151. /**
  92152. * Stores the current state of the camera (alpha, beta, radius and target)
  92153. * @returns the camera itself
  92154. */
  92155. storeState(): Camera;
  92156. /**
  92157. * @hidden
  92158. * Restored camera state. You must call storeState() first
  92159. */
  92160. _restoreStateValues(): boolean;
  92161. /** @hidden */
  92162. _isSynchronizedViewMatrix(): boolean;
  92163. /**
  92164. * Attached controls to the current camera.
  92165. * @param element Defines the element the controls should be listened from
  92166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92167. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92168. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92169. */
  92170. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92171. /**
  92172. * Detach the current controls from the camera.
  92173. * The camera will stop reacting to inputs.
  92174. * @param element Defines the element to stop listening the inputs from
  92175. */
  92176. detachControl(element: HTMLElement): void;
  92177. /** @hidden */
  92178. _checkInputs(): void;
  92179. protected _checkLimits(): void;
  92180. /**
  92181. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92182. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92183. */
  92184. rebuildAnglesAndRadius(updateView?: boolean): void;
  92185. /**
  92186. * Use a position to define the current camera related information like aplha, beta and radius
  92187. * @param position Defines the position to set the camera at
  92188. */
  92189. setPosition(position: Vector3): void;
  92190. /**
  92191. * Defines the target the camera should look at.
  92192. * This will automatically adapt alpha beta and radius to fit within the new target.
  92193. * @param target Defines the new target as a Vector or a mesh
  92194. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92195. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92196. */
  92197. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92198. /** @hidden */
  92199. _getViewMatrix(): Matrix;
  92200. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92201. /**
  92202. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92203. * @param meshes Defines the mesh to zoom on
  92204. * @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)
  92205. */
  92206. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92207. /**
  92208. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92209. * The target will be changed but the radius
  92210. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92211. * @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)
  92212. */
  92213. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92214. min: Vector3;
  92215. max: Vector3;
  92216. distance: number;
  92217. }, doNotUpdateMaxZ?: boolean): void;
  92218. /**
  92219. * @override
  92220. * Override Camera.createRigCamera
  92221. */
  92222. createRigCamera(name: string, cameraIndex: number): Camera;
  92223. /**
  92224. * @hidden
  92225. * @override
  92226. * Override Camera._updateRigCameras
  92227. */
  92228. _updateRigCameras(): void;
  92229. /**
  92230. * Destroy the camera and release the current resources hold by it.
  92231. */
  92232. dispose(): void;
  92233. /**
  92234. * Gets the current object class name.
  92235. * @return the class name
  92236. */
  92237. getClassName(): string;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /**
  92242. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92244. */
  92245. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92246. /**
  92247. * Gets the name of the behavior.
  92248. */
  92249. readonly name: string;
  92250. private _zoomStopsAnimation;
  92251. private _idleRotationSpeed;
  92252. private _idleRotationWaitTime;
  92253. private _idleRotationSpinupTime;
  92254. /**
  92255. * Sets the flag that indicates if user zooming should stop animation.
  92256. */
  92257. /**
  92258. * Gets the flag that indicates if user zooming should stop animation.
  92259. */
  92260. zoomStopsAnimation: boolean;
  92261. /**
  92262. * Sets the default speed at which the camera rotates around the model.
  92263. */
  92264. /**
  92265. * Gets the default speed at which the camera rotates around the model.
  92266. */
  92267. idleRotationSpeed: number;
  92268. /**
  92269. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92270. */
  92271. /**
  92272. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92273. */
  92274. idleRotationWaitTime: number;
  92275. /**
  92276. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92277. */
  92278. /**
  92279. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92280. */
  92281. idleRotationSpinupTime: number;
  92282. /**
  92283. * Gets a value indicating if the camera is currently rotating because of this behavior
  92284. */
  92285. readonly rotationInProgress: boolean;
  92286. private _onPrePointerObservableObserver;
  92287. private _onAfterCheckInputsObserver;
  92288. private _attachedCamera;
  92289. private _isPointerDown;
  92290. private _lastFrameTime;
  92291. private _lastInteractionTime;
  92292. private _cameraRotationSpeed;
  92293. /**
  92294. * Initializes the behavior.
  92295. */
  92296. init(): void;
  92297. /**
  92298. * Attaches the behavior to its arc rotate camera.
  92299. * @param camera Defines the camera to attach the behavior to
  92300. */
  92301. attach(camera: ArcRotateCamera): void;
  92302. /**
  92303. * Detaches the behavior from its current arc rotate camera.
  92304. */
  92305. detach(): void;
  92306. /**
  92307. * Returns true if user is scrolling.
  92308. * @return true if user is scrolling.
  92309. */
  92310. private _userIsZooming;
  92311. private _lastFrameRadius;
  92312. private _shouldAnimationStopForInteraction;
  92313. /**
  92314. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92315. */
  92316. private _applyUserInteraction;
  92317. private _userIsMoving;
  92318. }
  92319. }
  92320. declare module BABYLON {
  92321. /**
  92322. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92323. */
  92324. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92325. private ui;
  92326. /**
  92327. * The name of the behavior
  92328. */
  92329. name: string;
  92330. /**
  92331. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92332. */
  92333. distanceAwayFromFace: number;
  92334. /**
  92335. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92336. */
  92337. distanceAwayFromBottomOfFace: number;
  92338. private _faceVectors;
  92339. private _target;
  92340. private _scene;
  92341. private _onRenderObserver;
  92342. private _tmpMatrix;
  92343. private _tmpVector;
  92344. /**
  92345. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92346. * @param ui The transform node that should be attched to the mesh
  92347. */
  92348. constructor(ui: TransformNode);
  92349. /**
  92350. * Initializes the behavior
  92351. */
  92352. init(): void;
  92353. private _closestFace;
  92354. private _zeroVector;
  92355. private _lookAtTmpMatrix;
  92356. private _lookAtToRef;
  92357. /**
  92358. * Attaches the AttachToBoxBehavior to the passed in mesh
  92359. * @param target The mesh that the specified node will be attached to
  92360. */
  92361. attach(target: Mesh): void;
  92362. /**
  92363. * Detaches the behavior from the mesh
  92364. */
  92365. detach(): void;
  92366. }
  92367. }
  92368. declare module BABYLON {
  92369. /**
  92370. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92371. */
  92372. export class FadeInOutBehavior implements Behavior<Mesh> {
  92373. /**
  92374. * Time in milliseconds to delay before fading in (Default: 0)
  92375. */
  92376. delay: number;
  92377. /**
  92378. * Time in milliseconds for the mesh to fade in (Default: 300)
  92379. */
  92380. fadeInTime: number;
  92381. private _millisecondsPerFrame;
  92382. private _hovered;
  92383. private _hoverValue;
  92384. private _ownerNode;
  92385. /**
  92386. * Instatiates the FadeInOutBehavior
  92387. */
  92388. constructor();
  92389. /**
  92390. * The name of the behavior
  92391. */
  92392. readonly name: string;
  92393. /**
  92394. * Initializes the behavior
  92395. */
  92396. init(): void;
  92397. /**
  92398. * Attaches the fade behavior on the passed in mesh
  92399. * @param ownerNode The mesh that will be faded in/out once attached
  92400. */
  92401. attach(ownerNode: Mesh): void;
  92402. /**
  92403. * Detaches the behavior from the mesh
  92404. */
  92405. detach(): void;
  92406. /**
  92407. * Triggers the mesh to begin fading in or out
  92408. * @param value if the object should fade in or out (true to fade in)
  92409. */
  92410. fadeIn(value: boolean): void;
  92411. private _update;
  92412. private _setAllVisibility;
  92413. }
  92414. }
  92415. declare module BABYLON {
  92416. /**
  92417. * Class containing a set of static utilities functions for managing Pivots
  92418. * @hidden
  92419. */
  92420. export class PivotTools {
  92421. private static _PivotCached;
  92422. private static _OldPivotPoint;
  92423. private static _PivotTranslation;
  92424. private static _PivotTmpVector;
  92425. /** @hidden */
  92426. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92427. /** @hidden */
  92428. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92429. }
  92430. }
  92431. declare module BABYLON {
  92432. /**
  92433. * Class containing static functions to help procedurally build meshes
  92434. */
  92435. export class PlaneBuilder {
  92436. /**
  92437. * Creates a plane mesh
  92438. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92439. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92440. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92442. * * If you create a double-sided mesh, you can choose what parts of 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
  92443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92444. * @param name defines the name of the mesh
  92445. * @param options defines the options used to create the mesh
  92446. * @param scene defines the hosting scene
  92447. * @returns the plane mesh
  92448. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92449. */
  92450. static CreatePlane(name: string, options: {
  92451. size?: number;
  92452. width?: number;
  92453. height?: number;
  92454. sideOrientation?: number;
  92455. frontUVs?: Vector4;
  92456. backUVs?: Vector4;
  92457. updatable?: boolean;
  92458. sourcePlane?: Plane;
  92459. }, scene: Scene): Mesh;
  92460. }
  92461. }
  92462. declare module BABYLON {
  92463. /**
  92464. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92465. */
  92466. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92467. private static _AnyMouseID;
  92468. private _attachedNode;
  92469. private _dragPlane;
  92470. private _scene;
  92471. private _pointerObserver;
  92472. private _beforeRenderObserver;
  92473. private static _planeScene;
  92474. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92475. /**
  92476. * 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)
  92477. */
  92478. maxDragAngle: number;
  92479. /**
  92480. * @hidden
  92481. */
  92482. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92483. /**
  92484. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92485. */
  92486. currentDraggingPointerID: number;
  92487. /**
  92488. * The last position where the pointer hit the drag plane in world space
  92489. */
  92490. lastDragPosition: Vector3;
  92491. /**
  92492. * If the behavior is currently in a dragging state
  92493. */
  92494. dragging: boolean;
  92495. /**
  92496. * 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)
  92497. */
  92498. dragDeltaRatio: number;
  92499. /**
  92500. * If the drag plane orientation should be updated during the dragging (Default: true)
  92501. */
  92502. updateDragPlane: boolean;
  92503. private _debugMode;
  92504. private _moving;
  92505. /**
  92506. * Fires each time the attached mesh is dragged with the pointer
  92507. * * delta between last drag position and current drag position in world space
  92508. * * dragDistance along the drag axis
  92509. * * dragPlaneNormal normal of the current drag plane used during the drag
  92510. * * dragPlanePoint in world space where the drag intersects the drag plane
  92511. */
  92512. onDragObservable: Observable<{
  92513. delta: Vector3;
  92514. dragPlanePoint: Vector3;
  92515. dragPlaneNormal: Vector3;
  92516. dragDistance: number;
  92517. pointerId: number;
  92518. }>;
  92519. /**
  92520. * Fires each time a drag begins (eg. mouse down on mesh)
  92521. */
  92522. onDragStartObservable: Observable<{
  92523. dragPlanePoint: Vector3;
  92524. pointerId: number;
  92525. }>;
  92526. /**
  92527. * Fires each time a drag ends (eg. mouse release after drag)
  92528. */
  92529. onDragEndObservable: Observable<{
  92530. dragPlanePoint: Vector3;
  92531. pointerId: number;
  92532. }>;
  92533. /**
  92534. * If the attached mesh should be moved when dragged
  92535. */
  92536. moveAttached: boolean;
  92537. /**
  92538. * If the drag behavior will react to drag events (Default: true)
  92539. */
  92540. enabled: boolean;
  92541. /**
  92542. * If camera controls should be detached during the drag
  92543. */
  92544. detachCameraControls: boolean;
  92545. /**
  92546. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92547. */
  92548. useObjectOrienationForDragging: boolean;
  92549. private _options;
  92550. /**
  92551. * Creates a pointer drag behavior that can be attached to a mesh
  92552. * @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)
  92553. */
  92554. constructor(options?: {
  92555. dragAxis?: Vector3;
  92556. dragPlaneNormal?: Vector3;
  92557. });
  92558. /**
  92559. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92560. */
  92561. validateDrag: (targetPosition: Vector3) => boolean;
  92562. /**
  92563. * The name of the behavior
  92564. */
  92565. readonly name: string;
  92566. /**
  92567. * Initializes the behavior
  92568. */
  92569. init(): void;
  92570. private _tmpVector;
  92571. private _alternatePickedPoint;
  92572. private _worldDragAxis;
  92573. private _targetPosition;
  92574. private _attachedElement;
  92575. /**
  92576. * Attaches the drag behavior the passed in mesh
  92577. * @param ownerNode The mesh that will be dragged around once attached
  92578. */
  92579. attach(ownerNode: AbstractMesh): void;
  92580. /**
  92581. * Force relase the drag action by code.
  92582. */
  92583. releaseDrag(): void;
  92584. private _startDragRay;
  92585. private _lastPointerRay;
  92586. /**
  92587. * Simulates the start of a pointer drag event on the behavior
  92588. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92589. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92590. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92591. */
  92592. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92593. private _startDrag;
  92594. private _dragDelta;
  92595. private _moveDrag;
  92596. private _pickWithRayOnDragPlane;
  92597. private _pointA;
  92598. private _pointB;
  92599. private _pointC;
  92600. private _lineA;
  92601. private _lineB;
  92602. private _localAxis;
  92603. private _lookAt;
  92604. private _updateDragPlanePosition;
  92605. /**
  92606. * Detaches the behavior from the mesh
  92607. */
  92608. detach(): void;
  92609. }
  92610. }
  92611. declare module BABYLON {
  92612. /**
  92613. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92614. */
  92615. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92616. private _dragBehaviorA;
  92617. private _dragBehaviorB;
  92618. private _startDistance;
  92619. private _initialScale;
  92620. private _targetScale;
  92621. private _ownerNode;
  92622. private _sceneRenderObserver;
  92623. /**
  92624. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92625. */
  92626. constructor();
  92627. /**
  92628. * The name of the behavior
  92629. */
  92630. readonly name: string;
  92631. /**
  92632. * Initializes the behavior
  92633. */
  92634. init(): void;
  92635. private _getCurrentDistance;
  92636. /**
  92637. * Attaches the scale behavior the passed in mesh
  92638. * @param ownerNode The mesh that will be scaled around once attached
  92639. */
  92640. attach(ownerNode: Mesh): void;
  92641. /**
  92642. * Detaches the behavior from the mesh
  92643. */
  92644. detach(): void;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. /**
  92649. * 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
  92650. */
  92651. export class SixDofDragBehavior implements Behavior<Mesh> {
  92652. private static _virtualScene;
  92653. private _ownerNode;
  92654. private _sceneRenderObserver;
  92655. private _scene;
  92656. private _targetPosition;
  92657. private _virtualOriginMesh;
  92658. private _virtualDragMesh;
  92659. private _pointerObserver;
  92660. private _moving;
  92661. private _startingOrientation;
  92662. /**
  92663. * 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)
  92664. */
  92665. private zDragFactor;
  92666. /**
  92667. * If the object should rotate to face the drag origin
  92668. */
  92669. rotateDraggedObject: boolean;
  92670. /**
  92671. * If the behavior is currently in a dragging state
  92672. */
  92673. dragging: boolean;
  92674. /**
  92675. * 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)
  92676. */
  92677. dragDeltaRatio: number;
  92678. /**
  92679. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92680. */
  92681. currentDraggingPointerID: number;
  92682. /**
  92683. * If camera controls should be detached during the drag
  92684. */
  92685. detachCameraControls: boolean;
  92686. /**
  92687. * Fires each time a drag starts
  92688. */
  92689. onDragStartObservable: Observable<{}>;
  92690. /**
  92691. * Fires each time a drag ends (eg. mouse release after drag)
  92692. */
  92693. onDragEndObservable: Observable<{}>;
  92694. /**
  92695. * 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
  92696. */
  92697. constructor();
  92698. /**
  92699. * The name of the behavior
  92700. */
  92701. readonly name: string;
  92702. /**
  92703. * Initializes the behavior
  92704. */
  92705. init(): void;
  92706. /**
  92707. * Attaches the scale behavior the passed in mesh
  92708. * @param ownerNode The mesh that will be scaled around once attached
  92709. */
  92710. attach(ownerNode: Mesh): void;
  92711. /**
  92712. * Detaches the behavior from the mesh
  92713. */
  92714. detach(): void;
  92715. }
  92716. }
  92717. declare module BABYLON {
  92718. /**
  92719. * Class used to apply inverse kinematics to bones
  92720. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92721. */
  92722. export class BoneIKController {
  92723. private static _tmpVecs;
  92724. private static _tmpQuat;
  92725. private static _tmpMats;
  92726. /**
  92727. * Gets or sets the target mesh
  92728. */
  92729. targetMesh: AbstractMesh;
  92730. /** Gets or sets the mesh used as pole */
  92731. poleTargetMesh: AbstractMesh;
  92732. /**
  92733. * Gets or sets the bone used as pole
  92734. */
  92735. poleTargetBone: Nullable<Bone>;
  92736. /**
  92737. * Gets or sets the target position
  92738. */
  92739. targetPosition: Vector3;
  92740. /**
  92741. * Gets or sets the pole target position
  92742. */
  92743. poleTargetPosition: Vector3;
  92744. /**
  92745. * Gets or sets the pole target local offset
  92746. */
  92747. poleTargetLocalOffset: Vector3;
  92748. /**
  92749. * Gets or sets the pole angle
  92750. */
  92751. poleAngle: number;
  92752. /**
  92753. * Gets or sets the mesh associated with the controller
  92754. */
  92755. mesh: AbstractMesh;
  92756. /**
  92757. * 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)
  92758. */
  92759. slerpAmount: number;
  92760. private _bone1Quat;
  92761. private _bone1Mat;
  92762. private _bone2Ang;
  92763. private _bone1;
  92764. private _bone2;
  92765. private _bone1Length;
  92766. private _bone2Length;
  92767. private _maxAngle;
  92768. private _maxReach;
  92769. private _rightHandedSystem;
  92770. private _bendAxis;
  92771. private _slerping;
  92772. private _adjustRoll;
  92773. /**
  92774. * Gets or sets maximum allowed angle
  92775. */
  92776. maxAngle: number;
  92777. /**
  92778. * Creates a new BoneIKController
  92779. * @param mesh defines the mesh to control
  92780. * @param bone defines the bone to control
  92781. * @param options defines options to set up the controller
  92782. */
  92783. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92784. targetMesh?: AbstractMesh;
  92785. poleTargetMesh?: AbstractMesh;
  92786. poleTargetBone?: Bone;
  92787. poleTargetLocalOffset?: Vector3;
  92788. poleAngle?: number;
  92789. bendAxis?: Vector3;
  92790. maxAngle?: number;
  92791. slerpAmount?: number;
  92792. });
  92793. private _setMaxAngle;
  92794. /**
  92795. * Force the controller to update the bones
  92796. */
  92797. update(): void;
  92798. }
  92799. }
  92800. declare module BABYLON {
  92801. /**
  92802. * Class used to make a bone look toward a point in space
  92803. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92804. */
  92805. export class BoneLookController {
  92806. private static _tmpVecs;
  92807. private static _tmpQuat;
  92808. private static _tmpMats;
  92809. /**
  92810. * The target Vector3 that the bone will look at
  92811. */
  92812. target: Vector3;
  92813. /**
  92814. * The mesh that the bone is attached to
  92815. */
  92816. mesh: AbstractMesh;
  92817. /**
  92818. * The bone that will be looking to the target
  92819. */
  92820. bone: Bone;
  92821. /**
  92822. * The up axis of the coordinate system that is used when the bone is rotated
  92823. */
  92824. upAxis: Vector3;
  92825. /**
  92826. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92827. */
  92828. upAxisSpace: Space;
  92829. /**
  92830. * Used to make an adjustment to the yaw of the bone
  92831. */
  92832. adjustYaw: number;
  92833. /**
  92834. * Used to make an adjustment to the pitch of the bone
  92835. */
  92836. adjustPitch: number;
  92837. /**
  92838. * Used to make an adjustment to the roll of the bone
  92839. */
  92840. adjustRoll: number;
  92841. /**
  92842. * 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)
  92843. */
  92844. slerpAmount: number;
  92845. private _minYaw;
  92846. private _maxYaw;
  92847. private _minPitch;
  92848. private _maxPitch;
  92849. private _minYawSin;
  92850. private _minYawCos;
  92851. private _maxYawSin;
  92852. private _maxYawCos;
  92853. private _midYawConstraint;
  92854. private _minPitchTan;
  92855. private _maxPitchTan;
  92856. private _boneQuat;
  92857. private _slerping;
  92858. private _transformYawPitch;
  92859. private _transformYawPitchInv;
  92860. private _firstFrameSkipped;
  92861. private _yawRange;
  92862. private _fowardAxis;
  92863. /**
  92864. * Gets or sets the minimum yaw angle that the bone can look to
  92865. */
  92866. minYaw: number;
  92867. /**
  92868. * Gets or sets the maximum yaw angle that the bone can look to
  92869. */
  92870. maxYaw: number;
  92871. /**
  92872. * Gets or sets the minimum pitch angle that the bone can look to
  92873. */
  92874. minPitch: number;
  92875. /**
  92876. * Gets or sets the maximum pitch angle that the bone can look to
  92877. */
  92878. maxPitch: number;
  92879. /**
  92880. * Create a BoneLookController
  92881. * @param mesh the mesh that the bone belongs to
  92882. * @param bone the bone that will be looking to the target
  92883. * @param target the target Vector3 to look at
  92884. * @param options optional settings:
  92885. * * maxYaw: the maximum angle the bone will yaw to
  92886. * * minYaw: the minimum angle the bone will yaw to
  92887. * * maxPitch: the maximum angle the bone will pitch to
  92888. * * minPitch: the minimum angle the bone will yaw to
  92889. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92890. * * upAxis: the up axis of the coordinate system
  92891. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92892. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92893. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92894. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92895. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92896. * * adjustRoll: used to make an adjustment to the roll of the bone
  92897. **/
  92898. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92899. maxYaw?: number;
  92900. minYaw?: number;
  92901. maxPitch?: number;
  92902. minPitch?: number;
  92903. slerpAmount?: number;
  92904. upAxis?: Vector3;
  92905. upAxisSpace?: Space;
  92906. yawAxis?: Vector3;
  92907. pitchAxis?: Vector3;
  92908. adjustYaw?: number;
  92909. adjustPitch?: number;
  92910. adjustRoll?: number;
  92911. });
  92912. /**
  92913. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92914. */
  92915. update(): void;
  92916. private _getAngleDiff;
  92917. private _getAngleBetween;
  92918. private _isAngleBetween;
  92919. }
  92920. }
  92921. declare module BABYLON {
  92922. /**
  92923. * Manage the gamepad inputs to control an arc rotate camera.
  92924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92925. */
  92926. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92927. /**
  92928. * Defines the camera the input is attached to.
  92929. */
  92930. camera: ArcRotateCamera;
  92931. /**
  92932. * Defines the gamepad the input is gathering event from.
  92933. */
  92934. gamepad: Nullable<Gamepad>;
  92935. /**
  92936. * Defines the gamepad rotation sensiblity.
  92937. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92938. */
  92939. gamepadRotationSensibility: number;
  92940. /**
  92941. * Defines the gamepad move sensiblity.
  92942. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92943. */
  92944. gamepadMoveSensibility: number;
  92945. private _onGamepadConnectedObserver;
  92946. private _onGamepadDisconnectedObserver;
  92947. /**
  92948. * Attach the input controls to a specific dom element to get the input from.
  92949. * @param element Defines the element the controls should be listened from
  92950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92951. */
  92952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92953. /**
  92954. * Detach the current controls from the specified dom element.
  92955. * @param element Defines the element to stop listening the inputs from
  92956. */
  92957. detachControl(element: Nullable<HTMLElement>): void;
  92958. /**
  92959. * Update the current camera state depending on the inputs that have been used this frame.
  92960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92961. */
  92962. checkInputs(): void;
  92963. /**
  92964. * Gets the class name of the current intput.
  92965. * @returns the class name
  92966. */
  92967. getClassName(): string;
  92968. /**
  92969. * Get the friendly name associated with the input class.
  92970. * @returns the input friendly name
  92971. */
  92972. getSimpleName(): string;
  92973. }
  92974. }
  92975. declare module BABYLON {
  92976. interface ArcRotateCameraInputsManager {
  92977. /**
  92978. * Add orientation input support to the input manager.
  92979. * @returns the current input manager
  92980. */
  92981. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92982. }
  92983. /**
  92984. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92986. */
  92987. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92988. /**
  92989. * Defines the camera the input is attached to.
  92990. */
  92991. camera: ArcRotateCamera;
  92992. /**
  92993. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92994. */
  92995. alphaCorrection: number;
  92996. /**
  92997. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92998. */
  92999. gammaCorrection: number;
  93000. private _alpha;
  93001. private _gamma;
  93002. private _dirty;
  93003. private _deviceOrientationHandler;
  93004. /**
  93005. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  93006. */
  93007. constructor();
  93008. /**
  93009. * Attach the input controls to a specific dom element to get the input from.
  93010. * @param element Defines the element the controls should be listened from
  93011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93012. */
  93013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93014. /** @hidden */
  93015. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  93016. /**
  93017. * Update the current camera state depending on the inputs that have been used this frame.
  93018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93019. */
  93020. checkInputs(): void;
  93021. /**
  93022. * Detach the current controls from the specified dom element.
  93023. * @param element Defines the element to stop listening the inputs from
  93024. */
  93025. detachControl(element: Nullable<HTMLElement>): void;
  93026. /**
  93027. * Gets the class name of the current intput.
  93028. * @returns the class name
  93029. */
  93030. getClassName(): string;
  93031. /**
  93032. * Get the friendly name associated with the input class.
  93033. * @returns the input friendly name
  93034. */
  93035. getSimpleName(): string;
  93036. }
  93037. }
  93038. declare module BABYLON {
  93039. /**
  93040. * Listen to mouse events to control the camera.
  93041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93042. */
  93043. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93044. /**
  93045. * Defines the camera the input is attached to.
  93046. */
  93047. camera: FlyCamera;
  93048. /**
  93049. * Defines if touch is enabled. (Default is true.)
  93050. */
  93051. touchEnabled: boolean;
  93052. /**
  93053. * Defines the buttons associated with the input to handle camera rotation.
  93054. */
  93055. buttons: number[];
  93056. /**
  93057. * Assign buttons for Yaw control.
  93058. */
  93059. buttonsYaw: number[];
  93060. /**
  93061. * Assign buttons for Pitch control.
  93062. */
  93063. buttonsPitch: number[];
  93064. /**
  93065. * Assign buttons for Roll control.
  93066. */
  93067. buttonsRoll: number[];
  93068. /**
  93069. * Detect if any button is being pressed while mouse is moved.
  93070. * -1 = Mouse locked.
  93071. * 0 = Left button.
  93072. * 1 = Middle Button.
  93073. * 2 = Right Button.
  93074. */
  93075. activeButton: number;
  93076. /**
  93077. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93078. * Higher values reduce its sensitivity.
  93079. */
  93080. angularSensibility: number;
  93081. private _mousemoveCallback;
  93082. private _observer;
  93083. private _rollObserver;
  93084. private previousPosition;
  93085. private noPreventDefault;
  93086. private element;
  93087. /**
  93088. * Listen to mouse events to control the camera.
  93089. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93091. */
  93092. constructor(touchEnabled?: boolean);
  93093. /**
  93094. * Attach the mouse control to the HTML DOM element.
  93095. * @param element Defines the element that listens to the input events.
  93096. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93097. */
  93098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93099. /**
  93100. * Detach the current controls from the specified dom element.
  93101. * @param element Defines the element to stop listening the inputs from
  93102. */
  93103. detachControl(element: Nullable<HTMLElement>): void;
  93104. /**
  93105. * Gets the class name of the current input.
  93106. * @returns the class name.
  93107. */
  93108. getClassName(): string;
  93109. /**
  93110. * Get the friendly name associated with the input class.
  93111. * @returns the input's friendly name.
  93112. */
  93113. getSimpleName(): string;
  93114. private _pointerInput;
  93115. private _onMouseMove;
  93116. /**
  93117. * Rotate camera by mouse offset.
  93118. */
  93119. private rotateCamera;
  93120. }
  93121. }
  93122. declare module BABYLON {
  93123. /**
  93124. * Default Inputs manager for the FlyCamera.
  93125. * It groups all the default supported inputs for ease of use.
  93126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93127. */
  93128. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93129. /**
  93130. * Instantiates a new FlyCameraInputsManager.
  93131. * @param camera Defines the camera the inputs belong to.
  93132. */
  93133. constructor(camera: FlyCamera);
  93134. /**
  93135. * Add keyboard input support to the input manager.
  93136. * @returns the new FlyCameraKeyboardMoveInput().
  93137. */
  93138. addKeyboard(): FlyCameraInputsManager;
  93139. /**
  93140. * Add mouse input support to the input manager.
  93141. * @param touchEnabled Enable touch screen support.
  93142. * @returns the new FlyCameraMouseInput().
  93143. */
  93144. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93145. }
  93146. }
  93147. declare module BABYLON {
  93148. /**
  93149. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93150. * such as in a 3D Space Shooter or a Flight Simulator.
  93151. */
  93152. export class FlyCamera extends TargetCamera {
  93153. /**
  93154. * Define the collision ellipsoid of the camera.
  93155. * This is helpful for simulating a camera body, like a player's body.
  93156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93157. */
  93158. ellipsoid: Vector3;
  93159. /**
  93160. * Define an offset for the position of the ellipsoid around the camera.
  93161. * This can be helpful if the camera is attached away from the player's body center,
  93162. * such as at its head.
  93163. */
  93164. ellipsoidOffset: Vector3;
  93165. /**
  93166. * Enable or disable collisions of the camera with the rest of the scene objects.
  93167. */
  93168. checkCollisions: boolean;
  93169. /**
  93170. * Enable or disable gravity on the camera.
  93171. */
  93172. applyGravity: boolean;
  93173. /**
  93174. * Define the current direction the camera is moving to.
  93175. */
  93176. cameraDirection: Vector3;
  93177. /**
  93178. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93179. * This overrides and empties cameraRotation.
  93180. */
  93181. rotationQuaternion: Quaternion;
  93182. /**
  93183. * Track Roll to maintain the wanted Rolling when looking around.
  93184. */
  93185. _trackRoll: number;
  93186. /**
  93187. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93188. */
  93189. rollCorrect: number;
  93190. /**
  93191. * Mimic a banked turn, Rolling the camera when Yawing.
  93192. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93193. */
  93194. bankedTurn: boolean;
  93195. /**
  93196. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93197. */
  93198. bankedTurnLimit: number;
  93199. /**
  93200. * Value of 0 disables the banked Roll.
  93201. * Value of 1 is equal to the Yaw angle in radians.
  93202. */
  93203. bankedTurnMultiplier: number;
  93204. /**
  93205. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93206. */
  93207. inputs: FlyCameraInputsManager;
  93208. /**
  93209. * Gets the input sensibility for mouse input.
  93210. * Higher values reduce sensitivity.
  93211. */
  93212. /**
  93213. * Sets the input sensibility for a mouse input.
  93214. * Higher values reduce sensitivity.
  93215. */
  93216. angularSensibility: number;
  93217. /**
  93218. * Get the keys for camera movement forward.
  93219. */
  93220. /**
  93221. * Set the keys for camera movement forward.
  93222. */
  93223. keysForward: number[];
  93224. /**
  93225. * Get the keys for camera movement backward.
  93226. */
  93227. keysBackward: number[];
  93228. /**
  93229. * Get the keys for camera movement up.
  93230. */
  93231. /**
  93232. * Set the keys for camera movement up.
  93233. */
  93234. keysUp: number[];
  93235. /**
  93236. * Get the keys for camera movement down.
  93237. */
  93238. /**
  93239. * Set the keys for camera movement down.
  93240. */
  93241. keysDown: number[];
  93242. /**
  93243. * Get the keys for camera movement left.
  93244. */
  93245. /**
  93246. * Set the keys for camera movement left.
  93247. */
  93248. keysLeft: number[];
  93249. /**
  93250. * Set the keys for camera movement right.
  93251. */
  93252. /**
  93253. * Set the keys for camera movement right.
  93254. */
  93255. keysRight: number[];
  93256. /**
  93257. * Event raised when the camera collides with a mesh in the scene.
  93258. */
  93259. onCollide: (collidedMesh: AbstractMesh) => void;
  93260. private _collider;
  93261. private _needMoveForGravity;
  93262. private _oldPosition;
  93263. private _diffPosition;
  93264. private _newPosition;
  93265. /** @hidden */
  93266. _localDirection: Vector3;
  93267. /** @hidden */
  93268. _transformedDirection: Vector3;
  93269. /**
  93270. * Instantiates a FlyCamera.
  93271. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93272. * such as in a 3D Space Shooter or a Flight Simulator.
  93273. * @param name Define the name of the camera in the scene.
  93274. * @param position Define the starting position of the camera in the scene.
  93275. * @param scene Define the scene the camera belongs to.
  93276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93277. */
  93278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93279. /**
  93280. * Attach a control to the HTML DOM element.
  93281. * @param element Defines the element that listens to the input events.
  93282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93283. */
  93284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93285. /**
  93286. * Detach a control from the HTML DOM element.
  93287. * The camera will stop reacting to that input.
  93288. * @param element Defines the element that listens to the input events.
  93289. */
  93290. detachControl(element: HTMLElement): void;
  93291. private _collisionMask;
  93292. /**
  93293. * Get the mask that the camera ignores in collision events.
  93294. */
  93295. /**
  93296. * Set the mask that the camera ignores in collision events.
  93297. */
  93298. collisionMask: number;
  93299. /** @hidden */
  93300. _collideWithWorld(displacement: Vector3): void;
  93301. /** @hidden */
  93302. private _onCollisionPositionChange;
  93303. /** @hidden */
  93304. _checkInputs(): void;
  93305. /** @hidden */
  93306. _decideIfNeedsToMove(): boolean;
  93307. /** @hidden */
  93308. _updatePosition(): void;
  93309. /**
  93310. * Restore the Roll to its target value at the rate specified.
  93311. * @param rate - Higher means slower restoring.
  93312. * @hidden
  93313. */
  93314. restoreRoll(rate: number): void;
  93315. /**
  93316. * Destroy the camera and release the current resources held by it.
  93317. */
  93318. dispose(): void;
  93319. /**
  93320. * Get the current object class name.
  93321. * @returns the class name.
  93322. */
  93323. getClassName(): string;
  93324. }
  93325. }
  93326. declare module BABYLON {
  93327. /**
  93328. * Listen to keyboard events to control the camera.
  93329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93330. */
  93331. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93332. /**
  93333. * Defines the camera the input is attached to.
  93334. */
  93335. camera: FlyCamera;
  93336. /**
  93337. * The list of keyboard keys used to control the forward move of the camera.
  93338. */
  93339. keysForward: number[];
  93340. /**
  93341. * The list of keyboard keys used to control the backward move of the camera.
  93342. */
  93343. keysBackward: number[];
  93344. /**
  93345. * The list of keyboard keys used to control the forward move of the camera.
  93346. */
  93347. keysUp: number[];
  93348. /**
  93349. * The list of keyboard keys used to control the backward move of the camera.
  93350. */
  93351. keysDown: number[];
  93352. /**
  93353. * The list of keyboard keys used to control the right strafe move of the camera.
  93354. */
  93355. keysRight: number[];
  93356. /**
  93357. * The list of keyboard keys used to control the left strafe move of the camera.
  93358. */
  93359. keysLeft: number[];
  93360. private _keys;
  93361. private _onCanvasBlurObserver;
  93362. private _onKeyboardObserver;
  93363. private _engine;
  93364. private _scene;
  93365. /**
  93366. * Attach the input controls to a specific dom element to get the input from.
  93367. * @param element Defines the element the controls should be listened from
  93368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93369. */
  93370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93371. /**
  93372. * Detach the current controls from the specified dom element.
  93373. * @param element Defines the element to stop listening the inputs from
  93374. */
  93375. detachControl(element: Nullable<HTMLElement>): void;
  93376. /**
  93377. * Gets the class name of the current intput.
  93378. * @returns the class name
  93379. */
  93380. getClassName(): string;
  93381. /** @hidden */
  93382. _onLostFocus(e: FocusEvent): void;
  93383. /**
  93384. * Get the friendly name associated with the input class.
  93385. * @returns the input friendly name
  93386. */
  93387. getSimpleName(): string;
  93388. /**
  93389. * Update the current camera state depending on the inputs that have been used this frame.
  93390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93391. */
  93392. checkInputs(): void;
  93393. }
  93394. }
  93395. declare module BABYLON {
  93396. /**
  93397. * Manage the mouse wheel inputs to control a follow camera.
  93398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93399. */
  93400. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93401. /**
  93402. * Defines the camera the input is attached to.
  93403. */
  93404. camera: FollowCamera;
  93405. /**
  93406. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93407. */
  93408. axisControlRadius: boolean;
  93409. /**
  93410. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93411. */
  93412. axisControlHeight: boolean;
  93413. /**
  93414. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93415. */
  93416. axisControlRotation: boolean;
  93417. /**
  93418. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93419. * relation to mouseWheel events.
  93420. */
  93421. wheelPrecision: number;
  93422. /**
  93423. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93424. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93425. */
  93426. wheelDeltaPercentage: number;
  93427. private _wheel;
  93428. private _observer;
  93429. /**
  93430. * Attach the input controls to a specific dom element to get the input from.
  93431. * @param element Defines the element the controls should be listened from
  93432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93433. */
  93434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93435. /**
  93436. * Detach the current controls from the specified dom element.
  93437. * @param element Defines the element to stop listening the inputs from
  93438. */
  93439. detachControl(element: Nullable<HTMLElement>): void;
  93440. /**
  93441. * Gets the class name of the current intput.
  93442. * @returns the class name
  93443. */
  93444. getClassName(): string;
  93445. /**
  93446. * Get the friendly name associated with the input class.
  93447. * @returns the input friendly name
  93448. */
  93449. getSimpleName(): string;
  93450. }
  93451. }
  93452. declare module BABYLON {
  93453. /**
  93454. * Manage the pointers inputs to control an follow camera.
  93455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93456. */
  93457. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93458. /**
  93459. * Defines the camera the input is attached to.
  93460. */
  93461. camera: FollowCamera;
  93462. /**
  93463. * Gets the class name of the current input.
  93464. * @returns the class name
  93465. */
  93466. getClassName(): string;
  93467. /**
  93468. * Defines the pointer angular sensibility along the X axis or how fast is
  93469. * the camera rotating.
  93470. * A negative number will reverse the axis direction.
  93471. */
  93472. angularSensibilityX: number;
  93473. /**
  93474. * Defines the pointer angular sensibility along the Y axis or how fast is
  93475. * the camera rotating.
  93476. * A negative number will reverse the axis direction.
  93477. */
  93478. angularSensibilityY: number;
  93479. /**
  93480. * Defines the pointer pinch precision or how fast is the camera zooming.
  93481. * A negative number will reverse the axis direction.
  93482. */
  93483. pinchPrecision: number;
  93484. /**
  93485. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93486. * from 0.
  93487. * It defines the percentage of current camera.radius to use as delta when
  93488. * pinch zoom is used.
  93489. */
  93490. pinchDeltaPercentage: number;
  93491. /**
  93492. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93493. */
  93494. axisXControlRadius: boolean;
  93495. /**
  93496. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93497. */
  93498. axisXControlHeight: boolean;
  93499. /**
  93500. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93501. */
  93502. axisXControlRotation: boolean;
  93503. /**
  93504. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93505. */
  93506. axisYControlRadius: boolean;
  93507. /**
  93508. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93509. */
  93510. axisYControlHeight: boolean;
  93511. /**
  93512. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93513. */
  93514. axisYControlRotation: boolean;
  93515. /**
  93516. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93517. */
  93518. axisPinchControlRadius: boolean;
  93519. /**
  93520. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93521. */
  93522. axisPinchControlHeight: boolean;
  93523. /**
  93524. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93525. */
  93526. axisPinchControlRotation: boolean;
  93527. /**
  93528. * Log error messages if basic misconfiguration has occurred.
  93529. */
  93530. warningEnable: boolean;
  93531. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93532. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93533. private _warningCounter;
  93534. private _warning;
  93535. }
  93536. }
  93537. declare module BABYLON {
  93538. /**
  93539. * Default Inputs manager for the FollowCamera.
  93540. * It groups all the default supported inputs for ease of use.
  93541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93542. */
  93543. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93544. /**
  93545. * Instantiates a new FollowCameraInputsManager.
  93546. * @param camera Defines the camera the inputs belong to
  93547. */
  93548. constructor(camera: FollowCamera);
  93549. /**
  93550. * Add keyboard input support to the input manager.
  93551. * @returns the current input manager
  93552. */
  93553. addKeyboard(): FollowCameraInputsManager;
  93554. /**
  93555. * Add mouse wheel input support to the input manager.
  93556. * @returns the current input manager
  93557. */
  93558. addMouseWheel(): FollowCameraInputsManager;
  93559. /**
  93560. * Add pointers input support to the input manager.
  93561. * @returns the current input manager
  93562. */
  93563. addPointers(): FollowCameraInputsManager;
  93564. /**
  93565. * Add orientation input support to the input manager.
  93566. * @returns the current input manager
  93567. */
  93568. addVRDeviceOrientation(): FollowCameraInputsManager;
  93569. }
  93570. }
  93571. declare module BABYLON {
  93572. /**
  93573. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93574. * an arc rotate version arcFollowCamera are available.
  93575. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93576. */
  93577. export class FollowCamera extends TargetCamera {
  93578. /**
  93579. * Distance the follow camera should follow an object at
  93580. */
  93581. radius: number;
  93582. /**
  93583. * Minimum allowed distance of the camera to the axis of rotation
  93584. * (The camera can not get closer).
  93585. * This can help limiting how the Camera is able to move in the scene.
  93586. */
  93587. lowerRadiusLimit: Nullable<number>;
  93588. /**
  93589. * Maximum allowed distance of the camera to the axis of rotation
  93590. * (The camera can not get further).
  93591. * This can help limiting how the Camera is able to move in the scene.
  93592. */
  93593. upperRadiusLimit: Nullable<number>;
  93594. /**
  93595. * Define a rotation offset between the camera and the object it follows
  93596. */
  93597. rotationOffset: number;
  93598. /**
  93599. * Minimum allowed angle to camera position relative to target object.
  93600. * This can help limiting how the Camera is able to move in the scene.
  93601. */
  93602. lowerRotationOffsetLimit: Nullable<number>;
  93603. /**
  93604. * Maximum allowed angle to camera position relative to target object.
  93605. * This can help limiting how the Camera is able to move in the scene.
  93606. */
  93607. upperRotationOffsetLimit: Nullable<number>;
  93608. /**
  93609. * Define a height offset between the camera and the object it follows.
  93610. * It can help following an object from the top (like a car chaing a plane)
  93611. */
  93612. heightOffset: number;
  93613. /**
  93614. * Minimum allowed height of camera position relative to target object.
  93615. * This can help limiting how the Camera is able to move in the scene.
  93616. */
  93617. lowerHeightOffsetLimit: Nullable<number>;
  93618. /**
  93619. * Maximum allowed height of camera position relative to target object.
  93620. * This can help limiting how the Camera is able to move in the scene.
  93621. */
  93622. upperHeightOffsetLimit: Nullable<number>;
  93623. /**
  93624. * Define how fast the camera can accelerate to follow it s target.
  93625. */
  93626. cameraAcceleration: number;
  93627. /**
  93628. * Define the speed limit of the camera following an object.
  93629. */
  93630. maxCameraSpeed: number;
  93631. /**
  93632. * Define the target of the camera.
  93633. */
  93634. lockedTarget: Nullable<AbstractMesh>;
  93635. /**
  93636. * Defines the input associated with the camera.
  93637. */
  93638. inputs: FollowCameraInputsManager;
  93639. /**
  93640. * Instantiates the follow camera.
  93641. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93642. * @param name Define the name of the camera in the scene
  93643. * @param position Define the position of the camera
  93644. * @param scene Define the scene the camera belong to
  93645. * @param lockedTarget Define the target of the camera
  93646. */
  93647. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93648. private _follow;
  93649. /**
  93650. * Attached controls to the current camera.
  93651. * @param element Defines the element the controls should be listened from
  93652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93653. */
  93654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93655. /**
  93656. * Detach the current controls from the camera.
  93657. * The camera will stop reacting to inputs.
  93658. * @param element Defines the element to stop listening the inputs from
  93659. */
  93660. detachControl(element: HTMLElement): void;
  93661. /** @hidden */
  93662. _checkInputs(): void;
  93663. private _checkLimits;
  93664. /**
  93665. * Gets the camera class name.
  93666. * @returns the class name
  93667. */
  93668. getClassName(): string;
  93669. }
  93670. /**
  93671. * Arc Rotate version of the follow camera.
  93672. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93673. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93674. */
  93675. export class ArcFollowCamera extends TargetCamera {
  93676. /** The longitudinal angle of the camera */
  93677. alpha: number;
  93678. /** The latitudinal angle of the camera */
  93679. beta: number;
  93680. /** The radius of the camera from its target */
  93681. radius: number;
  93682. /** Define the camera target (the messh it should follow) */
  93683. target: Nullable<AbstractMesh>;
  93684. private _cartesianCoordinates;
  93685. /**
  93686. * Instantiates a new ArcFollowCamera
  93687. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93688. * @param name Define the name of the camera
  93689. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93690. * @param beta Define the rotation angle of the camera around the elevation axis
  93691. * @param radius Define the radius of the camera from its target point
  93692. * @param target Define the target of the camera
  93693. * @param scene Define the scene the camera belongs to
  93694. */
  93695. constructor(name: string,
  93696. /** The longitudinal angle of the camera */
  93697. alpha: number,
  93698. /** The latitudinal angle of the camera */
  93699. beta: number,
  93700. /** The radius of the camera from its target */
  93701. radius: number,
  93702. /** Define the camera target (the messh it should follow) */
  93703. target: Nullable<AbstractMesh>, scene: Scene);
  93704. private _follow;
  93705. /** @hidden */
  93706. _checkInputs(): void;
  93707. /**
  93708. * Returns the class name of the object.
  93709. * It is mostly used internally for serialization purposes.
  93710. */
  93711. getClassName(): string;
  93712. }
  93713. }
  93714. declare module BABYLON {
  93715. /**
  93716. * Manage the keyboard inputs to control the movement of a follow camera.
  93717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93718. */
  93719. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93720. /**
  93721. * Defines the camera the input is attached to.
  93722. */
  93723. camera: FollowCamera;
  93724. /**
  93725. * Defines the list of key codes associated with the up action (increase heightOffset)
  93726. */
  93727. keysHeightOffsetIncr: number[];
  93728. /**
  93729. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93730. */
  93731. keysHeightOffsetDecr: number[];
  93732. /**
  93733. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93734. */
  93735. keysHeightOffsetModifierAlt: boolean;
  93736. /**
  93737. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93738. */
  93739. keysHeightOffsetModifierCtrl: boolean;
  93740. /**
  93741. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93742. */
  93743. keysHeightOffsetModifierShift: boolean;
  93744. /**
  93745. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93746. */
  93747. keysRotationOffsetIncr: number[];
  93748. /**
  93749. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93750. */
  93751. keysRotationOffsetDecr: number[];
  93752. /**
  93753. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93754. */
  93755. keysRotationOffsetModifierAlt: boolean;
  93756. /**
  93757. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93758. */
  93759. keysRotationOffsetModifierCtrl: boolean;
  93760. /**
  93761. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93762. */
  93763. keysRotationOffsetModifierShift: boolean;
  93764. /**
  93765. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93766. */
  93767. keysRadiusIncr: number[];
  93768. /**
  93769. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93770. */
  93771. keysRadiusDecr: number[];
  93772. /**
  93773. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93774. */
  93775. keysRadiusModifierAlt: boolean;
  93776. /**
  93777. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93778. */
  93779. keysRadiusModifierCtrl: boolean;
  93780. /**
  93781. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93782. */
  93783. keysRadiusModifierShift: boolean;
  93784. /**
  93785. * Defines the rate of change of heightOffset.
  93786. */
  93787. heightSensibility: number;
  93788. /**
  93789. * Defines the rate of change of rotationOffset.
  93790. */
  93791. rotationSensibility: number;
  93792. /**
  93793. * Defines the rate of change of radius.
  93794. */
  93795. radiusSensibility: number;
  93796. private _keys;
  93797. private _ctrlPressed;
  93798. private _altPressed;
  93799. private _shiftPressed;
  93800. private _onCanvasBlurObserver;
  93801. private _onKeyboardObserver;
  93802. private _engine;
  93803. private _scene;
  93804. /**
  93805. * Attach the input controls to a specific dom element to get the input from.
  93806. * @param element Defines the element the controls should be listened from
  93807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93808. */
  93809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93810. /**
  93811. * Detach the current controls from the specified dom element.
  93812. * @param element Defines the element to stop listening the inputs from
  93813. */
  93814. detachControl(element: Nullable<HTMLElement>): void;
  93815. /**
  93816. * Update the current camera state depending on the inputs that have been used this frame.
  93817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93818. */
  93819. checkInputs(): void;
  93820. /**
  93821. * Gets the class name of the current input.
  93822. * @returns the class name
  93823. */
  93824. getClassName(): string;
  93825. /**
  93826. * Get the friendly name associated with the input class.
  93827. * @returns the input friendly name
  93828. */
  93829. getSimpleName(): string;
  93830. /**
  93831. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93832. * allow modification of the heightOffset value.
  93833. */
  93834. private _modifierHeightOffset;
  93835. /**
  93836. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93837. * allow modification of the rotationOffset value.
  93838. */
  93839. private _modifierRotationOffset;
  93840. /**
  93841. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93842. * allow modification of the radius value.
  93843. */
  93844. private _modifierRadius;
  93845. }
  93846. }
  93847. declare module BABYLON {
  93848. interface FreeCameraInputsManager {
  93849. /**
  93850. * Add orientation input support to the input manager.
  93851. * @returns the current input manager
  93852. */
  93853. addDeviceOrientation(): FreeCameraInputsManager;
  93854. }
  93855. /**
  93856. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93857. * Screen rotation is taken into account.
  93858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93859. */
  93860. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93861. private _camera;
  93862. private _screenOrientationAngle;
  93863. private _constantTranform;
  93864. private _screenQuaternion;
  93865. private _alpha;
  93866. private _beta;
  93867. private _gamma;
  93868. /**
  93869. * Instantiates a new input
  93870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93871. */
  93872. constructor();
  93873. /**
  93874. * Define the camera controlled by the input.
  93875. */
  93876. camera: FreeCamera;
  93877. /**
  93878. * Attach the input controls to a specific dom element to get the input from.
  93879. * @param element Defines the element the controls should be listened from
  93880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93881. */
  93882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93883. private _orientationChanged;
  93884. private _deviceOrientation;
  93885. /**
  93886. * Detach the current controls from the specified dom element.
  93887. * @param element Defines the element to stop listening the inputs from
  93888. */
  93889. detachControl(element: Nullable<HTMLElement>): void;
  93890. /**
  93891. * Update the current camera state depending on the inputs that have been used this frame.
  93892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93893. */
  93894. checkInputs(): void;
  93895. /**
  93896. * Gets the class name of the current intput.
  93897. * @returns the class name
  93898. */
  93899. getClassName(): string;
  93900. /**
  93901. * Get the friendly name associated with the input class.
  93902. * @returns the input friendly name
  93903. */
  93904. getSimpleName(): string;
  93905. }
  93906. }
  93907. declare module BABYLON {
  93908. /**
  93909. * Manage the gamepad inputs to control a free camera.
  93910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93911. */
  93912. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93913. /**
  93914. * Define the camera the input is attached to.
  93915. */
  93916. camera: FreeCamera;
  93917. /**
  93918. * Define the Gamepad controlling the input
  93919. */
  93920. gamepad: Nullable<Gamepad>;
  93921. /**
  93922. * Defines the gamepad rotation sensiblity.
  93923. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93924. */
  93925. gamepadAngularSensibility: number;
  93926. /**
  93927. * Defines the gamepad move sensiblity.
  93928. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93929. */
  93930. gamepadMoveSensibility: number;
  93931. private _onGamepadConnectedObserver;
  93932. private _onGamepadDisconnectedObserver;
  93933. private _cameraTransform;
  93934. private _deltaTransform;
  93935. private _vector3;
  93936. private _vector2;
  93937. /**
  93938. * Attach the input controls to a specific dom element to get the input from.
  93939. * @param element Defines the element the controls should be listened from
  93940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93941. */
  93942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93943. /**
  93944. * Detach the current controls from the specified dom element.
  93945. * @param element Defines the element to stop listening the inputs from
  93946. */
  93947. detachControl(element: Nullable<HTMLElement>): void;
  93948. /**
  93949. * Update the current camera state depending on the inputs that have been used this frame.
  93950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93951. */
  93952. checkInputs(): void;
  93953. /**
  93954. * Gets the class name of the current intput.
  93955. * @returns the class name
  93956. */
  93957. getClassName(): string;
  93958. /**
  93959. * Get the friendly name associated with the input class.
  93960. * @returns the input friendly name
  93961. */
  93962. getSimpleName(): string;
  93963. }
  93964. }
  93965. declare module BABYLON {
  93966. /**
  93967. * Defines the potential axis of a Joystick
  93968. */
  93969. export enum JoystickAxis {
  93970. /** X axis */
  93971. X = 0,
  93972. /** Y axis */
  93973. Y = 1,
  93974. /** Z axis */
  93975. Z = 2
  93976. }
  93977. /**
  93978. * Class used to define virtual joystick (used in touch mode)
  93979. */
  93980. export class VirtualJoystick {
  93981. /**
  93982. * Gets or sets a boolean indicating that left and right values must be inverted
  93983. */
  93984. reverseLeftRight: boolean;
  93985. /**
  93986. * Gets or sets a boolean indicating that up and down values must be inverted
  93987. */
  93988. reverseUpDown: boolean;
  93989. /**
  93990. * Gets the offset value for the position (ie. the change of the position value)
  93991. */
  93992. deltaPosition: Vector3;
  93993. /**
  93994. * Gets a boolean indicating if the virtual joystick was pressed
  93995. */
  93996. pressed: boolean;
  93997. /**
  93998. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93999. */
  94000. static Canvas: Nullable<HTMLCanvasElement>;
  94001. private static _globalJoystickIndex;
  94002. private static vjCanvasContext;
  94003. private static vjCanvasWidth;
  94004. private static vjCanvasHeight;
  94005. private static halfWidth;
  94006. private _action;
  94007. private _axisTargetedByLeftAndRight;
  94008. private _axisTargetedByUpAndDown;
  94009. private _joystickSensibility;
  94010. private _inversedSensibility;
  94011. private _joystickPointerID;
  94012. private _joystickColor;
  94013. private _joystickPointerPos;
  94014. private _joystickPreviousPointerPos;
  94015. private _joystickPointerStartPos;
  94016. private _deltaJoystickVector;
  94017. private _leftJoystick;
  94018. private _touches;
  94019. private _onPointerDownHandlerRef;
  94020. private _onPointerMoveHandlerRef;
  94021. private _onPointerUpHandlerRef;
  94022. private _onResize;
  94023. /**
  94024. * Creates a new virtual joystick
  94025. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94026. */
  94027. constructor(leftJoystick?: boolean);
  94028. /**
  94029. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94030. * @param newJoystickSensibility defines the new sensibility
  94031. */
  94032. setJoystickSensibility(newJoystickSensibility: number): void;
  94033. private _onPointerDown;
  94034. private _onPointerMove;
  94035. private _onPointerUp;
  94036. /**
  94037. * Change the color of the virtual joystick
  94038. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94039. */
  94040. setJoystickColor(newColor: string): void;
  94041. /**
  94042. * Defines a callback to call when the joystick is touched
  94043. * @param action defines the callback
  94044. */
  94045. setActionOnTouch(action: () => any): void;
  94046. /**
  94047. * Defines which axis you'd like to control for left & right
  94048. * @param axis defines the axis to use
  94049. */
  94050. setAxisForLeftRight(axis: JoystickAxis): void;
  94051. /**
  94052. * Defines which axis you'd like to control for up & down
  94053. * @param axis defines the axis to use
  94054. */
  94055. setAxisForUpDown(axis: JoystickAxis): void;
  94056. private _drawVirtualJoystick;
  94057. /**
  94058. * Release internal HTML canvas
  94059. */
  94060. releaseCanvas(): void;
  94061. }
  94062. }
  94063. declare module BABYLON {
  94064. interface FreeCameraInputsManager {
  94065. /**
  94066. * Add virtual joystick input support to the input manager.
  94067. * @returns the current input manager
  94068. */
  94069. addVirtualJoystick(): FreeCameraInputsManager;
  94070. }
  94071. /**
  94072. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94074. */
  94075. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94076. /**
  94077. * Defines the camera the input is attached to.
  94078. */
  94079. camera: FreeCamera;
  94080. private _leftjoystick;
  94081. private _rightjoystick;
  94082. /**
  94083. * Gets the left stick of the virtual joystick.
  94084. * @returns The virtual Joystick
  94085. */
  94086. getLeftJoystick(): VirtualJoystick;
  94087. /**
  94088. * Gets the right stick of the virtual joystick.
  94089. * @returns The virtual Joystick
  94090. */
  94091. getRightJoystick(): VirtualJoystick;
  94092. /**
  94093. * Update the current camera state depending on the inputs that have been used this frame.
  94094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94095. */
  94096. checkInputs(): void;
  94097. /**
  94098. * Attach the input controls to a specific dom element to get the input from.
  94099. * @param element Defines the element the controls should be listened from
  94100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94101. */
  94102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94103. /**
  94104. * Detach the current controls from the specified dom element.
  94105. * @param element Defines the element to stop listening the inputs from
  94106. */
  94107. detachControl(element: Nullable<HTMLElement>): void;
  94108. /**
  94109. * Gets the class name of the current intput.
  94110. * @returns the class name
  94111. */
  94112. getClassName(): string;
  94113. /**
  94114. * Get the friendly name associated with the input class.
  94115. * @returns the input friendly name
  94116. */
  94117. getSimpleName(): string;
  94118. }
  94119. }
  94120. declare module BABYLON {
  94121. /**
  94122. * This represents a FPS type of camera controlled by touch.
  94123. * This is like a universal camera minus the Gamepad controls.
  94124. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94125. */
  94126. export class TouchCamera extends FreeCamera {
  94127. /**
  94128. * Defines the touch sensibility for rotation.
  94129. * The higher the faster.
  94130. */
  94131. touchAngularSensibility: number;
  94132. /**
  94133. * Defines the touch sensibility for move.
  94134. * The higher the faster.
  94135. */
  94136. touchMoveSensibility: number;
  94137. /**
  94138. * Instantiates a new touch camera.
  94139. * This represents a FPS type of camera controlled by touch.
  94140. * This is like a universal camera minus the Gamepad controls.
  94141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94142. * @param name Define the name of the camera in the scene
  94143. * @param position Define the start position of the camera in the scene
  94144. * @param scene Define the scene the camera belongs to
  94145. */
  94146. constructor(name: string, position: Vector3, scene: Scene);
  94147. /**
  94148. * Gets the current object class name.
  94149. * @return the class name
  94150. */
  94151. getClassName(): string;
  94152. /** @hidden */
  94153. _setupInputs(): void;
  94154. }
  94155. }
  94156. declare module BABYLON {
  94157. /**
  94158. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94159. * being tilted forward or back and left or right.
  94160. */
  94161. export class DeviceOrientationCamera extends FreeCamera {
  94162. private _initialQuaternion;
  94163. private _quaternionCache;
  94164. /**
  94165. * Creates a new device orientation camera
  94166. * @param name The name of the camera
  94167. * @param position The start position camera
  94168. * @param scene The scene the camera belongs to
  94169. */
  94170. constructor(name: string, position: Vector3, scene: Scene);
  94171. /**
  94172. * Gets the current instance class name ("DeviceOrientationCamera").
  94173. * This helps avoiding instanceof at run time.
  94174. * @returns the class name
  94175. */
  94176. getClassName(): string;
  94177. /**
  94178. * @hidden
  94179. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94180. */
  94181. _checkInputs(): void;
  94182. /**
  94183. * Reset the camera to its default orientation on the specified axis only.
  94184. * @param axis The axis to reset
  94185. */
  94186. resetToCurrentRotation(axis?: Axis): void;
  94187. }
  94188. }
  94189. declare module BABYLON {
  94190. /**
  94191. * 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,
  94192. * which still works and will still be found in many Playgrounds.
  94193. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94194. */
  94195. export class UniversalCamera extends TouchCamera {
  94196. /**
  94197. * Defines the gamepad rotation sensiblity.
  94198. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94199. */
  94200. gamepadAngularSensibility: number;
  94201. /**
  94202. * Defines the gamepad move sensiblity.
  94203. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94204. */
  94205. gamepadMoveSensibility: number;
  94206. /**
  94207. * 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,
  94208. * which still works and will still be found in many Playgrounds.
  94209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94210. * @param name Define the name of the camera in the scene
  94211. * @param position Define the start position of the camera in the scene
  94212. * @param scene Define the scene the camera belongs to
  94213. */
  94214. constructor(name: string, position: Vector3, scene: Scene);
  94215. /**
  94216. * Gets the current object class name.
  94217. * @return the class name
  94218. */
  94219. getClassName(): string;
  94220. }
  94221. }
  94222. declare module BABYLON {
  94223. /**
  94224. * This represents a FPS type of camera. This is only here for back compat purpose.
  94225. * Please use the UniversalCamera instead as both are identical.
  94226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94227. */
  94228. export class GamepadCamera extends UniversalCamera {
  94229. /**
  94230. * Instantiates a new Gamepad Camera
  94231. * This represents a FPS type of camera. This is only here for back compat purpose.
  94232. * Please use the UniversalCamera instead as both are identical.
  94233. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94234. * @param name Define the name of the camera in the scene
  94235. * @param position Define the start position of the camera in the scene
  94236. * @param scene Define the scene the camera belongs to
  94237. */
  94238. constructor(name: string, position: Vector3, scene: Scene);
  94239. /**
  94240. * Gets the current object class name.
  94241. * @return the class name
  94242. */
  94243. getClassName(): string;
  94244. }
  94245. }
  94246. declare module BABYLON {
  94247. /** @hidden */
  94248. export var passPixelShader: {
  94249. name: string;
  94250. shader: string;
  94251. };
  94252. }
  94253. declare module BABYLON {
  94254. /** @hidden */
  94255. export var passCubePixelShader: {
  94256. name: string;
  94257. shader: string;
  94258. };
  94259. }
  94260. declare module BABYLON {
  94261. /**
  94262. * PassPostProcess which produces an output the same as it's input
  94263. */
  94264. export class PassPostProcess extends PostProcess {
  94265. /**
  94266. * Creates the PassPostProcess
  94267. * @param name The name of the effect.
  94268. * @param options The required width/height ratio to downsize to before computing the render pass.
  94269. * @param camera The camera to apply the render pass to.
  94270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94271. * @param engine The engine which the post process will be applied. (default: current engine)
  94272. * @param reusable If the post process can be reused on the same frame. (default: false)
  94273. * @param textureType The type of texture to be used when performing the post processing.
  94274. * @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)
  94275. */
  94276. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94277. }
  94278. /**
  94279. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94280. */
  94281. export class PassCubePostProcess extends PostProcess {
  94282. private _face;
  94283. /**
  94284. * Gets or sets the cube face to display.
  94285. * * 0 is +X
  94286. * * 1 is -X
  94287. * * 2 is +Y
  94288. * * 3 is -Y
  94289. * * 4 is +Z
  94290. * * 5 is -Z
  94291. */
  94292. face: number;
  94293. /**
  94294. * Creates the PassCubePostProcess
  94295. * @param name The name of the effect.
  94296. * @param options The required width/height ratio to downsize to before computing the render pass.
  94297. * @param camera The camera to apply the render pass to.
  94298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94299. * @param engine The engine which the post process will be applied. (default: current engine)
  94300. * @param reusable If the post process can be reused on the same frame. (default: false)
  94301. * @param textureType The type of texture to be used when performing the post processing.
  94302. * @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)
  94303. */
  94304. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94305. }
  94306. }
  94307. declare module BABYLON {
  94308. /** @hidden */
  94309. export var anaglyphPixelShader: {
  94310. name: string;
  94311. shader: string;
  94312. };
  94313. }
  94314. declare module BABYLON {
  94315. /**
  94316. * Postprocess used to generate anaglyphic rendering
  94317. */
  94318. export class AnaglyphPostProcess extends PostProcess {
  94319. private _passedProcess;
  94320. /**
  94321. * Creates a new AnaglyphPostProcess
  94322. * @param name defines postprocess name
  94323. * @param options defines creation options or target ratio scale
  94324. * @param rigCameras defines cameras using this postprocess
  94325. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94326. * @param engine defines hosting engine
  94327. * @param reusable defines if the postprocess will be reused multiple times per frame
  94328. */
  94329. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94330. }
  94331. }
  94332. declare module BABYLON {
  94333. /**
  94334. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94335. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94336. */
  94337. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94338. /**
  94339. * Creates a new AnaglyphArcRotateCamera
  94340. * @param name defines camera name
  94341. * @param alpha defines alpha angle (in radians)
  94342. * @param beta defines beta angle (in radians)
  94343. * @param radius defines radius
  94344. * @param target defines camera target
  94345. * @param interaxialDistance defines distance between each color axis
  94346. * @param scene defines the hosting scene
  94347. */
  94348. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94349. /**
  94350. * Gets camera class name
  94351. * @returns AnaglyphArcRotateCamera
  94352. */
  94353. getClassName(): string;
  94354. }
  94355. }
  94356. declare module BABYLON {
  94357. /**
  94358. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94359. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94360. */
  94361. export class AnaglyphFreeCamera extends FreeCamera {
  94362. /**
  94363. * Creates a new AnaglyphFreeCamera
  94364. * @param name defines camera name
  94365. * @param position defines initial position
  94366. * @param interaxialDistance defines distance between each color axis
  94367. * @param scene defines the hosting scene
  94368. */
  94369. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94370. /**
  94371. * Gets camera class name
  94372. * @returns AnaglyphFreeCamera
  94373. */
  94374. getClassName(): string;
  94375. }
  94376. }
  94377. declare module BABYLON {
  94378. /**
  94379. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94380. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94381. */
  94382. export class AnaglyphGamepadCamera extends GamepadCamera {
  94383. /**
  94384. * Creates a new AnaglyphGamepadCamera
  94385. * @param name defines camera name
  94386. * @param position defines initial position
  94387. * @param interaxialDistance defines distance between each color axis
  94388. * @param scene defines the hosting scene
  94389. */
  94390. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94391. /**
  94392. * Gets camera class name
  94393. * @returns AnaglyphGamepadCamera
  94394. */
  94395. getClassName(): string;
  94396. }
  94397. }
  94398. declare module BABYLON {
  94399. /**
  94400. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94401. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94402. */
  94403. export class AnaglyphUniversalCamera extends UniversalCamera {
  94404. /**
  94405. * Creates a new AnaglyphUniversalCamera
  94406. * @param name defines camera name
  94407. * @param position defines initial position
  94408. * @param interaxialDistance defines distance between each color axis
  94409. * @param scene defines the hosting scene
  94410. */
  94411. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94412. /**
  94413. * Gets camera class name
  94414. * @returns AnaglyphUniversalCamera
  94415. */
  94416. getClassName(): string;
  94417. }
  94418. }
  94419. declare module BABYLON {
  94420. /** @hidden */
  94421. export var stereoscopicInterlacePixelShader: {
  94422. name: string;
  94423. shader: string;
  94424. };
  94425. }
  94426. declare module BABYLON {
  94427. /**
  94428. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94429. */
  94430. export class StereoscopicInterlacePostProcess extends PostProcess {
  94431. private _stepSize;
  94432. private _passedProcess;
  94433. /**
  94434. * Initializes a StereoscopicInterlacePostProcess
  94435. * @param name The name of the effect.
  94436. * @param rigCameras The rig cameras to be appled to the post process
  94437. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94439. * @param engine The engine which the post process will be applied. (default: current engine)
  94440. * @param reusable If the post process can be reused on the same frame. (default: false)
  94441. */
  94442. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94443. }
  94444. }
  94445. declare module BABYLON {
  94446. /**
  94447. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94448. * @see http://doc.babylonjs.com/features/cameras
  94449. */
  94450. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94451. /**
  94452. * Creates a new StereoscopicArcRotateCamera
  94453. * @param name defines camera name
  94454. * @param alpha defines alpha angle (in radians)
  94455. * @param beta defines beta angle (in radians)
  94456. * @param radius defines radius
  94457. * @param target defines camera target
  94458. * @param interaxialDistance defines distance between each color axis
  94459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94460. * @param scene defines the hosting scene
  94461. */
  94462. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94463. /**
  94464. * Gets camera class name
  94465. * @returns StereoscopicArcRotateCamera
  94466. */
  94467. getClassName(): string;
  94468. }
  94469. }
  94470. declare module BABYLON {
  94471. /**
  94472. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94473. * @see http://doc.babylonjs.com/features/cameras
  94474. */
  94475. export class StereoscopicFreeCamera extends FreeCamera {
  94476. /**
  94477. * Creates a new StereoscopicFreeCamera
  94478. * @param name defines camera name
  94479. * @param position defines initial position
  94480. * @param interaxialDistance defines distance between each color axis
  94481. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94482. * @param scene defines the hosting scene
  94483. */
  94484. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94485. /**
  94486. * Gets camera class name
  94487. * @returns StereoscopicFreeCamera
  94488. */
  94489. getClassName(): string;
  94490. }
  94491. }
  94492. declare module BABYLON {
  94493. /**
  94494. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94495. * @see http://doc.babylonjs.com/features/cameras
  94496. */
  94497. export class StereoscopicGamepadCamera extends GamepadCamera {
  94498. /**
  94499. * Creates a new StereoscopicGamepadCamera
  94500. * @param name defines camera name
  94501. * @param position defines initial position
  94502. * @param interaxialDistance defines distance between each color axis
  94503. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94504. * @param scene defines the hosting scene
  94505. */
  94506. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94507. /**
  94508. * Gets camera class name
  94509. * @returns StereoscopicGamepadCamera
  94510. */
  94511. getClassName(): string;
  94512. }
  94513. }
  94514. declare module BABYLON {
  94515. /**
  94516. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94517. * @see http://doc.babylonjs.com/features/cameras
  94518. */
  94519. export class StereoscopicUniversalCamera extends UniversalCamera {
  94520. /**
  94521. * Creates a new StereoscopicUniversalCamera
  94522. * @param name defines camera name
  94523. * @param position defines initial position
  94524. * @param interaxialDistance defines distance between each color axis
  94525. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94526. * @param scene defines the hosting scene
  94527. */
  94528. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94529. /**
  94530. * Gets camera class name
  94531. * @returns StereoscopicUniversalCamera
  94532. */
  94533. getClassName(): string;
  94534. }
  94535. }
  94536. declare module BABYLON {
  94537. /**
  94538. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94539. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94540. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94541. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94542. */
  94543. export class VirtualJoysticksCamera extends FreeCamera {
  94544. /**
  94545. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94546. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94547. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94548. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94549. * @param name Define the name of the camera in the scene
  94550. * @param position Define the start position of the camera in the scene
  94551. * @param scene Define the scene the camera belongs to
  94552. */
  94553. constructor(name: string, position: Vector3, scene: Scene);
  94554. /**
  94555. * Gets the current object class name.
  94556. * @return the class name
  94557. */
  94558. getClassName(): string;
  94559. }
  94560. }
  94561. declare module BABYLON {
  94562. /**
  94563. * This represents all the required metrics to create a VR camera.
  94564. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94565. */
  94566. export class VRCameraMetrics {
  94567. /**
  94568. * Define the horizontal resolution off the screen.
  94569. */
  94570. hResolution: number;
  94571. /**
  94572. * Define the vertical resolution off the screen.
  94573. */
  94574. vResolution: number;
  94575. /**
  94576. * Define the horizontal screen size.
  94577. */
  94578. hScreenSize: number;
  94579. /**
  94580. * Define the vertical screen size.
  94581. */
  94582. vScreenSize: number;
  94583. /**
  94584. * Define the vertical screen center position.
  94585. */
  94586. vScreenCenter: number;
  94587. /**
  94588. * Define the distance of the eyes to the screen.
  94589. */
  94590. eyeToScreenDistance: number;
  94591. /**
  94592. * Define the distance between both lenses
  94593. */
  94594. lensSeparationDistance: number;
  94595. /**
  94596. * Define the distance between both viewer's eyes.
  94597. */
  94598. interpupillaryDistance: number;
  94599. /**
  94600. * Define the distortion factor of the VR postprocess.
  94601. * Please, touch with care.
  94602. */
  94603. distortionK: number[];
  94604. /**
  94605. * Define the chromatic aberration correction factors for the VR post process.
  94606. */
  94607. chromaAbCorrection: number[];
  94608. /**
  94609. * Define the scale factor of the post process.
  94610. * The smaller the better but the slower.
  94611. */
  94612. postProcessScaleFactor: number;
  94613. /**
  94614. * Define an offset for the lens center.
  94615. */
  94616. lensCenterOffset: number;
  94617. /**
  94618. * Define if the current vr camera should compensate the distortion of the lense or not.
  94619. */
  94620. compensateDistortion: boolean;
  94621. /**
  94622. * Gets the rendering aspect ratio based on the provided resolutions.
  94623. */
  94624. readonly aspectRatio: number;
  94625. /**
  94626. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94627. */
  94628. readonly aspectRatioFov: number;
  94629. /**
  94630. * @hidden
  94631. */
  94632. readonly leftHMatrix: Matrix;
  94633. /**
  94634. * @hidden
  94635. */
  94636. readonly rightHMatrix: Matrix;
  94637. /**
  94638. * @hidden
  94639. */
  94640. readonly leftPreViewMatrix: Matrix;
  94641. /**
  94642. * @hidden
  94643. */
  94644. readonly rightPreViewMatrix: Matrix;
  94645. /**
  94646. * Get the default VRMetrics based on the most generic setup.
  94647. * @returns the default vr metrics
  94648. */
  94649. static GetDefault(): VRCameraMetrics;
  94650. }
  94651. }
  94652. declare module BABYLON {
  94653. /** @hidden */
  94654. export var vrDistortionCorrectionPixelShader: {
  94655. name: string;
  94656. shader: string;
  94657. };
  94658. }
  94659. declare module BABYLON {
  94660. /**
  94661. * VRDistortionCorrectionPostProcess used for mobile VR
  94662. */
  94663. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94664. private _isRightEye;
  94665. private _distortionFactors;
  94666. private _postProcessScaleFactor;
  94667. private _lensCenterOffset;
  94668. private _scaleIn;
  94669. private _scaleFactor;
  94670. private _lensCenter;
  94671. /**
  94672. * Initializes the VRDistortionCorrectionPostProcess
  94673. * @param name The name of the effect.
  94674. * @param camera The camera to apply the render pass to.
  94675. * @param isRightEye If this is for the right eye distortion
  94676. * @param vrMetrics All the required metrics for the VR camera
  94677. */
  94678. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94679. }
  94680. }
  94681. declare module BABYLON {
  94682. /**
  94683. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94684. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94685. */
  94686. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94687. /**
  94688. * Creates a new VRDeviceOrientationArcRotateCamera
  94689. * @param name defines camera name
  94690. * @param alpha defines the camera rotation along the logitudinal axis
  94691. * @param beta defines the camera rotation along the latitudinal axis
  94692. * @param radius defines the camera distance from its target
  94693. * @param target defines the camera target
  94694. * @param scene defines the scene the camera belongs to
  94695. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94696. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94697. */
  94698. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94699. /**
  94700. * Gets camera class name
  94701. * @returns VRDeviceOrientationArcRotateCamera
  94702. */
  94703. getClassName(): string;
  94704. }
  94705. }
  94706. declare module BABYLON {
  94707. /**
  94708. * Camera used to simulate VR rendering (based on FreeCamera)
  94709. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94710. */
  94711. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94712. /**
  94713. * Creates a new VRDeviceOrientationFreeCamera
  94714. * @param name defines camera name
  94715. * @param position defines the start position of the camera
  94716. * @param scene defines the scene the camera belongs to
  94717. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94718. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94719. */
  94720. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94721. /**
  94722. * Gets camera class name
  94723. * @returns VRDeviceOrientationFreeCamera
  94724. */
  94725. getClassName(): string;
  94726. }
  94727. }
  94728. declare module BABYLON {
  94729. /**
  94730. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94731. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94732. */
  94733. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94734. /**
  94735. * Creates a new VRDeviceOrientationGamepadCamera
  94736. * @param name defines camera name
  94737. * @param position defines the start position of the camera
  94738. * @param scene defines the scene the camera belongs to
  94739. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94740. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94741. */
  94742. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94743. /**
  94744. * Gets camera class name
  94745. * @returns VRDeviceOrientationGamepadCamera
  94746. */
  94747. getClassName(): string;
  94748. }
  94749. }
  94750. declare module BABYLON {
  94751. /**
  94752. * Defines supported buttons for XBox360 compatible gamepads
  94753. */
  94754. export enum Xbox360Button {
  94755. /** A */
  94756. A = 0,
  94757. /** B */
  94758. B = 1,
  94759. /** X */
  94760. X = 2,
  94761. /** Y */
  94762. Y = 3,
  94763. /** Start */
  94764. Start = 4,
  94765. /** Back */
  94766. Back = 5,
  94767. /** Left button */
  94768. LB = 6,
  94769. /** Right button */
  94770. RB = 7,
  94771. /** Left stick */
  94772. LeftStick = 8,
  94773. /** Right stick */
  94774. RightStick = 9
  94775. }
  94776. /** Defines values for XBox360 DPad */
  94777. export enum Xbox360Dpad {
  94778. /** Up */
  94779. Up = 0,
  94780. /** Down */
  94781. Down = 1,
  94782. /** Left */
  94783. Left = 2,
  94784. /** Right */
  94785. Right = 3
  94786. }
  94787. /**
  94788. * Defines a XBox360 gamepad
  94789. */
  94790. export class Xbox360Pad extends Gamepad {
  94791. private _leftTrigger;
  94792. private _rightTrigger;
  94793. private _onlefttriggerchanged;
  94794. private _onrighttriggerchanged;
  94795. private _onbuttondown;
  94796. private _onbuttonup;
  94797. private _ondpaddown;
  94798. private _ondpadup;
  94799. /** Observable raised when a button is pressed */
  94800. onButtonDownObservable: Observable<Xbox360Button>;
  94801. /** Observable raised when a button is released */
  94802. onButtonUpObservable: Observable<Xbox360Button>;
  94803. /** Observable raised when a pad is pressed */
  94804. onPadDownObservable: Observable<Xbox360Dpad>;
  94805. /** Observable raised when a pad is released */
  94806. onPadUpObservable: Observable<Xbox360Dpad>;
  94807. private _buttonA;
  94808. private _buttonB;
  94809. private _buttonX;
  94810. private _buttonY;
  94811. private _buttonBack;
  94812. private _buttonStart;
  94813. private _buttonLB;
  94814. private _buttonRB;
  94815. private _buttonLeftStick;
  94816. private _buttonRightStick;
  94817. private _dPadUp;
  94818. private _dPadDown;
  94819. private _dPadLeft;
  94820. private _dPadRight;
  94821. private _isXboxOnePad;
  94822. /**
  94823. * Creates a new XBox360 gamepad object
  94824. * @param id defines the id of this gamepad
  94825. * @param index defines its index
  94826. * @param gamepad defines the internal HTML gamepad object
  94827. * @param xboxOne defines if it is a XBox One gamepad
  94828. */
  94829. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94830. /**
  94831. * Defines the callback to call when left trigger is pressed
  94832. * @param callback defines the callback to use
  94833. */
  94834. onlefttriggerchanged(callback: (value: number) => void): void;
  94835. /**
  94836. * Defines the callback to call when right trigger is pressed
  94837. * @param callback defines the callback to use
  94838. */
  94839. onrighttriggerchanged(callback: (value: number) => void): void;
  94840. /**
  94841. * Gets the left trigger value
  94842. */
  94843. /**
  94844. * Sets the left trigger value
  94845. */
  94846. leftTrigger: number;
  94847. /**
  94848. * Gets the right trigger value
  94849. */
  94850. /**
  94851. * Sets the right trigger value
  94852. */
  94853. rightTrigger: number;
  94854. /**
  94855. * Defines the callback to call when a button is pressed
  94856. * @param callback defines the callback to use
  94857. */
  94858. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94859. /**
  94860. * Defines the callback to call when a button is released
  94861. * @param callback defines the callback to use
  94862. */
  94863. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94864. /**
  94865. * Defines the callback to call when a pad is pressed
  94866. * @param callback defines the callback to use
  94867. */
  94868. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94869. /**
  94870. * Defines the callback to call when a pad is released
  94871. * @param callback defines the callback to use
  94872. */
  94873. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94874. private _setButtonValue;
  94875. private _setDPadValue;
  94876. /**
  94877. * Gets the value of the `A` button
  94878. */
  94879. /**
  94880. * Sets the value of the `A` button
  94881. */
  94882. buttonA: number;
  94883. /**
  94884. * Gets the value of the `B` button
  94885. */
  94886. /**
  94887. * Sets the value of the `B` button
  94888. */
  94889. buttonB: number;
  94890. /**
  94891. * Gets the value of the `X` button
  94892. */
  94893. /**
  94894. * Sets the value of the `X` button
  94895. */
  94896. buttonX: number;
  94897. /**
  94898. * Gets the value of the `Y` button
  94899. */
  94900. /**
  94901. * Sets the value of the `Y` button
  94902. */
  94903. buttonY: number;
  94904. /**
  94905. * Gets the value of the `Start` button
  94906. */
  94907. /**
  94908. * Sets the value of the `Start` button
  94909. */
  94910. buttonStart: number;
  94911. /**
  94912. * Gets the value of the `Back` button
  94913. */
  94914. /**
  94915. * Sets the value of the `Back` button
  94916. */
  94917. buttonBack: number;
  94918. /**
  94919. * Gets the value of the `Left` button
  94920. */
  94921. /**
  94922. * Sets the value of the `Left` button
  94923. */
  94924. buttonLB: number;
  94925. /**
  94926. * Gets the value of the `Right` button
  94927. */
  94928. /**
  94929. * Sets the value of the `Right` button
  94930. */
  94931. buttonRB: number;
  94932. /**
  94933. * Gets the value of the Left joystick
  94934. */
  94935. /**
  94936. * Sets the value of the Left joystick
  94937. */
  94938. buttonLeftStick: number;
  94939. /**
  94940. * Gets the value of the Right joystick
  94941. */
  94942. /**
  94943. * Sets the value of the Right joystick
  94944. */
  94945. buttonRightStick: number;
  94946. /**
  94947. * Gets the value of D-pad up
  94948. */
  94949. /**
  94950. * Sets the value of D-pad up
  94951. */
  94952. dPadUp: number;
  94953. /**
  94954. * Gets the value of D-pad down
  94955. */
  94956. /**
  94957. * Sets the value of D-pad down
  94958. */
  94959. dPadDown: number;
  94960. /**
  94961. * Gets the value of D-pad left
  94962. */
  94963. /**
  94964. * Sets the value of D-pad left
  94965. */
  94966. dPadLeft: number;
  94967. /**
  94968. * Gets the value of D-pad right
  94969. */
  94970. /**
  94971. * Sets the value of D-pad right
  94972. */
  94973. dPadRight: number;
  94974. /**
  94975. * Force the gamepad to synchronize with device values
  94976. */
  94977. update(): void;
  94978. /**
  94979. * Disposes the gamepad
  94980. */
  94981. dispose(): void;
  94982. }
  94983. }
  94984. declare module BABYLON {
  94985. /**
  94986. * Base class of materials working in push mode in babylon JS
  94987. * @hidden
  94988. */
  94989. export class PushMaterial extends Material {
  94990. protected _activeEffect: Effect;
  94991. protected _normalMatrix: Matrix;
  94992. /**
  94993. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94994. * This means that the material can keep using a previous shader while a new one is being compiled.
  94995. * This is mostly used when shader parallel compilation is supported (true by default)
  94996. */
  94997. allowShaderHotSwapping: boolean;
  94998. constructor(name: string, scene: Scene);
  94999. getEffect(): Effect;
  95000. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95001. /**
  95002. * Binds the given world matrix to the active effect
  95003. *
  95004. * @param world the matrix to bind
  95005. */
  95006. bindOnlyWorldMatrix(world: Matrix): void;
  95007. /**
  95008. * Binds the given normal matrix to the active effect
  95009. *
  95010. * @param normalMatrix the matrix to bind
  95011. */
  95012. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  95013. bind(world: Matrix, mesh?: Mesh): void;
  95014. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  95015. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  95016. }
  95017. }
  95018. declare module BABYLON {
  95019. /**
  95020. * This groups all the flags used to control the materials channel.
  95021. */
  95022. export class MaterialFlags {
  95023. private static _DiffuseTextureEnabled;
  95024. /**
  95025. * Are diffuse textures enabled in the application.
  95026. */
  95027. static DiffuseTextureEnabled: boolean;
  95028. private static _AmbientTextureEnabled;
  95029. /**
  95030. * Are ambient textures enabled in the application.
  95031. */
  95032. static AmbientTextureEnabled: boolean;
  95033. private static _OpacityTextureEnabled;
  95034. /**
  95035. * Are opacity textures enabled in the application.
  95036. */
  95037. static OpacityTextureEnabled: boolean;
  95038. private static _ReflectionTextureEnabled;
  95039. /**
  95040. * Are reflection textures enabled in the application.
  95041. */
  95042. static ReflectionTextureEnabled: boolean;
  95043. private static _EmissiveTextureEnabled;
  95044. /**
  95045. * Are emissive textures enabled in the application.
  95046. */
  95047. static EmissiveTextureEnabled: boolean;
  95048. private static _SpecularTextureEnabled;
  95049. /**
  95050. * Are specular textures enabled in the application.
  95051. */
  95052. static SpecularTextureEnabled: boolean;
  95053. private static _BumpTextureEnabled;
  95054. /**
  95055. * Are bump textures enabled in the application.
  95056. */
  95057. static BumpTextureEnabled: boolean;
  95058. private static _LightmapTextureEnabled;
  95059. /**
  95060. * Are lightmap textures enabled in the application.
  95061. */
  95062. static LightmapTextureEnabled: boolean;
  95063. private static _RefractionTextureEnabled;
  95064. /**
  95065. * Are refraction textures enabled in the application.
  95066. */
  95067. static RefractionTextureEnabled: boolean;
  95068. private static _ColorGradingTextureEnabled;
  95069. /**
  95070. * Are color grading textures enabled in the application.
  95071. */
  95072. static ColorGradingTextureEnabled: boolean;
  95073. private static _FresnelEnabled;
  95074. /**
  95075. * Are fresnels enabled in the application.
  95076. */
  95077. static FresnelEnabled: boolean;
  95078. private static _ClearCoatTextureEnabled;
  95079. /**
  95080. * Are clear coat textures enabled in the application.
  95081. */
  95082. static ClearCoatTextureEnabled: boolean;
  95083. private static _ClearCoatBumpTextureEnabled;
  95084. /**
  95085. * Are clear coat bump textures enabled in the application.
  95086. */
  95087. static ClearCoatBumpTextureEnabled: boolean;
  95088. private static _ClearCoatTintTextureEnabled;
  95089. /**
  95090. * Are clear coat tint textures enabled in the application.
  95091. */
  95092. static ClearCoatTintTextureEnabled: boolean;
  95093. private static _SheenTextureEnabled;
  95094. /**
  95095. * Are sheen textures enabled in the application.
  95096. */
  95097. static SheenTextureEnabled: boolean;
  95098. private static _AnisotropicTextureEnabled;
  95099. /**
  95100. * Are anisotropic textures enabled in the application.
  95101. */
  95102. static AnisotropicTextureEnabled: boolean;
  95103. }
  95104. }
  95105. declare module BABYLON {
  95106. /** @hidden */
  95107. export var defaultFragmentDeclaration: {
  95108. name: string;
  95109. shader: string;
  95110. };
  95111. }
  95112. declare module BABYLON {
  95113. /** @hidden */
  95114. export var defaultUboDeclaration: {
  95115. name: string;
  95116. shader: string;
  95117. };
  95118. }
  95119. declare module BABYLON {
  95120. /** @hidden */
  95121. export var lightFragmentDeclaration: {
  95122. name: string;
  95123. shader: string;
  95124. };
  95125. }
  95126. declare module BABYLON {
  95127. /** @hidden */
  95128. export var lightUboDeclaration: {
  95129. name: string;
  95130. shader: string;
  95131. };
  95132. }
  95133. declare module BABYLON {
  95134. /** @hidden */
  95135. export var lightsFragmentFunctions: {
  95136. name: string;
  95137. shader: string;
  95138. };
  95139. }
  95140. declare module BABYLON {
  95141. /** @hidden */
  95142. export var shadowsFragmentFunctions: {
  95143. name: string;
  95144. shader: string;
  95145. };
  95146. }
  95147. declare module BABYLON {
  95148. /** @hidden */
  95149. export var fresnelFunction: {
  95150. name: string;
  95151. shader: string;
  95152. };
  95153. }
  95154. declare module BABYLON {
  95155. /** @hidden */
  95156. export var reflectionFunction: {
  95157. name: string;
  95158. shader: string;
  95159. };
  95160. }
  95161. declare module BABYLON {
  95162. /** @hidden */
  95163. export var bumpFragmentFunctions: {
  95164. name: string;
  95165. shader: string;
  95166. };
  95167. }
  95168. declare module BABYLON {
  95169. /** @hidden */
  95170. export var logDepthDeclaration: {
  95171. name: string;
  95172. shader: string;
  95173. };
  95174. }
  95175. declare module BABYLON {
  95176. /** @hidden */
  95177. export var bumpFragment: {
  95178. name: string;
  95179. shader: string;
  95180. };
  95181. }
  95182. declare module BABYLON {
  95183. /** @hidden */
  95184. export var depthPrePass: {
  95185. name: string;
  95186. shader: string;
  95187. };
  95188. }
  95189. declare module BABYLON {
  95190. /** @hidden */
  95191. export var lightFragment: {
  95192. name: string;
  95193. shader: string;
  95194. };
  95195. }
  95196. declare module BABYLON {
  95197. /** @hidden */
  95198. export var logDepthFragment: {
  95199. name: string;
  95200. shader: string;
  95201. };
  95202. }
  95203. declare module BABYLON {
  95204. /** @hidden */
  95205. export var defaultPixelShader: {
  95206. name: string;
  95207. shader: string;
  95208. };
  95209. }
  95210. declare module BABYLON {
  95211. /** @hidden */
  95212. export var defaultVertexDeclaration: {
  95213. name: string;
  95214. shader: string;
  95215. };
  95216. }
  95217. declare module BABYLON {
  95218. /** @hidden */
  95219. export var bumpVertexDeclaration: {
  95220. name: string;
  95221. shader: string;
  95222. };
  95223. }
  95224. declare module BABYLON {
  95225. /** @hidden */
  95226. export var bumpVertex: {
  95227. name: string;
  95228. shader: string;
  95229. };
  95230. }
  95231. declare module BABYLON {
  95232. /** @hidden */
  95233. export var fogVertex: {
  95234. name: string;
  95235. shader: string;
  95236. };
  95237. }
  95238. declare module BABYLON {
  95239. /** @hidden */
  95240. export var shadowsVertex: {
  95241. name: string;
  95242. shader: string;
  95243. };
  95244. }
  95245. declare module BABYLON {
  95246. /** @hidden */
  95247. export var pointCloudVertex: {
  95248. name: string;
  95249. shader: string;
  95250. };
  95251. }
  95252. declare module BABYLON {
  95253. /** @hidden */
  95254. export var logDepthVertex: {
  95255. name: string;
  95256. shader: string;
  95257. };
  95258. }
  95259. declare module BABYLON {
  95260. /** @hidden */
  95261. export var defaultVertexShader: {
  95262. name: string;
  95263. shader: string;
  95264. };
  95265. }
  95266. declare module BABYLON {
  95267. /** @hidden */
  95268. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95269. MAINUV1: boolean;
  95270. MAINUV2: boolean;
  95271. DIFFUSE: boolean;
  95272. DIFFUSEDIRECTUV: number;
  95273. AMBIENT: boolean;
  95274. AMBIENTDIRECTUV: number;
  95275. OPACITY: boolean;
  95276. OPACITYDIRECTUV: number;
  95277. OPACITYRGB: boolean;
  95278. REFLECTION: boolean;
  95279. EMISSIVE: boolean;
  95280. EMISSIVEDIRECTUV: number;
  95281. SPECULAR: boolean;
  95282. SPECULARDIRECTUV: number;
  95283. BUMP: boolean;
  95284. BUMPDIRECTUV: number;
  95285. PARALLAX: boolean;
  95286. PARALLAXOCCLUSION: boolean;
  95287. SPECULAROVERALPHA: boolean;
  95288. CLIPPLANE: boolean;
  95289. CLIPPLANE2: boolean;
  95290. CLIPPLANE3: boolean;
  95291. CLIPPLANE4: boolean;
  95292. ALPHATEST: boolean;
  95293. DEPTHPREPASS: boolean;
  95294. ALPHAFROMDIFFUSE: boolean;
  95295. POINTSIZE: boolean;
  95296. FOG: boolean;
  95297. SPECULARTERM: boolean;
  95298. DIFFUSEFRESNEL: boolean;
  95299. OPACITYFRESNEL: boolean;
  95300. REFLECTIONFRESNEL: boolean;
  95301. REFRACTIONFRESNEL: boolean;
  95302. EMISSIVEFRESNEL: boolean;
  95303. FRESNEL: boolean;
  95304. NORMAL: boolean;
  95305. UV1: boolean;
  95306. UV2: boolean;
  95307. VERTEXCOLOR: boolean;
  95308. VERTEXALPHA: boolean;
  95309. NUM_BONE_INFLUENCERS: number;
  95310. BonesPerMesh: number;
  95311. BONETEXTURE: boolean;
  95312. INSTANCES: boolean;
  95313. GLOSSINESS: boolean;
  95314. ROUGHNESS: boolean;
  95315. EMISSIVEASILLUMINATION: boolean;
  95316. LINKEMISSIVEWITHDIFFUSE: boolean;
  95317. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95318. LIGHTMAP: boolean;
  95319. LIGHTMAPDIRECTUV: number;
  95320. OBJECTSPACE_NORMALMAP: boolean;
  95321. USELIGHTMAPASSHADOWMAP: boolean;
  95322. REFLECTIONMAP_3D: boolean;
  95323. REFLECTIONMAP_SPHERICAL: boolean;
  95324. REFLECTIONMAP_PLANAR: boolean;
  95325. REFLECTIONMAP_CUBIC: boolean;
  95326. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95327. REFLECTIONMAP_PROJECTION: boolean;
  95328. REFLECTIONMAP_SKYBOX: boolean;
  95329. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95330. REFLECTIONMAP_EXPLICIT: boolean;
  95331. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95332. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95333. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95334. INVERTCUBICMAP: boolean;
  95335. LOGARITHMICDEPTH: boolean;
  95336. REFRACTION: boolean;
  95337. REFRACTIONMAP_3D: boolean;
  95338. REFLECTIONOVERALPHA: boolean;
  95339. TWOSIDEDLIGHTING: boolean;
  95340. SHADOWFLOAT: boolean;
  95341. MORPHTARGETS: boolean;
  95342. MORPHTARGETS_NORMAL: boolean;
  95343. MORPHTARGETS_TANGENT: boolean;
  95344. NUM_MORPH_INFLUENCERS: number;
  95345. NONUNIFORMSCALING: boolean;
  95346. PREMULTIPLYALPHA: boolean;
  95347. IMAGEPROCESSING: boolean;
  95348. VIGNETTE: boolean;
  95349. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95350. VIGNETTEBLENDMODEOPAQUE: boolean;
  95351. TONEMAPPING: boolean;
  95352. TONEMAPPING_ACES: boolean;
  95353. CONTRAST: boolean;
  95354. COLORCURVES: boolean;
  95355. COLORGRADING: boolean;
  95356. COLORGRADING3D: boolean;
  95357. SAMPLER3DGREENDEPTH: boolean;
  95358. SAMPLER3DBGRMAP: boolean;
  95359. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95360. /**
  95361. * If the reflection texture on this material is in linear color space
  95362. * @hidden
  95363. */
  95364. IS_REFLECTION_LINEAR: boolean;
  95365. /**
  95366. * If the refraction texture on this material is in linear color space
  95367. * @hidden
  95368. */
  95369. IS_REFRACTION_LINEAR: boolean;
  95370. EXPOSURE: boolean;
  95371. constructor();
  95372. setReflectionMode(modeToEnable: string): void;
  95373. }
  95374. /**
  95375. * This is the default material used in Babylon. It is the best trade off between quality
  95376. * and performances.
  95377. * @see http://doc.babylonjs.com/babylon101/materials
  95378. */
  95379. export class StandardMaterial extends PushMaterial {
  95380. private _diffuseTexture;
  95381. /**
  95382. * The basic texture of the material as viewed under a light.
  95383. */
  95384. diffuseTexture: Nullable<BaseTexture>;
  95385. private _ambientTexture;
  95386. /**
  95387. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95388. */
  95389. ambientTexture: Nullable<BaseTexture>;
  95390. private _opacityTexture;
  95391. /**
  95392. * Define the transparency of the material from a texture.
  95393. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95394. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95395. */
  95396. opacityTexture: Nullable<BaseTexture>;
  95397. private _reflectionTexture;
  95398. /**
  95399. * Define the texture used to display the reflection.
  95400. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95401. */
  95402. reflectionTexture: Nullable<BaseTexture>;
  95403. private _emissiveTexture;
  95404. /**
  95405. * Define texture of the material as if self lit.
  95406. * This will be mixed in the final result even in the absence of light.
  95407. */
  95408. emissiveTexture: Nullable<BaseTexture>;
  95409. private _specularTexture;
  95410. /**
  95411. * Define how the color and intensity of the highlight given by the light in the material.
  95412. */
  95413. specularTexture: Nullable<BaseTexture>;
  95414. private _bumpTexture;
  95415. /**
  95416. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95417. * 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.
  95418. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95419. */
  95420. bumpTexture: Nullable<BaseTexture>;
  95421. private _lightmapTexture;
  95422. /**
  95423. * Complex lighting can be computationally expensive to compute at runtime.
  95424. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95425. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95426. */
  95427. lightmapTexture: Nullable<BaseTexture>;
  95428. private _refractionTexture;
  95429. /**
  95430. * Define the texture used to display the refraction.
  95431. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95432. */
  95433. refractionTexture: Nullable<BaseTexture>;
  95434. /**
  95435. * The color of the material lit by the environmental background lighting.
  95436. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95437. */
  95438. ambientColor: Color3;
  95439. /**
  95440. * The basic color of the material as viewed under a light.
  95441. */
  95442. diffuseColor: Color3;
  95443. /**
  95444. * Define how the color and intensity of the highlight given by the light in the material.
  95445. */
  95446. specularColor: Color3;
  95447. /**
  95448. * Define the color of the material as if self lit.
  95449. * This will be mixed in the final result even in the absence of light.
  95450. */
  95451. emissiveColor: Color3;
  95452. /**
  95453. * Defines how sharp are the highlights in the material.
  95454. * The bigger the value the sharper giving a more glossy feeling to the result.
  95455. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95456. */
  95457. specularPower: number;
  95458. private _useAlphaFromDiffuseTexture;
  95459. /**
  95460. * Does the transparency come from the diffuse texture alpha channel.
  95461. */
  95462. useAlphaFromDiffuseTexture: boolean;
  95463. private _useEmissiveAsIllumination;
  95464. /**
  95465. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95466. */
  95467. useEmissiveAsIllumination: boolean;
  95468. private _linkEmissiveWithDiffuse;
  95469. /**
  95470. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95471. * the emissive level when the final color is close to one.
  95472. */
  95473. linkEmissiveWithDiffuse: boolean;
  95474. private _useSpecularOverAlpha;
  95475. /**
  95476. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95477. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95478. */
  95479. useSpecularOverAlpha: boolean;
  95480. private _useReflectionOverAlpha;
  95481. /**
  95482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95484. */
  95485. useReflectionOverAlpha: boolean;
  95486. private _disableLighting;
  95487. /**
  95488. * Does lights from the scene impacts this material.
  95489. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95490. */
  95491. disableLighting: boolean;
  95492. private _useObjectSpaceNormalMap;
  95493. /**
  95494. * Allows using an object space normal map (instead of tangent space).
  95495. */
  95496. useObjectSpaceNormalMap: boolean;
  95497. private _useParallax;
  95498. /**
  95499. * Is parallax enabled or not.
  95500. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95501. */
  95502. useParallax: boolean;
  95503. private _useParallaxOcclusion;
  95504. /**
  95505. * Is parallax occlusion enabled or not.
  95506. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95507. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95508. */
  95509. useParallaxOcclusion: boolean;
  95510. /**
  95511. * 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.
  95512. */
  95513. parallaxScaleBias: number;
  95514. private _roughness;
  95515. /**
  95516. * Helps to define how blurry the reflections should appears in the material.
  95517. */
  95518. roughness: number;
  95519. /**
  95520. * In case of refraction, define the value of the indice of refraction.
  95521. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95522. */
  95523. indexOfRefraction: number;
  95524. /**
  95525. * Invert the refraction texture alongside the y axis.
  95526. * It can be useful with procedural textures or probe for instance.
  95527. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95528. */
  95529. invertRefractionY: boolean;
  95530. /**
  95531. * Defines the alpha limits in alpha test mode.
  95532. */
  95533. alphaCutOff: number;
  95534. private _useLightmapAsShadowmap;
  95535. /**
  95536. * In case of light mapping, define whether the map contains light or shadow informations.
  95537. */
  95538. useLightmapAsShadowmap: boolean;
  95539. private _diffuseFresnelParameters;
  95540. /**
  95541. * Define the diffuse fresnel parameters of the material.
  95542. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95543. */
  95544. diffuseFresnelParameters: FresnelParameters;
  95545. private _opacityFresnelParameters;
  95546. /**
  95547. * Define the opacity fresnel parameters of the material.
  95548. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95549. */
  95550. opacityFresnelParameters: FresnelParameters;
  95551. private _reflectionFresnelParameters;
  95552. /**
  95553. * Define the reflection fresnel parameters of the material.
  95554. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95555. */
  95556. reflectionFresnelParameters: FresnelParameters;
  95557. private _refractionFresnelParameters;
  95558. /**
  95559. * Define the refraction fresnel parameters of the material.
  95560. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95561. */
  95562. refractionFresnelParameters: FresnelParameters;
  95563. private _emissiveFresnelParameters;
  95564. /**
  95565. * Define the emissive fresnel parameters of the material.
  95566. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95567. */
  95568. emissiveFresnelParameters: FresnelParameters;
  95569. private _useReflectionFresnelFromSpecular;
  95570. /**
  95571. * If true automatically deducts the fresnels values from the material specularity.
  95572. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95573. */
  95574. useReflectionFresnelFromSpecular: boolean;
  95575. private _useGlossinessFromSpecularMapAlpha;
  95576. /**
  95577. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95578. */
  95579. useGlossinessFromSpecularMapAlpha: boolean;
  95580. private _maxSimultaneousLights;
  95581. /**
  95582. * Defines the maximum number of lights that can be used in the material
  95583. */
  95584. maxSimultaneousLights: number;
  95585. private _invertNormalMapX;
  95586. /**
  95587. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95588. */
  95589. invertNormalMapX: boolean;
  95590. private _invertNormalMapY;
  95591. /**
  95592. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95593. */
  95594. invertNormalMapY: boolean;
  95595. private _twoSidedLighting;
  95596. /**
  95597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95598. */
  95599. twoSidedLighting: boolean;
  95600. /**
  95601. * Default configuration related to image processing available in the standard Material.
  95602. */
  95603. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95604. /**
  95605. * Gets the image processing configuration used either in this material.
  95606. */
  95607. /**
  95608. * Sets the Default image processing configuration used either in the this material.
  95609. *
  95610. * If sets to null, the scene one is in use.
  95611. */
  95612. imageProcessingConfiguration: ImageProcessingConfiguration;
  95613. /**
  95614. * Keep track of the image processing observer to allow dispose and replace.
  95615. */
  95616. private _imageProcessingObserver;
  95617. /**
  95618. * Attaches a new image processing configuration to the Standard Material.
  95619. * @param configuration
  95620. */
  95621. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95622. /**
  95623. * Gets wether the color curves effect is enabled.
  95624. */
  95625. /**
  95626. * Sets wether the color curves effect is enabled.
  95627. */
  95628. cameraColorCurvesEnabled: boolean;
  95629. /**
  95630. * Gets wether the color grading effect is enabled.
  95631. */
  95632. /**
  95633. * Gets wether the color grading effect is enabled.
  95634. */
  95635. cameraColorGradingEnabled: boolean;
  95636. /**
  95637. * Gets wether tonemapping is enabled or not.
  95638. */
  95639. /**
  95640. * Sets wether tonemapping is enabled or not
  95641. */
  95642. cameraToneMappingEnabled: boolean;
  95643. /**
  95644. * The camera exposure used on this material.
  95645. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95646. * This corresponds to a photographic exposure.
  95647. */
  95648. /**
  95649. * The camera exposure used on this material.
  95650. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95651. * This corresponds to a photographic exposure.
  95652. */
  95653. cameraExposure: number;
  95654. /**
  95655. * Gets The camera contrast used on this material.
  95656. */
  95657. /**
  95658. * Sets The camera contrast used on this material.
  95659. */
  95660. cameraContrast: number;
  95661. /**
  95662. * Gets the Color Grading 2D Lookup Texture.
  95663. */
  95664. /**
  95665. * Sets the Color Grading 2D Lookup Texture.
  95666. */
  95667. cameraColorGradingTexture: Nullable<BaseTexture>;
  95668. /**
  95669. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95670. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95671. * 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;
  95672. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95673. */
  95674. /**
  95675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95677. * 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;
  95678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95679. */
  95680. cameraColorCurves: Nullable<ColorCurves>;
  95681. /**
  95682. * Custom callback helping to override the default shader used in the material.
  95683. */
  95684. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95685. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95686. protected _worldViewProjectionMatrix: Matrix;
  95687. protected _globalAmbientColor: Color3;
  95688. protected _useLogarithmicDepth: boolean;
  95689. /**
  95690. * Instantiates a new standard material.
  95691. * This is the default material used in Babylon. It is the best trade off between quality
  95692. * and performances.
  95693. * @see http://doc.babylonjs.com/babylon101/materials
  95694. * @param name Define the name of the material in the scene
  95695. * @param scene Define the scene the material belong to
  95696. */
  95697. constructor(name: string, scene: Scene);
  95698. /**
  95699. * Gets a boolean indicating that current material needs to register RTT
  95700. */
  95701. readonly hasRenderTargetTextures: boolean;
  95702. /**
  95703. * Gets the current class name of the material e.g. "StandardMaterial"
  95704. * Mainly use in serialization.
  95705. * @returns the class name
  95706. */
  95707. getClassName(): string;
  95708. /**
  95709. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95710. * You can try switching to logarithmic depth.
  95711. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95712. */
  95713. useLogarithmicDepth: boolean;
  95714. /**
  95715. * Specifies if the material will require alpha blending
  95716. * @returns a boolean specifying if alpha blending is needed
  95717. */
  95718. needAlphaBlending(): boolean;
  95719. /**
  95720. * Specifies if this material should be rendered in alpha test mode
  95721. * @returns a boolean specifying if an alpha test is needed.
  95722. */
  95723. needAlphaTesting(): boolean;
  95724. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95725. /**
  95726. * Get the texture used for alpha test purpose.
  95727. * @returns the diffuse texture in case of the standard material.
  95728. */
  95729. getAlphaTestTexture(): Nullable<BaseTexture>;
  95730. /**
  95731. * Get if the submesh is ready to be used and all its information available.
  95732. * Child classes can use it to update shaders
  95733. * @param mesh defines the mesh to check
  95734. * @param subMesh defines which submesh to check
  95735. * @param useInstances specifies that instances should be used
  95736. * @returns a boolean indicating that the submesh is ready or not
  95737. */
  95738. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95739. /**
  95740. * Builds the material UBO layouts.
  95741. * Used internally during the effect preparation.
  95742. */
  95743. buildUniformLayout(): void;
  95744. /**
  95745. * Unbinds the material from the mesh
  95746. */
  95747. unbind(): void;
  95748. /**
  95749. * Binds the submesh to this material by preparing the effect and shader to draw
  95750. * @param world defines the world transformation matrix
  95751. * @param mesh defines the mesh containing the submesh
  95752. * @param subMesh defines the submesh to bind the material to
  95753. */
  95754. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95755. /**
  95756. * Get the list of animatables in the material.
  95757. * @returns the list of animatables object used in the material
  95758. */
  95759. getAnimatables(): IAnimatable[];
  95760. /**
  95761. * Gets the active textures from the material
  95762. * @returns an array of textures
  95763. */
  95764. getActiveTextures(): BaseTexture[];
  95765. /**
  95766. * Specifies if the material uses a texture
  95767. * @param texture defines the texture to check against the material
  95768. * @returns a boolean specifying if the material uses the texture
  95769. */
  95770. hasTexture(texture: BaseTexture): boolean;
  95771. /**
  95772. * Disposes the material
  95773. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95774. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95775. */
  95776. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95777. /**
  95778. * Makes a duplicate of the material, and gives it a new name
  95779. * @param name defines the new name for the duplicated material
  95780. * @returns the cloned material
  95781. */
  95782. clone(name: string): StandardMaterial;
  95783. /**
  95784. * Serializes this material in a JSON representation
  95785. * @returns the serialized material object
  95786. */
  95787. serialize(): any;
  95788. /**
  95789. * Creates a standard material from parsed material data
  95790. * @param source defines the JSON representation of the material
  95791. * @param scene defines the hosting scene
  95792. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95793. * @returns a new standard material
  95794. */
  95795. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95796. /**
  95797. * Are diffuse textures enabled in the application.
  95798. */
  95799. static DiffuseTextureEnabled: boolean;
  95800. /**
  95801. * Are ambient textures enabled in the application.
  95802. */
  95803. static AmbientTextureEnabled: boolean;
  95804. /**
  95805. * Are opacity textures enabled in the application.
  95806. */
  95807. static OpacityTextureEnabled: boolean;
  95808. /**
  95809. * Are reflection textures enabled in the application.
  95810. */
  95811. static ReflectionTextureEnabled: boolean;
  95812. /**
  95813. * Are emissive textures enabled in the application.
  95814. */
  95815. static EmissiveTextureEnabled: boolean;
  95816. /**
  95817. * Are specular textures enabled in the application.
  95818. */
  95819. static SpecularTextureEnabled: boolean;
  95820. /**
  95821. * Are bump textures enabled in the application.
  95822. */
  95823. static BumpTextureEnabled: boolean;
  95824. /**
  95825. * Are lightmap textures enabled in the application.
  95826. */
  95827. static LightmapTextureEnabled: boolean;
  95828. /**
  95829. * Are refraction textures enabled in the application.
  95830. */
  95831. static RefractionTextureEnabled: boolean;
  95832. /**
  95833. * Are color grading textures enabled in the application.
  95834. */
  95835. static ColorGradingTextureEnabled: boolean;
  95836. /**
  95837. * Are fresnels enabled in the application.
  95838. */
  95839. static FresnelEnabled: boolean;
  95840. }
  95841. }
  95842. declare module BABYLON {
  95843. /**
  95844. * A class extending Texture allowing drawing on a texture
  95845. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95846. */
  95847. export class DynamicTexture extends Texture {
  95848. private _generateMipMaps;
  95849. private _canvas;
  95850. private _context;
  95851. private _engine;
  95852. /**
  95853. * Creates a DynamicTexture
  95854. * @param name defines the name of the texture
  95855. * @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
  95856. * @param scene defines the scene where you want the texture
  95857. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95858. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95859. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95860. */
  95861. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95862. /**
  95863. * Get the current class name of the texture useful for serialization or dynamic coding.
  95864. * @returns "DynamicTexture"
  95865. */
  95866. getClassName(): string;
  95867. /**
  95868. * Gets the current state of canRescale
  95869. */
  95870. readonly canRescale: boolean;
  95871. private _recreate;
  95872. /**
  95873. * Scales the texture
  95874. * @param ratio the scale factor to apply to both width and height
  95875. */
  95876. scale(ratio: number): void;
  95877. /**
  95878. * Resizes the texture
  95879. * @param width the new width
  95880. * @param height the new height
  95881. */
  95882. scaleTo(width: number, height: number): void;
  95883. /**
  95884. * Gets the context of the canvas used by the texture
  95885. * @returns the canvas context of the dynamic texture
  95886. */
  95887. getContext(): CanvasRenderingContext2D;
  95888. /**
  95889. * Clears the texture
  95890. */
  95891. clear(): void;
  95892. /**
  95893. * Updates the texture
  95894. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95895. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95896. */
  95897. update(invertY?: boolean, premulAlpha?: boolean): void;
  95898. /**
  95899. * Draws text onto the texture
  95900. * @param text defines the text to be drawn
  95901. * @param x defines the placement of the text from the left
  95902. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95903. * @param font defines the font to be used with font-style, font-size, font-name
  95904. * @param color defines the color used for the text
  95905. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95906. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95907. * @param update defines whether texture is immediately update (default is true)
  95908. */
  95909. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95910. /**
  95911. * Clones the texture
  95912. * @returns the clone of the texture.
  95913. */
  95914. clone(): DynamicTexture;
  95915. /**
  95916. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95917. * @returns a serialized dynamic texture object
  95918. */
  95919. serialize(): any;
  95920. /** @hidden */
  95921. _rebuild(): void;
  95922. }
  95923. }
  95924. declare module BABYLON {
  95925. /** @hidden */
  95926. export var imageProcessingPixelShader: {
  95927. name: string;
  95928. shader: string;
  95929. };
  95930. }
  95931. declare module BABYLON {
  95932. /**
  95933. * ImageProcessingPostProcess
  95934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95935. */
  95936. export class ImageProcessingPostProcess extends PostProcess {
  95937. /**
  95938. * Default configuration related to image processing available in the PBR Material.
  95939. */
  95940. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95941. /**
  95942. * Gets the image processing configuration used either in this material.
  95943. */
  95944. /**
  95945. * Sets the Default image processing configuration used either in the this material.
  95946. *
  95947. * If sets to null, the scene one is in use.
  95948. */
  95949. imageProcessingConfiguration: ImageProcessingConfiguration;
  95950. /**
  95951. * Keep track of the image processing observer to allow dispose and replace.
  95952. */
  95953. private _imageProcessingObserver;
  95954. /**
  95955. * Attaches a new image processing configuration to the PBR Material.
  95956. * @param configuration
  95957. */
  95958. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95959. /**
  95960. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95961. */
  95962. /**
  95963. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95964. */
  95965. colorCurves: Nullable<ColorCurves>;
  95966. /**
  95967. * Gets wether the color curves effect is enabled.
  95968. */
  95969. /**
  95970. * Sets wether the color curves effect is enabled.
  95971. */
  95972. colorCurvesEnabled: boolean;
  95973. /**
  95974. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95975. */
  95976. /**
  95977. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95978. */
  95979. colorGradingTexture: Nullable<BaseTexture>;
  95980. /**
  95981. * Gets wether the color grading effect is enabled.
  95982. */
  95983. /**
  95984. * Gets wether the color grading effect is enabled.
  95985. */
  95986. colorGradingEnabled: boolean;
  95987. /**
  95988. * Gets exposure used in the effect.
  95989. */
  95990. /**
  95991. * Sets exposure used in the effect.
  95992. */
  95993. exposure: number;
  95994. /**
  95995. * Gets wether tonemapping is enabled or not.
  95996. */
  95997. /**
  95998. * Sets wether tonemapping is enabled or not
  95999. */
  96000. toneMappingEnabled: boolean;
  96001. /**
  96002. * Gets the type of tone mapping effect.
  96003. */
  96004. /**
  96005. * Sets the type of tone mapping effect.
  96006. */
  96007. toneMappingType: number;
  96008. /**
  96009. * Gets contrast used in the effect.
  96010. */
  96011. /**
  96012. * Sets contrast used in the effect.
  96013. */
  96014. contrast: number;
  96015. /**
  96016. * Gets Vignette stretch size.
  96017. */
  96018. /**
  96019. * Sets Vignette stretch size.
  96020. */
  96021. vignetteStretch: number;
  96022. /**
  96023. * Gets Vignette centre X Offset.
  96024. */
  96025. /**
  96026. * Sets Vignette centre X Offset.
  96027. */
  96028. vignetteCentreX: number;
  96029. /**
  96030. * Gets Vignette centre Y Offset.
  96031. */
  96032. /**
  96033. * Sets Vignette centre Y Offset.
  96034. */
  96035. vignetteCentreY: number;
  96036. /**
  96037. * Gets Vignette weight or intensity of the vignette effect.
  96038. */
  96039. /**
  96040. * Sets Vignette weight or intensity of the vignette effect.
  96041. */
  96042. vignetteWeight: number;
  96043. /**
  96044. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96045. * if vignetteEnabled is set to true.
  96046. */
  96047. /**
  96048. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96049. * if vignetteEnabled is set to true.
  96050. */
  96051. vignetteColor: Color4;
  96052. /**
  96053. * Gets Camera field of view used by the Vignette effect.
  96054. */
  96055. /**
  96056. * Sets Camera field of view used by the Vignette effect.
  96057. */
  96058. vignetteCameraFov: number;
  96059. /**
  96060. * Gets the vignette blend mode allowing different kind of effect.
  96061. */
  96062. /**
  96063. * Sets the vignette blend mode allowing different kind of effect.
  96064. */
  96065. vignetteBlendMode: number;
  96066. /**
  96067. * Gets wether the vignette effect is enabled.
  96068. */
  96069. /**
  96070. * Sets wether the vignette effect is enabled.
  96071. */
  96072. vignetteEnabled: boolean;
  96073. private _fromLinearSpace;
  96074. /**
  96075. * Gets wether the input of the processing is in Gamma or Linear Space.
  96076. */
  96077. /**
  96078. * Sets wether the input of the processing is in Gamma or Linear Space.
  96079. */
  96080. fromLinearSpace: boolean;
  96081. /**
  96082. * Defines cache preventing GC.
  96083. */
  96084. private _defines;
  96085. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96086. /**
  96087. * "ImageProcessingPostProcess"
  96088. * @returns "ImageProcessingPostProcess"
  96089. */
  96090. getClassName(): string;
  96091. protected _updateParameters(): void;
  96092. dispose(camera?: Camera): void;
  96093. }
  96094. }
  96095. declare module BABYLON {
  96096. /**
  96097. * Class containing static functions to help procedurally build meshes
  96098. */
  96099. export class GroundBuilder {
  96100. /**
  96101. * Creates a ground mesh
  96102. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96103. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96105. * @param name defines the name of the mesh
  96106. * @param options defines the options used to create the mesh
  96107. * @param scene defines the hosting scene
  96108. * @returns the ground mesh
  96109. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96110. */
  96111. static CreateGround(name: string, options: {
  96112. width?: number;
  96113. height?: number;
  96114. subdivisions?: number;
  96115. subdivisionsX?: number;
  96116. subdivisionsY?: number;
  96117. updatable?: boolean;
  96118. }, scene: any): Mesh;
  96119. /**
  96120. * Creates a tiled ground mesh
  96121. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96122. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96123. * * 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
  96124. * * 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
  96125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96126. * @param name defines the name of the mesh
  96127. * @param options defines the options used to create the mesh
  96128. * @param scene defines the hosting scene
  96129. * @returns the tiled ground mesh
  96130. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96131. */
  96132. static CreateTiledGround(name: string, options: {
  96133. xmin: number;
  96134. zmin: number;
  96135. xmax: number;
  96136. zmax: number;
  96137. subdivisions?: {
  96138. w: number;
  96139. h: number;
  96140. };
  96141. precision?: {
  96142. w: number;
  96143. h: number;
  96144. };
  96145. updatable?: boolean;
  96146. }, scene: Scene): Mesh;
  96147. /**
  96148. * Creates a ground mesh from a height map
  96149. * * The parameter `url` sets the URL of the height map image resource.
  96150. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96151. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96152. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96153. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96154. * * 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.
  96155. * * 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).
  96156. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96158. * @param name defines the name of the mesh
  96159. * @param url defines the url to the height map
  96160. * @param options defines the options used to create the mesh
  96161. * @param scene defines the hosting scene
  96162. * @returns the ground mesh
  96163. * @see https://doc.babylonjs.com/babylon101/height_map
  96164. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96165. */
  96166. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96167. width?: number;
  96168. height?: number;
  96169. subdivisions?: number;
  96170. minHeight?: number;
  96171. maxHeight?: number;
  96172. colorFilter?: Color3;
  96173. alphaFilter?: number;
  96174. updatable?: boolean;
  96175. onReady?: (mesh: GroundMesh) => void;
  96176. }, scene: Scene): GroundMesh;
  96177. }
  96178. }
  96179. declare module BABYLON {
  96180. /**
  96181. * Class containing static functions to help procedurally build meshes
  96182. */
  96183. export class TorusBuilder {
  96184. /**
  96185. * Creates a torus mesh
  96186. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96187. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96188. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96190. * * If you create a double-sided mesh, you can choose what parts of 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
  96191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96192. * @param name defines the name of the mesh
  96193. * @param options defines the options used to create the mesh
  96194. * @param scene defines the hosting scene
  96195. * @returns the torus mesh
  96196. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96197. */
  96198. static CreateTorus(name: string, options: {
  96199. diameter?: number;
  96200. thickness?: number;
  96201. tessellation?: number;
  96202. updatable?: boolean;
  96203. sideOrientation?: number;
  96204. frontUVs?: Vector4;
  96205. backUVs?: Vector4;
  96206. }, scene: any): Mesh;
  96207. }
  96208. }
  96209. declare module BABYLON {
  96210. /**
  96211. * Class containing static functions to help procedurally build meshes
  96212. */
  96213. export class CylinderBuilder {
  96214. /**
  96215. * Creates a cylinder or a cone mesh
  96216. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96217. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96218. * * 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.
  96219. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96220. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96221. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96222. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96223. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96224. * * 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).
  96225. * * 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
  96226. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96227. * * 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
  96228. * * 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.
  96229. * * If `enclose` is false, a ring surface is one element.
  96230. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96231. * * 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
  96232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96233. * * If you create a double-sided mesh, you can choose what parts of 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
  96234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96235. * @param name defines the name of the mesh
  96236. * @param options defines the options used to create the mesh
  96237. * @param scene defines the hosting scene
  96238. * @returns the cylinder mesh
  96239. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96240. */
  96241. static CreateCylinder(name: string, options: {
  96242. height?: number;
  96243. diameterTop?: number;
  96244. diameterBottom?: number;
  96245. diameter?: number;
  96246. tessellation?: number;
  96247. subdivisions?: number;
  96248. arc?: number;
  96249. faceColors?: Color4[];
  96250. faceUV?: Vector4[];
  96251. updatable?: boolean;
  96252. hasRings?: boolean;
  96253. enclose?: boolean;
  96254. sideOrientation?: number;
  96255. frontUVs?: Vector4;
  96256. backUVs?: Vector4;
  96257. }, scene: any): Mesh;
  96258. }
  96259. }
  96260. declare module BABYLON {
  96261. /**
  96262. * Manager for handling gamepads
  96263. */
  96264. export class GamepadManager {
  96265. private _scene?;
  96266. private _babylonGamepads;
  96267. private _oneGamepadConnected;
  96268. /** @hidden */
  96269. _isMonitoring: boolean;
  96270. private _gamepadEventSupported;
  96271. private _gamepadSupport;
  96272. /**
  96273. * observable to be triggered when the gamepad controller has been connected
  96274. */
  96275. onGamepadConnectedObservable: Observable<Gamepad>;
  96276. /**
  96277. * observable to be triggered when the gamepad controller has been disconnected
  96278. */
  96279. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96280. private _onGamepadConnectedEvent;
  96281. private _onGamepadDisconnectedEvent;
  96282. /**
  96283. * Initializes the gamepad manager
  96284. * @param _scene BabylonJS scene
  96285. */
  96286. constructor(_scene?: Scene | undefined);
  96287. /**
  96288. * The gamepads in the game pad manager
  96289. */
  96290. readonly gamepads: Gamepad[];
  96291. /**
  96292. * Get the gamepad controllers based on type
  96293. * @param type The type of gamepad controller
  96294. * @returns Nullable gamepad
  96295. */
  96296. getGamepadByType(type?: number): Nullable<Gamepad>;
  96297. /**
  96298. * Disposes the gamepad manager
  96299. */
  96300. dispose(): void;
  96301. private _addNewGamepad;
  96302. private _startMonitoringGamepads;
  96303. private _stopMonitoringGamepads;
  96304. /** @hidden */
  96305. _checkGamepadsStatus(): void;
  96306. private _updateGamepadObjects;
  96307. }
  96308. }
  96309. declare module BABYLON {
  96310. interface Scene {
  96311. /** @hidden */
  96312. _gamepadManager: Nullable<GamepadManager>;
  96313. /**
  96314. * Gets the gamepad manager associated with the scene
  96315. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96316. */
  96317. gamepadManager: GamepadManager;
  96318. }
  96319. /**
  96320. * Interface representing a free camera inputs manager
  96321. */
  96322. interface FreeCameraInputsManager {
  96323. /**
  96324. * Adds gamepad input support to the FreeCameraInputsManager.
  96325. * @returns the FreeCameraInputsManager
  96326. */
  96327. addGamepad(): FreeCameraInputsManager;
  96328. }
  96329. /**
  96330. * Interface representing an arc rotate camera inputs manager
  96331. */
  96332. interface ArcRotateCameraInputsManager {
  96333. /**
  96334. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96335. * @returns the camera inputs manager
  96336. */
  96337. addGamepad(): ArcRotateCameraInputsManager;
  96338. }
  96339. /**
  96340. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96341. */
  96342. export class GamepadSystemSceneComponent implements ISceneComponent {
  96343. /**
  96344. * The component name helpfull to identify the component in the list of scene components.
  96345. */
  96346. readonly name: string;
  96347. /**
  96348. * The scene the component belongs to.
  96349. */
  96350. scene: Scene;
  96351. /**
  96352. * Creates a new instance of the component for the given scene
  96353. * @param scene Defines the scene to register the component in
  96354. */
  96355. constructor(scene: Scene);
  96356. /**
  96357. * Registers the component in a given scene
  96358. */
  96359. register(): void;
  96360. /**
  96361. * Rebuilds the elements related to this component in case of
  96362. * context lost for instance.
  96363. */
  96364. rebuild(): void;
  96365. /**
  96366. * Disposes the component and the associated ressources
  96367. */
  96368. dispose(): void;
  96369. private _beforeCameraUpdate;
  96370. }
  96371. }
  96372. declare module BABYLON {
  96373. /**
  96374. * Options to modify the vr teleportation behavior.
  96375. */
  96376. export interface VRTeleportationOptions {
  96377. /**
  96378. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96379. */
  96380. floorMeshName?: string;
  96381. /**
  96382. * A list of meshes to be used as the teleportation floor. (default: empty)
  96383. */
  96384. floorMeshes?: Mesh[];
  96385. }
  96386. /**
  96387. * Options to modify the vr experience helper's behavior.
  96388. */
  96389. export interface VRExperienceHelperOptions extends WebVROptions {
  96390. /**
  96391. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96392. */
  96393. createDeviceOrientationCamera?: boolean;
  96394. /**
  96395. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96396. */
  96397. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96398. /**
  96399. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96400. */
  96401. laserToggle?: boolean;
  96402. /**
  96403. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96404. */
  96405. floorMeshes?: Mesh[];
  96406. /**
  96407. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96408. */
  96409. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96410. }
  96411. /**
  96412. * Event containing information after VR has been entered
  96413. */
  96414. export class OnAfterEnteringVRObservableEvent {
  96415. /**
  96416. * If entering vr was successful
  96417. */
  96418. success: boolean;
  96419. }
  96420. /**
  96421. * Helps to quickly add VR support to an existing scene.
  96422. * See http://doc.babylonjs.com/how_to/webvr_helper
  96423. */
  96424. export class VRExperienceHelper {
  96425. /** Options to modify the vr experience helper's behavior. */
  96426. webVROptions: VRExperienceHelperOptions;
  96427. private _scene;
  96428. private _position;
  96429. private _btnVR;
  96430. private _btnVRDisplayed;
  96431. private _webVRsupported;
  96432. private _webVRready;
  96433. private _webVRrequesting;
  96434. private _webVRpresenting;
  96435. private _hasEnteredVR;
  96436. private _fullscreenVRpresenting;
  96437. private _canvas;
  96438. private _webVRCamera;
  96439. private _vrDeviceOrientationCamera;
  96440. private _deviceOrientationCamera;
  96441. private _existingCamera;
  96442. private _onKeyDown;
  96443. private _onVrDisplayPresentChange;
  96444. private _onVRDisplayChanged;
  96445. private _onVRRequestPresentStart;
  96446. private _onVRRequestPresentComplete;
  96447. /**
  96448. * Observable raised right before entering VR.
  96449. */
  96450. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96451. /**
  96452. * Observable raised when entering VR has completed.
  96453. */
  96454. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96455. /**
  96456. * Observable raised when exiting VR.
  96457. */
  96458. onExitingVRObservable: Observable<VRExperienceHelper>;
  96459. /**
  96460. * Observable raised when controller mesh is loaded.
  96461. */
  96462. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96463. /** Return this.onEnteringVRObservable
  96464. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96465. */
  96466. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96467. /** Return this.onExitingVRObservable
  96468. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96469. */
  96470. readonly onExitingVR: Observable<VRExperienceHelper>;
  96471. /** Return this.onControllerMeshLoadedObservable
  96472. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96473. */
  96474. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96475. private _rayLength;
  96476. private _useCustomVRButton;
  96477. private _teleportationRequested;
  96478. private _teleportActive;
  96479. private _floorMeshName;
  96480. private _floorMeshesCollection;
  96481. private _rotationAllowed;
  96482. private _teleportBackwardsVector;
  96483. private _teleportationTarget;
  96484. private _isDefaultTeleportationTarget;
  96485. private _postProcessMove;
  96486. private _teleportationFillColor;
  96487. private _teleportationBorderColor;
  96488. private _rotationAngle;
  96489. private _haloCenter;
  96490. private _cameraGazer;
  96491. private _padSensibilityUp;
  96492. private _padSensibilityDown;
  96493. private _leftController;
  96494. private _rightController;
  96495. /**
  96496. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96497. */
  96498. onNewMeshSelected: Observable<AbstractMesh>;
  96499. /**
  96500. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96501. */
  96502. onNewMeshPicked: Observable<PickingInfo>;
  96503. private _circleEase;
  96504. /**
  96505. * Observable raised before camera teleportation
  96506. */
  96507. onBeforeCameraTeleport: Observable<Vector3>;
  96508. /**
  96509. * Observable raised after camera teleportation
  96510. */
  96511. onAfterCameraTeleport: Observable<Vector3>;
  96512. /**
  96513. * Observable raised when current selected mesh gets unselected
  96514. */
  96515. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96516. private _raySelectionPredicate;
  96517. /**
  96518. * To be optionaly changed by user to define custom ray selection
  96519. */
  96520. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96521. /**
  96522. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96523. */
  96524. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96525. /**
  96526. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96527. */
  96528. teleportationEnabled: boolean;
  96529. private _defaultHeight;
  96530. private _teleportationInitialized;
  96531. private _interactionsEnabled;
  96532. private _interactionsRequested;
  96533. private _displayGaze;
  96534. private _displayLaserPointer;
  96535. /**
  96536. * The mesh used to display where the user is going to teleport.
  96537. */
  96538. /**
  96539. * Sets the mesh to be used to display where the user is going to teleport.
  96540. */
  96541. teleportationTarget: Mesh;
  96542. /**
  96543. * 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
  96544. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96545. * See http://doc.babylonjs.com/resources/baking_transformations
  96546. */
  96547. gazeTrackerMesh: Mesh;
  96548. /**
  96549. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96550. */
  96551. updateGazeTrackerScale: boolean;
  96552. /**
  96553. * If the gaze trackers color should be updated when selecting meshes
  96554. */
  96555. updateGazeTrackerColor: boolean;
  96556. /**
  96557. * The gaze tracking mesh corresponding to the left controller
  96558. */
  96559. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96560. /**
  96561. * The gaze tracking mesh corresponding to the right controller
  96562. */
  96563. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96564. /**
  96565. * If the ray of the gaze should be displayed.
  96566. */
  96567. /**
  96568. * Sets if the ray of the gaze should be displayed.
  96569. */
  96570. displayGaze: boolean;
  96571. /**
  96572. * If the ray of the LaserPointer should be displayed.
  96573. */
  96574. /**
  96575. * Sets if the ray of the LaserPointer should be displayed.
  96576. */
  96577. displayLaserPointer: boolean;
  96578. /**
  96579. * The deviceOrientationCamera used as the camera when not in VR.
  96580. */
  96581. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96582. /**
  96583. * Based on the current WebVR support, returns the current VR camera used.
  96584. */
  96585. readonly currentVRCamera: Nullable<Camera>;
  96586. /**
  96587. * The webVRCamera which is used when in VR.
  96588. */
  96589. readonly webVRCamera: WebVRFreeCamera;
  96590. /**
  96591. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96592. */
  96593. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96594. private readonly _teleportationRequestInitiated;
  96595. /**
  96596. * Defines wether or not Pointer lock should be requested when switching to
  96597. * full screen.
  96598. */
  96599. requestPointerLockOnFullScreen: boolean;
  96600. /**
  96601. * Instantiates a VRExperienceHelper.
  96602. * Helps to quickly add VR support to an existing scene.
  96603. * @param scene The scene the VRExperienceHelper belongs to.
  96604. * @param webVROptions Options to modify the vr experience helper's behavior.
  96605. */
  96606. constructor(scene: Scene,
  96607. /** Options to modify the vr experience helper's behavior. */
  96608. webVROptions?: VRExperienceHelperOptions);
  96609. private _onDefaultMeshLoaded;
  96610. private _onResize;
  96611. private _onFullscreenChange;
  96612. /**
  96613. * Gets a value indicating if we are currently in VR mode.
  96614. */
  96615. readonly isInVRMode: boolean;
  96616. private onVrDisplayPresentChange;
  96617. private onVRDisplayChanged;
  96618. private moveButtonToBottomRight;
  96619. private displayVRButton;
  96620. private updateButtonVisibility;
  96621. private _cachedAngularSensibility;
  96622. /**
  96623. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96624. * Otherwise, will use the fullscreen API.
  96625. */
  96626. enterVR(): void;
  96627. /**
  96628. * Attempt to exit VR, or fullscreen.
  96629. */
  96630. exitVR(): void;
  96631. /**
  96632. * The position of the vr experience helper.
  96633. */
  96634. /**
  96635. * Sets the position of the vr experience helper.
  96636. */
  96637. position: Vector3;
  96638. /**
  96639. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96640. */
  96641. enableInteractions(): void;
  96642. private readonly _noControllerIsActive;
  96643. private beforeRender;
  96644. private _isTeleportationFloor;
  96645. /**
  96646. * Adds a floor mesh to be used for teleportation.
  96647. * @param floorMesh the mesh to be used for teleportation.
  96648. */
  96649. addFloorMesh(floorMesh: Mesh): void;
  96650. /**
  96651. * Removes a floor mesh from being used for teleportation.
  96652. * @param floorMesh the mesh to be removed.
  96653. */
  96654. removeFloorMesh(floorMesh: Mesh): void;
  96655. /**
  96656. * Enables interactions and teleportation using the VR controllers and gaze.
  96657. * @param vrTeleportationOptions options to modify teleportation behavior.
  96658. */
  96659. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96660. private _onNewGamepadConnected;
  96661. private _tryEnableInteractionOnController;
  96662. private _onNewGamepadDisconnected;
  96663. private _enableInteractionOnController;
  96664. private _checkTeleportWithRay;
  96665. private _checkRotate;
  96666. private _checkTeleportBackwards;
  96667. private _enableTeleportationOnController;
  96668. private _createTeleportationCircles;
  96669. private _displayTeleportationTarget;
  96670. private _hideTeleportationTarget;
  96671. private _rotateCamera;
  96672. private _moveTeleportationSelectorTo;
  96673. private _workingVector;
  96674. private _workingQuaternion;
  96675. private _workingMatrix;
  96676. /**
  96677. * Teleports the users feet to the desired location
  96678. * @param location The location where the user's feet should be placed
  96679. */
  96680. teleportCamera(location: Vector3): void;
  96681. private _convertNormalToDirectionOfRay;
  96682. private _castRayAndSelectObject;
  96683. private _notifySelectedMeshUnselected;
  96684. /**
  96685. * Sets the color of the laser ray from the vr controllers.
  96686. * @param color new color for the ray.
  96687. */
  96688. changeLaserColor(color: Color3): void;
  96689. /**
  96690. * Sets the color of the ray from the vr headsets gaze.
  96691. * @param color new color for the ray.
  96692. */
  96693. changeGazeColor(color: Color3): void;
  96694. /**
  96695. * Exits VR and disposes of the vr experience helper
  96696. */
  96697. dispose(): void;
  96698. /**
  96699. * Gets the name of the VRExperienceHelper class
  96700. * @returns "VRExperienceHelper"
  96701. */
  96702. getClassName(): string;
  96703. }
  96704. }
  96705. declare module BABYLON {
  96706. /**
  96707. * Manages an XRSession
  96708. * @see https://doc.babylonjs.com/how_to/webxr
  96709. */
  96710. export class WebXRSessionManager implements IDisposable {
  96711. private scene;
  96712. /**
  96713. * Fires every time a new xrFrame arrives which can be used to update the camera
  96714. */
  96715. onXRFrameObservable: Observable<any>;
  96716. /**
  96717. * Fires when the xr session is ended either by the device or manually done
  96718. */
  96719. onXRSessionEnded: Observable<any>;
  96720. /** @hidden */
  96721. _xrSession: XRSession;
  96722. /** @hidden */
  96723. _frameOfReference: XRFrameOfReference;
  96724. /** @hidden */
  96725. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96726. /** @hidden */
  96727. _currentXRFrame: Nullable<XRFrame>;
  96728. private _xrNavigator;
  96729. private _xrDevice;
  96730. private _tmpMatrix;
  96731. /**
  96732. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96733. * @param scene The scene which the session should be created for
  96734. */
  96735. constructor(scene: Scene);
  96736. /**
  96737. * Initializes the manager
  96738. * After initialization enterXR can be called to start an XR session
  96739. * @returns Promise which resolves after it is initialized
  96740. */
  96741. initializeAsync(): Promise<void>;
  96742. /**
  96743. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96744. * @param sessionCreationOptions xr options to create the session with
  96745. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96746. * @returns Promise which resolves after it enters XR
  96747. */
  96748. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96749. /**
  96750. * Stops the xrSession and restores the renderloop
  96751. * @returns Promise which resolves after it exits XR
  96752. */
  96753. exitXRAsync(): Promise<void>;
  96754. /**
  96755. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96756. * @param ray ray to cast into the environment
  96757. * @returns Promise which resolves with a collision point in the environment if it exists
  96758. */
  96759. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96760. /**
  96761. * Checks if a session would be supported for the creation options specified
  96762. * @param options creation options to check if they are supported
  96763. * @returns true if supported
  96764. */
  96765. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96766. /**
  96767. * @hidden
  96768. * Converts the render layer of xrSession to a render target
  96769. * @param session session to create render target for
  96770. * @param scene scene the new render target should be created for
  96771. */
  96772. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96773. /**
  96774. * Disposes of the session manager
  96775. */
  96776. dispose(): void;
  96777. }
  96778. }
  96779. declare module BABYLON {
  96780. /**
  96781. * WebXR Camera which holds the views for the xrSession
  96782. * @see https://doc.babylonjs.com/how_to/webxr
  96783. */
  96784. export class WebXRCamera extends FreeCamera {
  96785. private static _TmpMatrix;
  96786. /**
  96787. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96788. * @param name the name of the camera
  96789. * @param scene the scene to add the camera to
  96790. */
  96791. constructor(name: string, scene: Scene);
  96792. private _updateNumberOfRigCameras;
  96793. /** @hidden */
  96794. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96795. /**
  96796. * Updates the cameras position from the current pose information of the XR session
  96797. * @param xrSessionManager the session containing pose information
  96798. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96799. */
  96800. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96801. }
  96802. }
  96803. declare module BABYLON {
  96804. /**
  96805. * States of the webXR experience
  96806. */
  96807. export enum WebXRState {
  96808. /**
  96809. * Transitioning to being in XR mode
  96810. */
  96811. ENTERING_XR = 0,
  96812. /**
  96813. * Transitioning to non XR mode
  96814. */
  96815. EXITING_XR = 1,
  96816. /**
  96817. * In XR mode and presenting
  96818. */
  96819. IN_XR = 2,
  96820. /**
  96821. * Not entered XR mode
  96822. */
  96823. NOT_IN_XR = 3
  96824. }
  96825. /**
  96826. * Helper class used to enable XR
  96827. * @see https://doc.babylonjs.com/how_to/webxr
  96828. */
  96829. export class WebXRExperienceHelper implements IDisposable {
  96830. private scene;
  96831. /**
  96832. * 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
  96833. */
  96834. container: AbstractMesh;
  96835. /**
  96836. * Camera used to render xr content
  96837. */
  96838. camera: WebXRCamera;
  96839. /**
  96840. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96841. */
  96842. state: WebXRState;
  96843. private _setState;
  96844. private static _TmpVector;
  96845. /**
  96846. * Fires when the state of the experience helper has changed
  96847. */
  96848. onStateChangedObservable: Observable<WebXRState>;
  96849. /** @hidden */
  96850. _sessionManager: WebXRSessionManager;
  96851. private _nonVRCamera;
  96852. private _originalSceneAutoClear;
  96853. private _supported;
  96854. /**
  96855. * Creates the experience helper
  96856. * @param scene the scene to attach the experience helper to
  96857. * @returns a promise for the experience helper
  96858. */
  96859. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96860. /**
  96861. * Creates a WebXRExperienceHelper
  96862. * @param scene The scene the helper should be created in
  96863. */
  96864. private constructor();
  96865. /**
  96866. * Exits XR mode and returns the scene to its original state
  96867. * @returns promise that resolves after xr mode has exited
  96868. */
  96869. exitXRAsync(): Promise<void>;
  96870. /**
  96871. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96872. * @param sessionCreationOptions options for the XR session
  96873. * @param frameOfReference frame of reference of the XR session
  96874. * @returns promise that resolves after xr mode has entered
  96875. */
  96876. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96877. /**
  96878. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96879. * @param ray ray to cast into the environment
  96880. * @returns Promise which resolves with a collision point in the environment if it exists
  96881. */
  96882. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96883. /**
  96884. * Updates the global position of the camera by moving the camera's container
  96885. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96886. * @param position The desired global position of the camera
  96887. */
  96888. setPositionOfCameraUsingContainer(position: Vector3): void;
  96889. /**
  96890. * Rotates the xr camera by rotating the camera's container around the camera's position
  96891. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96892. * @param rotation the desired quaternion rotation to apply to the camera
  96893. */
  96894. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96895. /**
  96896. * Checks if the creation options are supported by the xr session
  96897. * @param options creation options
  96898. * @returns true if supported
  96899. */
  96900. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96901. /**
  96902. * Disposes of the experience helper
  96903. */
  96904. dispose(): void;
  96905. }
  96906. }
  96907. declare module BABYLON {
  96908. /**
  96909. * Button which can be used to enter a different mode of XR
  96910. */
  96911. export class WebXREnterExitUIButton {
  96912. /** button element */
  96913. element: HTMLElement;
  96914. /** XR initialization options for the button */
  96915. initializationOptions: XRSessionCreationOptions;
  96916. /**
  96917. * Creates a WebXREnterExitUIButton
  96918. * @param element button element
  96919. * @param initializationOptions XR initialization options for the button
  96920. */
  96921. constructor(
  96922. /** button element */
  96923. element: HTMLElement,
  96924. /** XR initialization options for the button */
  96925. initializationOptions: XRSessionCreationOptions);
  96926. /**
  96927. * Overwritable function which can be used to update the button's visuals when the state changes
  96928. * @param activeButton the current active button in the UI
  96929. */
  96930. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96931. }
  96932. /**
  96933. * Options to create the webXR UI
  96934. */
  96935. export class WebXREnterExitUIOptions {
  96936. /**
  96937. * Context to enter xr with
  96938. */
  96939. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96940. /**
  96941. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96942. */
  96943. customButtons?: Array<WebXREnterExitUIButton>;
  96944. }
  96945. /**
  96946. * UI to allow the user to enter/exit XR mode
  96947. */
  96948. export class WebXREnterExitUI implements IDisposable {
  96949. private scene;
  96950. private _overlay;
  96951. private _buttons;
  96952. private _activeButton;
  96953. /**
  96954. * Fired every time the active button is changed.
  96955. *
  96956. * When xr is entered via a button that launches xr that button will be the callback parameter
  96957. *
  96958. * When exiting xr the callback parameter will be null)
  96959. */
  96960. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96961. /**
  96962. * Creates UI to allow the user to enter/exit XR mode
  96963. * @param scene the scene to add the ui to
  96964. * @param helper the xr experience helper to enter/exit xr with
  96965. * @param options options to configure the UI
  96966. * @returns the created ui
  96967. */
  96968. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96969. private constructor();
  96970. private _updateButtons;
  96971. /**
  96972. * Disposes of the object
  96973. */
  96974. dispose(): void;
  96975. }
  96976. }
  96977. declare module BABYLON {
  96978. /**
  96979. * Represents an XR input
  96980. */
  96981. export class WebXRController {
  96982. /**
  96983. * 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
  96984. */
  96985. grip?: AbstractMesh;
  96986. /**
  96987. * Pointer which can be used to select objects or attach a visible laser to
  96988. */
  96989. pointer: AbstractMesh;
  96990. /**
  96991. * Creates the controller
  96992. * @see https://doc.babylonjs.com/how_to/webxr
  96993. * @param scene the scene which the controller should be associated to
  96994. */
  96995. constructor(scene: Scene);
  96996. /**
  96997. * Disposes of the object
  96998. */
  96999. dispose(): void;
  97000. }
  97001. /**
  97002. * XR input used to track XR inputs such as controllers/rays
  97003. */
  97004. export class WebXRInput implements IDisposable {
  97005. private helper;
  97006. /**
  97007. * XR controllers being tracked
  97008. */
  97009. controllers: Array<WebXRController>;
  97010. private _tmpMatrix;
  97011. private _frameObserver;
  97012. /**
  97013. * Initializes the WebXRInput
  97014. * @param helper experience helper which the input should be created for
  97015. */
  97016. constructor(helper: WebXRExperienceHelper);
  97017. /**
  97018. * Disposes of the object
  97019. */
  97020. dispose(): void;
  97021. }
  97022. }
  97023. declare module BABYLON {
  97024. /**
  97025. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97026. */
  97027. export class WebXRManagedOutputCanvas implements IDisposable {
  97028. private _canvas;
  97029. /**
  97030. * xrpresent context of the canvas which can be used to display/mirror xr content
  97031. */
  97032. canvasContext: Nullable<WebGLRenderingContext>;
  97033. /**
  97034. * Initializes the canvas to be added/removed upon entering/exiting xr
  97035. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97036. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97037. */
  97038. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97039. /**
  97040. * Disposes of the object
  97041. */
  97042. dispose(): void;
  97043. private _setManagedOutputCanvas;
  97044. private _addCanvas;
  97045. private _removeCanvas;
  97046. }
  97047. }
  97048. declare module BABYLON {
  97049. /**
  97050. * Contains an array of blocks representing the octree
  97051. */
  97052. export interface IOctreeContainer<T> {
  97053. /**
  97054. * Blocks within the octree
  97055. */
  97056. blocks: Array<OctreeBlock<T>>;
  97057. }
  97058. /**
  97059. * Class used to store a cell in an octree
  97060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97061. */
  97062. export class OctreeBlock<T> {
  97063. /**
  97064. * Gets the content of the current block
  97065. */
  97066. entries: T[];
  97067. /**
  97068. * Gets the list of block children
  97069. */
  97070. blocks: Array<OctreeBlock<T>>;
  97071. private _depth;
  97072. private _maxDepth;
  97073. private _capacity;
  97074. private _minPoint;
  97075. private _maxPoint;
  97076. private _boundingVectors;
  97077. private _creationFunc;
  97078. /**
  97079. * Creates a new block
  97080. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97081. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97082. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97083. * @param depth defines the current depth of this block in the octree
  97084. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97085. * @param creationFunc defines a callback to call when an element is added to the block
  97086. */
  97087. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97088. /**
  97089. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97090. */
  97091. readonly capacity: number;
  97092. /**
  97093. * Gets the minimum vector (in world space) of the block's bounding box
  97094. */
  97095. readonly minPoint: Vector3;
  97096. /**
  97097. * Gets the maximum vector (in world space) of the block's bounding box
  97098. */
  97099. readonly maxPoint: Vector3;
  97100. /**
  97101. * Add a new element to this block
  97102. * @param entry defines the element to add
  97103. */
  97104. addEntry(entry: T): void;
  97105. /**
  97106. * Remove an element from this block
  97107. * @param entry defines the element to remove
  97108. */
  97109. removeEntry(entry: T): void;
  97110. /**
  97111. * Add an array of elements to this block
  97112. * @param entries defines the array of elements to add
  97113. */
  97114. addEntries(entries: T[]): void;
  97115. /**
  97116. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97117. * @param frustumPlanes defines the frustum planes to test
  97118. * @param selection defines the array to store current content if selection is positive
  97119. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97120. */
  97121. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97122. /**
  97123. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97124. * @param sphereCenter defines the bounding sphere center
  97125. * @param sphereRadius defines the bounding sphere radius
  97126. * @param selection defines the array to store current content if selection is positive
  97127. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97128. */
  97129. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97130. /**
  97131. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97132. * @param ray defines the ray to test with
  97133. * @param selection defines the array to store current content if selection is positive
  97134. */
  97135. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97136. /**
  97137. * Subdivide the content into child blocks (this block will then be empty)
  97138. */
  97139. createInnerBlocks(): void;
  97140. /**
  97141. * @hidden
  97142. */
  97143. 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;
  97144. }
  97145. }
  97146. declare module BABYLON {
  97147. /**
  97148. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97149. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97150. */
  97151. export class Octree<T> {
  97152. /** 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.) */
  97153. maxDepth: number;
  97154. /**
  97155. * Blocks within the octree containing objects
  97156. */
  97157. blocks: Array<OctreeBlock<T>>;
  97158. /**
  97159. * Content stored in the octree
  97160. */
  97161. dynamicContent: T[];
  97162. private _maxBlockCapacity;
  97163. private _selectionContent;
  97164. private _creationFunc;
  97165. /**
  97166. * Creates a octree
  97167. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97168. * @param creationFunc function to be used to instatiate the octree
  97169. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97170. * @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.)
  97171. */
  97172. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97173. /** 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.) */
  97174. maxDepth?: number);
  97175. /**
  97176. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97177. * @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);
  97178. * @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);
  97179. * @param entries meshes to be added to the octree blocks
  97180. */
  97181. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97182. /**
  97183. * Adds a mesh to the octree
  97184. * @param entry Mesh to add to the octree
  97185. */
  97186. addMesh(entry: T): void;
  97187. /**
  97188. * Remove an element from the octree
  97189. * @param entry defines the element to remove
  97190. */
  97191. removeMesh(entry: T): void;
  97192. /**
  97193. * Selects an array of meshes within the frustum
  97194. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97195. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97196. * @returns array of meshes within the frustum
  97197. */
  97198. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97199. /**
  97200. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97201. * @param sphereCenter defines the bounding sphere center
  97202. * @param sphereRadius defines the bounding sphere radius
  97203. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97204. * @returns an array of objects that intersect the sphere
  97205. */
  97206. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97207. /**
  97208. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97209. * @param ray defines the ray to test with
  97210. * @returns array of intersected objects
  97211. */
  97212. intersectsRay(ray: Ray): SmartArray<T>;
  97213. /**
  97214. * Adds a mesh into the octree block if it intersects the block
  97215. */
  97216. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97217. /**
  97218. * Adds a submesh into the octree block if it intersects the block
  97219. */
  97220. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97221. }
  97222. }
  97223. declare module BABYLON {
  97224. interface Scene {
  97225. /**
  97226. * @hidden
  97227. * Backing Filed
  97228. */
  97229. _selectionOctree: Octree<AbstractMesh>;
  97230. /**
  97231. * Gets the octree used to boost mesh selection (picking)
  97232. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97233. */
  97234. selectionOctree: Octree<AbstractMesh>;
  97235. /**
  97236. * Creates or updates the octree used to boost selection (picking)
  97237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97238. * @param maxCapacity defines the maximum capacity per leaf
  97239. * @param maxDepth defines the maximum depth of the octree
  97240. * @returns an octree of AbstractMesh
  97241. */
  97242. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97243. }
  97244. interface AbstractMesh {
  97245. /**
  97246. * @hidden
  97247. * Backing Field
  97248. */
  97249. _submeshesOctree: Octree<SubMesh>;
  97250. /**
  97251. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97252. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97253. * @param maxCapacity defines the maximum size of each block (64 by default)
  97254. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97255. * @returns the new octree
  97256. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97258. */
  97259. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97260. }
  97261. /**
  97262. * Defines the octree scene component responsible to manage any octrees
  97263. * in a given scene.
  97264. */
  97265. export class OctreeSceneComponent {
  97266. /**
  97267. * The component name helpfull to identify the component in the list of scene components.
  97268. */
  97269. readonly name: string;
  97270. /**
  97271. * The scene the component belongs to.
  97272. */
  97273. scene: Scene;
  97274. /**
  97275. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97276. */
  97277. readonly checksIsEnabled: boolean;
  97278. /**
  97279. * Creates a new instance of the component for the given scene
  97280. * @param scene Defines the scene to register the component in
  97281. */
  97282. constructor(scene: Scene);
  97283. /**
  97284. * Registers the component in a given scene
  97285. */
  97286. register(): void;
  97287. /**
  97288. * Return the list of active meshes
  97289. * @returns the list of active meshes
  97290. */
  97291. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97292. /**
  97293. * Return the list of active sub meshes
  97294. * @param mesh The mesh to get the candidates sub meshes from
  97295. * @returns the list of active sub meshes
  97296. */
  97297. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97298. private _tempRay;
  97299. /**
  97300. * Return the list of sub meshes intersecting with a given local ray
  97301. * @param mesh defines the mesh to find the submesh for
  97302. * @param localRay defines the ray in local space
  97303. * @returns the list of intersecting sub meshes
  97304. */
  97305. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97306. /**
  97307. * Return the list of sub meshes colliding with a collider
  97308. * @param mesh defines the mesh to find the submesh for
  97309. * @param collider defines the collider to evaluate the collision against
  97310. * @returns the list of colliding sub meshes
  97311. */
  97312. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97313. /**
  97314. * Rebuilds the elements related to this component in case of
  97315. * context lost for instance.
  97316. */
  97317. rebuild(): void;
  97318. /**
  97319. * Disposes the component and the associated ressources.
  97320. */
  97321. dispose(): void;
  97322. }
  97323. }
  97324. declare module BABYLON {
  97325. /**
  97326. * Class containing static functions to help procedurally build meshes
  97327. */
  97328. export class LinesBuilder {
  97329. /**
  97330. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97331. * * 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
  97332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97333. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97334. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97335. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97336. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97337. * * 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
  97338. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97341. * @param name defines the name of the new line system
  97342. * @param options defines the options used to create the line system
  97343. * @param scene defines the hosting scene
  97344. * @returns a new line system mesh
  97345. */
  97346. static CreateLineSystem(name: string, options: {
  97347. lines: Vector3[][];
  97348. updatable?: boolean;
  97349. instance?: Nullable<LinesMesh>;
  97350. colors?: Nullable<Color4[][]>;
  97351. useVertexAlpha?: boolean;
  97352. }, scene: Nullable<Scene>): LinesMesh;
  97353. /**
  97354. * Creates a line mesh
  97355. * 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
  97356. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97357. * * The parameter `points` is an array successive Vector3
  97358. * * 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
  97359. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97360. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97361. * * When updating an instance, remember that only point positions can change, not the number of points
  97362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97364. * @param name defines the name of the new line system
  97365. * @param options defines the options used to create the line system
  97366. * @param scene defines the hosting scene
  97367. * @returns a new line mesh
  97368. */
  97369. static CreateLines(name: string, options: {
  97370. points: Vector3[];
  97371. updatable?: boolean;
  97372. instance?: Nullable<LinesMesh>;
  97373. colors?: Color4[];
  97374. useVertexAlpha?: boolean;
  97375. }, scene?: Nullable<Scene>): LinesMesh;
  97376. /**
  97377. * Creates a dashed line mesh
  97378. * * 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
  97379. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97380. * * The parameter `points` is an array successive Vector3
  97381. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97382. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97383. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97384. * * 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
  97385. * * When updating an instance, remember that only point positions can change, not the number of points
  97386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97387. * @param name defines the name of the mesh
  97388. * @param options defines the options used to create the mesh
  97389. * @param scene defines the hosting scene
  97390. * @returns the dashed line mesh
  97391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97392. */
  97393. static CreateDashedLines(name: string, options: {
  97394. points: Vector3[];
  97395. dashSize?: number;
  97396. gapSize?: number;
  97397. dashNb?: number;
  97398. updatable?: boolean;
  97399. instance?: LinesMesh;
  97400. }, scene?: Nullable<Scene>): LinesMesh;
  97401. }
  97402. }
  97403. declare module BABYLON {
  97404. /**
  97405. * Renders a layer on top of an existing scene
  97406. */
  97407. export class UtilityLayerRenderer implements IDisposable {
  97408. /** the original scene that will be rendered on top of */
  97409. originalScene: Scene;
  97410. private _pointerCaptures;
  97411. private _lastPointerEvents;
  97412. private static _DefaultUtilityLayer;
  97413. private static _DefaultKeepDepthUtilityLayer;
  97414. /**
  97415. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97416. */
  97417. pickUtilitySceneFirst: boolean;
  97418. /**
  97419. * 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)
  97420. */
  97421. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97422. /**
  97423. * 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)
  97424. */
  97425. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97426. /**
  97427. * The scene that is rendered on top of the original scene
  97428. */
  97429. utilityLayerScene: Scene;
  97430. /**
  97431. * If the utility layer should automatically be rendered on top of existing scene
  97432. */
  97433. shouldRender: boolean;
  97434. /**
  97435. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97436. */
  97437. onlyCheckPointerDownEvents: boolean;
  97438. /**
  97439. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97440. */
  97441. processAllEvents: boolean;
  97442. /**
  97443. * Observable raised when the pointer move from the utility layer scene to the main scene
  97444. */
  97445. onPointerOutObservable: Observable<number>;
  97446. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97447. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97448. private _afterRenderObserver;
  97449. private _sceneDisposeObserver;
  97450. private _originalPointerObserver;
  97451. /**
  97452. * Instantiates a UtilityLayerRenderer
  97453. * @param originalScene the original scene that will be rendered on top of
  97454. * @param handleEvents boolean indicating if the utility layer should handle events
  97455. */
  97456. constructor(
  97457. /** the original scene that will be rendered on top of */
  97458. originalScene: Scene, handleEvents?: boolean);
  97459. private _notifyObservers;
  97460. /**
  97461. * Renders the utility layers scene on top of the original scene
  97462. */
  97463. render(): void;
  97464. /**
  97465. * Disposes of the renderer
  97466. */
  97467. dispose(): void;
  97468. private _updateCamera;
  97469. }
  97470. }
  97471. declare module BABYLON {
  97472. /**
  97473. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97474. */
  97475. export class Gizmo implements IDisposable {
  97476. /** The utility layer the gizmo will be added to */
  97477. gizmoLayer: UtilityLayerRenderer;
  97478. /**
  97479. * The root mesh of the gizmo
  97480. */
  97481. _rootMesh: Mesh;
  97482. private _attachedMesh;
  97483. /**
  97484. * Ratio for the scale of the gizmo (Default: 1)
  97485. */
  97486. scaleRatio: number;
  97487. private _tmpMatrix;
  97488. /**
  97489. * If a custom mesh has been set (Default: false)
  97490. */
  97491. protected _customMeshSet: boolean;
  97492. /**
  97493. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97494. * * When set, interactions will be enabled
  97495. */
  97496. attachedMesh: Nullable<AbstractMesh>;
  97497. /**
  97498. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97499. * @param mesh The mesh to replace the default mesh of the gizmo
  97500. */
  97501. setCustomMesh(mesh: Mesh): void;
  97502. /**
  97503. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97504. */
  97505. updateGizmoRotationToMatchAttachedMesh: boolean;
  97506. /**
  97507. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97508. */
  97509. updateGizmoPositionToMatchAttachedMesh: boolean;
  97510. /**
  97511. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97512. */
  97513. protected _updateScale: boolean;
  97514. protected _interactionsEnabled: boolean;
  97515. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97516. private _beforeRenderObserver;
  97517. /**
  97518. * Creates a gizmo
  97519. * @param gizmoLayer The utility layer the gizmo will be added to
  97520. */
  97521. constructor(
  97522. /** The utility layer the gizmo will be added to */
  97523. gizmoLayer?: UtilityLayerRenderer);
  97524. private _tempVector;
  97525. /**
  97526. * @hidden
  97527. * Updates the gizmo to match the attached mesh's position/rotation
  97528. */
  97529. protected _update(): void;
  97530. /**
  97531. * Disposes of the gizmo
  97532. */
  97533. dispose(): void;
  97534. }
  97535. }
  97536. declare module BABYLON {
  97537. /**
  97538. * Single axis drag gizmo
  97539. */
  97540. export class AxisDragGizmo extends Gizmo {
  97541. /**
  97542. * Drag behavior responsible for the gizmos dragging interactions
  97543. */
  97544. dragBehavior: PointerDragBehavior;
  97545. private _pointerObserver;
  97546. /**
  97547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97548. */
  97549. snapDistance: number;
  97550. /**
  97551. * Event that fires each time the gizmo snaps to a new location.
  97552. * * snapDistance is the the change in distance
  97553. */
  97554. onSnapObservable: Observable<{
  97555. snapDistance: number;
  97556. }>;
  97557. /** @hidden */
  97558. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97559. /** @hidden */
  97560. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97561. /**
  97562. * Creates an AxisDragGizmo
  97563. * @param gizmoLayer The utility layer the gizmo will be added to
  97564. * @param dragAxis The axis which the gizmo will be able to drag on
  97565. * @param color The color of the gizmo
  97566. */
  97567. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97568. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97569. /**
  97570. * Disposes of the gizmo
  97571. */
  97572. dispose(): void;
  97573. }
  97574. }
  97575. declare module BABYLON.Debug {
  97576. /**
  97577. * The Axes viewer will show 3 axes in a specific point in space
  97578. */
  97579. export class AxesViewer {
  97580. private _xAxis;
  97581. private _yAxis;
  97582. private _zAxis;
  97583. private _scaleLinesFactor;
  97584. private _instanced;
  97585. /**
  97586. * Gets the hosting scene
  97587. */
  97588. scene: Scene;
  97589. /**
  97590. * Gets or sets a number used to scale line length
  97591. */
  97592. scaleLines: number;
  97593. /** Gets the node hierarchy used to render x-axis */
  97594. readonly xAxis: TransformNode;
  97595. /** Gets the node hierarchy used to render y-axis */
  97596. readonly yAxis: TransformNode;
  97597. /** Gets the node hierarchy used to render z-axis */
  97598. readonly zAxis: TransformNode;
  97599. /**
  97600. * Creates a new AxesViewer
  97601. * @param scene defines the hosting scene
  97602. * @param scaleLines defines a number used to scale line length (1 by default)
  97603. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97604. * @param xAxis defines the node hierarchy used to render the x-axis
  97605. * @param yAxis defines the node hierarchy used to render the y-axis
  97606. * @param zAxis defines the node hierarchy used to render the z-axis
  97607. */
  97608. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97609. /**
  97610. * Force the viewer to update
  97611. * @param position defines the position of the viewer
  97612. * @param xaxis defines the x axis of the viewer
  97613. * @param yaxis defines the y axis of the viewer
  97614. * @param zaxis defines the z axis of the viewer
  97615. */
  97616. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97617. /**
  97618. * Creates an instance of this axes viewer.
  97619. * @returns a new axes viewer with instanced meshes
  97620. */
  97621. createInstance(): AxesViewer;
  97622. /** Releases resources */
  97623. dispose(): void;
  97624. private static _SetRenderingGroupId;
  97625. }
  97626. }
  97627. declare module BABYLON.Debug {
  97628. /**
  97629. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97630. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97631. */
  97632. export class BoneAxesViewer extends AxesViewer {
  97633. /**
  97634. * Gets or sets the target mesh where to display the axes viewer
  97635. */
  97636. mesh: Nullable<Mesh>;
  97637. /**
  97638. * Gets or sets the target bone where to display the axes viewer
  97639. */
  97640. bone: Nullable<Bone>;
  97641. /** Gets current position */
  97642. pos: Vector3;
  97643. /** Gets direction of X axis */
  97644. xaxis: Vector3;
  97645. /** Gets direction of Y axis */
  97646. yaxis: Vector3;
  97647. /** Gets direction of Z axis */
  97648. zaxis: Vector3;
  97649. /**
  97650. * Creates a new BoneAxesViewer
  97651. * @param scene defines the hosting scene
  97652. * @param bone defines the target bone
  97653. * @param mesh defines the target mesh
  97654. * @param scaleLines defines a scaling factor for line length (1 by default)
  97655. */
  97656. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97657. /**
  97658. * Force the viewer to update
  97659. */
  97660. update(): void;
  97661. /** Releases resources */
  97662. dispose(): void;
  97663. }
  97664. }
  97665. declare module BABYLON {
  97666. /**
  97667. * Interface used to define scene explorer extensibility option
  97668. */
  97669. export interface IExplorerExtensibilityOption {
  97670. /**
  97671. * Define the option label
  97672. */
  97673. label: string;
  97674. /**
  97675. * Defines the action to execute on click
  97676. */
  97677. action: (entity: any) => void;
  97678. }
  97679. /**
  97680. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97681. */
  97682. export interface IExplorerExtensibilityGroup {
  97683. /**
  97684. * Defines a predicate to test if a given type mut be extended
  97685. */
  97686. predicate: (entity: any) => boolean;
  97687. /**
  97688. * Gets the list of options added to a type
  97689. */
  97690. entries: IExplorerExtensibilityOption[];
  97691. }
  97692. /**
  97693. * Interface used to define the options to use to create the Inspector
  97694. */
  97695. export interface IInspectorOptions {
  97696. /**
  97697. * Display in overlay mode (default: false)
  97698. */
  97699. overlay?: boolean;
  97700. /**
  97701. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97702. */
  97703. globalRoot?: HTMLElement;
  97704. /**
  97705. * Display the Scene explorer
  97706. */
  97707. showExplorer?: boolean;
  97708. /**
  97709. * Display the property inspector
  97710. */
  97711. showInspector?: boolean;
  97712. /**
  97713. * Display in embed mode (both panes on the right)
  97714. */
  97715. embedMode?: boolean;
  97716. /**
  97717. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97718. */
  97719. handleResize?: boolean;
  97720. /**
  97721. * Allow the panes to popup (default: true)
  97722. */
  97723. enablePopup?: boolean;
  97724. /**
  97725. * Allow the panes to be closed by users (default: true)
  97726. */
  97727. enableClose?: boolean;
  97728. /**
  97729. * Optional list of extensibility entries
  97730. */
  97731. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97732. /**
  97733. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97734. */
  97735. inspectorURL?: string;
  97736. }
  97737. interface Scene {
  97738. /**
  97739. * @hidden
  97740. * Backing field
  97741. */
  97742. _debugLayer: DebugLayer;
  97743. /**
  97744. * Gets the debug layer (aka Inspector) associated with the scene
  97745. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97746. */
  97747. debugLayer: DebugLayer;
  97748. }
  97749. /**
  97750. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97751. * what is happening in your scene
  97752. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97753. */
  97754. export class DebugLayer {
  97755. /**
  97756. * Define the url to get the inspector script from.
  97757. * By default it uses the babylonjs CDN.
  97758. * @ignoreNaming
  97759. */
  97760. static InspectorURL: string;
  97761. private _scene;
  97762. private BJSINSPECTOR;
  97763. /**
  97764. * Observable triggered when a property is changed through the inspector.
  97765. */
  97766. onPropertyChangedObservable: Observable<{
  97767. object: any;
  97768. property: string;
  97769. value: any;
  97770. initialValue: any;
  97771. }>;
  97772. /**
  97773. * Instantiates a new debug layer.
  97774. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97775. * what is happening in your scene
  97776. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97777. * @param scene Defines the scene to inspect
  97778. */
  97779. constructor(scene: Scene);
  97780. /** Creates the inspector window. */
  97781. private _createInspector;
  97782. /**
  97783. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97784. * @param entity defines the entity to select
  97785. * @param lineContainerTitle defines the specific block to highlight
  97786. */
  97787. select(entity: any, lineContainerTitle?: string): void;
  97788. /** Get the inspector from bundle or global */
  97789. private _getGlobalInspector;
  97790. /**
  97791. * Get if the inspector is visible or not.
  97792. * @returns true if visible otherwise, false
  97793. */
  97794. isVisible(): boolean;
  97795. /**
  97796. * Hide the inspector and close its window.
  97797. */
  97798. hide(): void;
  97799. /**
  97800. * Launch the debugLayer.
  97801. * @param config Define the configuration of the inspector
  97802. * @return a promise fulfilled when the debug layer is visible
  97803. */
  97804. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97805. }
  97806. }
  97807. declare module BABYLON {
  97808. /**
  97809. * Class containing static functions to help procedurally build meshes
  97810. */
  97811. export class BoxBuilder {
  97812. /**
  97813. * Creates a box mesh
  97814. * * The parameter `size` sets the size (float) of each box side (default 1)
  97815. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97816. * * 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)
  97817. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97819. * * If you create a double-sided mesh, you can choose what parts of 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
  97820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97821. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97822. * @param name defines the name of the mesh
  97823. * @param options defines the options used to create the mesh
  97824. * @param scene defines the hosting scene
  97825. * @returns the box mesh
  97826. */
  97827. static CreateBox(name: string, options: {
  97828. size?: number;
  97829. width?: number;
  97830. height?: number;
  97831. depth?: number;
  97832. faceUV?: Vector4[];
  97833. faceColors?: Color4[];
  97834. sideOrientation?: number;
  97835. frontUVs?: Vector4;
  97836. backUVs?: Vector4;
  97837. updatable?: boolean;
  97838. }, scene?: Nullable<Scene>): Mesh;
  97839. }
  97840. }
  97841. declare module BABYLON {
  97842. /**
  97843. * Class containing static functions to help procedurally build meshes
  97844. */
  97845. export class SphereBuilder {
  97846. /**
  97847. * Creates a sphere mesh
  97848. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97849. * * 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`)
  97850. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97851. * * 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
  97852. * * 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)
  97853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97854. * * If you create a double-sided mesh, you can choose what parts of 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
  97855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97856. * @param name defines the name of the mesh
  97857. * @param options defines the options used to create the mesh
  97858. * @param scene defines the hosting scene
  97859. * @returns the sphere mesh
  97860. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97861. */
  97862. static CreateSphere(name: string, options: {
  97863. segments?: number;
  97864. diameter?: number;
  97865. diameterX?: number;
  97866. diameterY?: number;
  97867. diameterZ?: number;
  97868. arc?: number;
  97869. slice?: number;
  97870. sideOrientation?: number;
  97871. frontUVs?: Vector4;
  97872. backUVs?: Vector4;
  97873. updatable?: boolean;
  97874. }, scene: any): Mesh;
  97875. }
  97876. }
  97877. declare module BABYLON.Debug {
  97878. /**
  97879. * Used to show the physics impostor around the specific mesh
  97880. */
  97881. export class PhysicsViewer {
  97882. /** @hidden */
  97883. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97884. /** @hidden */
  97885. protected _meshes: Array<Nullable<AbstractMesh>>;
  97886. /** @hidden */
  97887. protected _scene: Nullable<Scene>;
  97888. /** @hidden */
  97889. protected _numMeshes: number;
  97890. /** @hidden */
  97891. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97892. private _renderFunction;
  97893. private _utilityLayer;
  97894. private _debugBoxMesh;
  97895. private _debugSphereMesh;
  97896. private _debugMaterial;
  97897. /**
  97898. * Creates a new PhysicsViewer
  97899. * @param scene defines the hosting scene
  97900. */
  97901. constructor(scene: Scene);
  97902. /** @hidden */
  97903. protected _updateDebugMeshes(): void;
  97904. /**
  97905. * Renders a specified physic impostor
  97906. * @param impostor defines the impostor to render
  97907. * @returns the new debug mesh used to render the impostor
  97908. */
  97909. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97910. /**
  97911. * Hides a specified physic impostor
  97912. * @param impostor defines the impostor to hide
  97913. */
  97914. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97915. private _getDebugMaterial;
  97916. private _getDebugBoxMesh;
  97917. private _getDebugSphereMesh;
  97918. private _getDebugMesh;
  97919. /** Releases all resources */
  97920. dispose(): void;
  97921. }
  97922. }
  97923. declare module BABYLON {
  97924. /**
  97925. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97926. * in order to better appreciate the issue one might have.
  97927. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97928. */
  97929. export class RayHelper {
  97930. /**
  97931. * Defines the ray we are currently tryin to visualize.
  97932. */
  97933. ray: Nullable<Ray>;
  97934. private _renderPoints;
  97935. private _renderLine;
  97936. private _renderFunction;
  97937. private _scene;
  97938. private _updateToMeshFunction;
  97939. private _attachedToMesh;
  97940. private _meshSpaceDirection;
  97941. private _meshSpaceOrigin;
  97942. /**
  97943. * Helper function to create a colored helper in a scene in one line.
  97944. * @param ray Defines the ray we are currently tryin to visualize
  97945. * @param scene Defines the scene the ray is used in
  97946. * @param color Defines the color we want to see the ray in
  97947. * @returns The newly created ray helper.
  97948. */
  97949. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97950. /**
  97951. * Instantiate a new ray helper.
  97952. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97953. * in order to better appreciate the issue one might have.
  97954. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97955. * @param ray Defines the ray we are currently tryin to visualize
  97956. */
  97957. constructor(ray: Ray);
  97958. /**
  97959. * Shows the ray we are willing to debug.
  97960. * @param scene Defines the scene the ray needs to be rendered in
  97961. * @param color Defines the color the ray needs to be rendered in
  97962. */
  97963. show(scene: Scene, color?: Color3): void;
  97964. /**
  97965. * Hides the ray we are debugging.
  97966. */
  97967. hide(): void;
  97968. private _render;
  97969. /**
  97970. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97971. * @param mesh Defines the mesh we want the helper attached to
  97972. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97973. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97974. * @param length Defines the length of the ray
  97975. */
  97976. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97977. /**
  97978. * Detach the ray helper from the mesh it has previously been attached to.
  97979. */
  97980. detachFromMesh(): void;
  97981. private _updateToMesh;
  97982. /**
  97983. * Dispose the helper and release its associated resources.
  97984. */
  97985. dispose(): void;
  97986. }
  97987. }
  97988. declare module BABYLON.Debug {
  97989. /**
  97990. * Class used to render a debug view of a given skeleton
  97991. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97992. */
  97993. export class SkeletonViewer {
  97994. /** defines the skeleton to render */
  97995. skeleton: Skeleton;
  97996. /** defines the mesh attached to the skeleton */
  97997. mesh: AbstractMesh;
  97998. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97999. autoUpdateBonesMatrices: boolean;
  98000. /** defines the rendering group id to use with the viewer */
  98001. renderingGroupId: number;
  98002. /** Gets or sets the color used to render the skeleton */
  98003. color: Color3;
  98004. private _scene;
  98005. private _debugLines;
  98006. private _debugMesh;
  98007. private _isEnabled;
  98008. private _renderFunction;
  98009. private _utilityLayer;
  98010. /**
  98011. * Returns the mesh used to render the bones
  98012. */
  98013. readonly debugMesh: Nullable<LinesMesh>;
  98014. /**
  98015. * Creates a new SkeletonViewer
  98016. * @param skeleton defines the skeleton to render
  98017. * @param mesh defines the mesh attached to the skeleton
  98018. * @param scene defines the hosting scene
  98019. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98020. * @param renderingGroupId defines the rendering group id to use with the viewer
  98021. */
  98022. constructor(
  98023. /** defines the skeleton to render */
  98024. skeleton: Skeleton,
  98025. /** defines the mesh attached to the skeleton */
  98026. mesh: AbstractMesh, scene: Scene,
  98027. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98028. autoUpdateBonesMatrices?: boolean,
  98029. /** defines the rendering group id to use with the viewer */
  98030. renderingGroupId?: number);
  98031. /** Gets or sets a boolean indicating if the viewer is enabled */
  98032. isEnabled: boolean;
  98033. private _getBonePosition;
  98034. private _getLinesForBonesWithLength;
  98035. private _getLinesForBonesNoLength;
  98036. /** Update the viewer to sync with current skeleton state */
  98037. update(): void;
  98038. /** Release associated resources */
  98039. dispose(): void;
  98040. }
  98041. }
  98042. declare module BABYLON {
  98043. /**
  98044. * Options to create the null engine
  98045. */
  98046. export class NullEngineOptions {
  98047. /**
  98048. * Render width (Default: 512)
  98049. */
  98050. renderWidth: number;
  98051. /**
  98052. * Render height (Default: 256)
  98053. */
  98054. renderHeight: number;
  98055. /**
  98056. * Texture size (Default: 512)
  98057. */
  98058. textureSize: number;
  98059. /**
  98060. * If delta time between frames should be constant
  98061. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98062. */
  98063. deterministicLockstep: boolean;
  98064. /**
  98065. * Maximum about of steps between frames (Default: 4)
  98066. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98067. */
  98068. lockstepMaxSteps: number;
  98069. }
  98070. /**
  98071. * The null engine class provides support for headless version of babylon.js.
  98072. * This can be used in server side scenario or for testing purposes
  98073. */
  98074. export class NullEngine extends Engine {
  98075. private _options;
  98076. /**
  98077. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98078. */
  98079. isDeterministicLockStep(): boolean;
  98080. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98081. getLockstepMaxSteps(): number;
  98082. /**
  98083. * Sets hardware scaling, used to save performance if needed
  98084. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98085. */
  98086. getHardwareScalingLevel(): number;
  98087. constructor(options?: NullEngineOptions);
  98088. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98089. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98090. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98091. getRenderWidth(useScreen?: boolean): number;
  98092. getRenderHeight(useScreen?: boolean): number;
  98093. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98094. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98095. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98096. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98097. bindSamplers(effect: Effect): void;
  98098. enableEffect(effect: Effect): void;
  98099. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98100. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98101. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98102. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98103. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98104. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98105. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98106. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98107. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98108. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98109. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98110. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98111. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98112. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98113. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98114. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98115. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98116. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98117. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98118. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98119. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98120. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98121. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98122. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98123. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98124. bindBuffers(vertexBuffers: {
  98125. [key: string]: VertexBuffer;
  98126. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98127. wipeCaches(bruteForce?: boolean): void;
  98128. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98129. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98130. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98131. /** @hidden */
  98132. _createTexture(): WebGLTexture;
  98133. /** @hidden */
  98134. _releaseTexture(texture: InternalTexture): void;
  98135. 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;
  98136. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98137. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98138. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98139. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98140. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98141. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98142. areAllEffectsReady(): boolean;
  98143. /**
  98144. * @hidden
  98145. * Get the current error code of the webGL context
  98146. * @returns the error code
  98147. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98148. */
  98149. getError(): number;
  98150. /** @hidden */
  98151. _getUnpackAlignement(): number;
  98152. /** @hidden */
  98153. _unpackFlipY(value: boolean): void;
  98154. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98155. /**
  98156. * Updates a dynamic vertex buffer.
  98157. * @param vertexBuffer the vertex buffer to update
  98158. * @param data the data used to update the vertex buffer
  98159. * @param byteOffset the byte offset of the data (optional)
  98160. * @param byteLength the byte length of the data (optional)
  98161. */
  98162. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98163. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98164. /** @hidden */
  98165. _bindTexture(channel: number, texture: InternalTexture): void;
  98166. /** @hidden */
  98167. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98168. releaseEffects(): void;
  98169. displayLoadingUI(): void;
  98170. hideLoadingUI(): void;
  98171. /** @hidden */
  98172. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98173. /** @hidden */
  98174. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98175. /** @hidden */
  98176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98177. /** @hidden */
  98178. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98179. }
  98180. }
  98181. declare module BABYLON {
  98182. /** @hidden */
  98183. export class _OcclusionDataStorage {
  98184. /** @hidden */
  98185. occlusionInternalRetryCounter: number;
  98186. /** @hidden */
  98187. isOcclusionQueryInProgress: boolean;
  98188. /** @hidden */
  98189. isOccluded: boolean;
  98190. /** @hidden */
  98191. occlusionRetryCount: number;
  98192. /** @hidden */
  98193. occlusionType: number;
  98194. /** @hidden */
  98195. occlusionQueryAlgorithmType: number;
  98196. }
  98197. interface Engine {
  98198. /**
  98199. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98200. * @return the new query
  98201. */
  98202. createQuery(): WebGLQuery;
  98203. /**
  98204. * Delete and release a webGL query
  98205. * @param query defines the query to delete
  98206. * @return the current engine
  98207. */
  98208. deleteQuery(query: WebGLQuery): Engine;
  98209. /**
  98210. * Check if a given query has resolved and got its value
  98211. * @param query defines the query to check
  98212. * @returns true if the query got its value
  98213. */
  98214. isQueryResultAvailable(query: WebGLQuery): boolean;
  98215. /**
  98216. * Gets the value of a given query
  98217. * @param query defines the query to check
  98218. * @returns the value of the query
  98219. */
  98220. getQueryResult(query: WebGLQuery): number;
  98221. /**
  98222. * Initiates an occlusion query
  98223. * @param algorithmType defines the algorithm to use
  98224. * @param query defines the query to use
  98225. * @returns the current engine
  98226. * @see http://doc.babylonjs.com/features/occlusionquery
  98227. */
  98228. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98229. /**
  98230. * Ends an occlusion query
  98231. * @see http://doc.babylonjs.com/features/occlusionquery
  98232. * @param algorithmType defines the algorithm to use
  98233. * @returns the current engine
  98234. */
  98235. endOcclusionQuery(algorithmType: number): Engine;
  98236. /**
  98237. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98238. * Please note that only one query can be issued at a time
  98239. * @returns a time token used to track the time span
  98240. */
  98241. startTimeQuery(): Nullable<_TimeToken>;
  98242. /**
  98243. * Ends a time query
  98244. * @param token defines the token used to measure the time span
  98245. * @returns the time spent (in ns)
  98246. */
  98247. endTimeQuery(token: _TimeToken): int;
  98248. /** @hidden */
  98249. _currentNonTimestampToken: Nullable<_TimeToken>;
  98250. /** @hidden */
  98251. _createTimeQuery(): WebGLQuery;
  98252. /** @hidden */
  98253. _deleteTimeQuery(query: WebGLQuery): void;
  98254. /** @hidden */
  98255. _getGlAlgorithmType(algorithmType: number): number;
  98256. /** @hidden */
  98257. _getTimeQueryResult(query: WebGLQuery): any;
  98258. /** @hidden */
  98259. _getTimeQueryAvailability(query: WebGLQuery): any;
  98260. }
  98261. interface AbstractMesh {
  98262. /**
  98263. * Backing filed
  98264. * @hidden
  98265. */
  98266. __occlusionDataStorage: _OcclusionDataStorage;
  98267. /**
  98268. * Access property
  98269. * @hidden
  98270. */
  98271. _occlusionDataStorage: _OcclusionDataStorage;
  98272. /**
  98273. * 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.
  98274. * The default value is -1 which means don't break the query and wait till the result
  98275. * @see http://doc.babylonjs.com/features/occlusionquery
  98276. */
  98277. occlusionRetryCount: number;
  98278. /**
  98279. * 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:
  98280. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98281. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98282. * * 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.
  98283. * @see http://doc.babylonjs.com/features/occlusionquery
  98284. */
  98285. occlusionType: number;
  98286. /**
  98287. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98288. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98289. * * 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.
  98290. * @see http://doc.babylonjs.com/features/occlusionquery
  98291. */
  98292. occlusionQueryAlgorithmType: number;
  98293. /**
  98294. * 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
  98295. * @see http://doc.babylonjs.com/features/occlusionquery
  98296. */
  98297. isOccluded: boolean;
  98298. /**
  98299. * Flag to check the progress status of the query
  98300. * @see http://doc.babylonjs.com/features/occlusionquery
  98301. */
  98302. isOcclusionQueryInProgress: boolean;
  98303. }
  98304. }
  98305. declare module BABYLON {
  98306. /** @hidden */
  98307. export var _forceTransformFeedbackToBundle: boolean;
  98308. interface Engine {
  98309. /**
  98310. * Creates a webGL transform feedback object
  98311. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98312. * @returns the webGL transform feedback object
  98313. */
  98314. createTransformFeedback(): WebGLTransformFeedback;
  98315. /**
  98316. * Delete a webGL transform feedback object
  98317. * @param value defines the webGL transform feedback object to delete
  98318. */
  98319. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98320. /**
  98321. * Bind a webGL transform feedback object to the webgl context
  98322. * @param value defines the webGL transform feedback object to bind
  98323. */
  98324. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98325. /**
  98326. * Begins a transform feedback operation
  98327. * @param usePoints defines if points or triangles must be used
  98328. */
  98329. beginTransformFeedback(usePoints: boolean): void;
  98330. /**
  98331. * Ends a transform feedback operation
  98332. */
  98333. endTransformFeedback(): void;
  98334. /**
  98335. * Specify the varyings to use with transform feedback
  98336. * @param program defines the associated webGL program
  98337. * @param value defines the list of strings representing the varying names
  98338. */
  98339. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98340. /**
  98341. * Bind a webGL buffer for a transform feedback operation
  98342. * @param value defines the webGL buffer to bind
  98343. */
  98344. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98345. }
  98346. }
  98347. declare module BABYLON {
  98348. /**
  98349. * Gather the list of clipboard event types as constants.
  98350. */
  98351. export class ClipboardEventTypes {
  98352. /**
  98353. * The clipboard event is fired when a copy command is active (pressed).
  98354. */
  98355. static readonly COPY: number;
  98356. /**
  98357. * The clipboard event is fired when a cut command is active (pressed).
  98358. */
  98359. static readonly CUT: number;
  98360. /**
  98361. * The clipboard event is fired when a paste command is active (pressed).
  98362. */
  98363. static readonly PASTE: number;
  98364. }
  98365. /**
  98366. * This class is used to store clipboard related info for the onClipboardObservable event.
  98367. */
  98368. export class ClipboardInfo {
  98369. /**
  98370. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98371. */
  98372. type: number;
  98373. /**
  98374. * Defines the related dom event
  98375. */
  98376. event: ClipboardEvent;
  98377. /**
  98378. *Creates an instance of ClipboardInfo.
  98379. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98380. * @param event Defines the related dom event
  98381. */
  98382. constructor(
  98383. /**
  98384. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98385. */
  98386. type: number,
  98387. /**
  98388. * Defines the related dom event
  98389. */
  98390. event: ClipboardEvent);
  98391. /**
  98392. * Get the clipboard event's type from the keycode.
  98393. * @param keyCode Defines the keyCode for the current keyboard event.
  98394. * @return {number}
  98395. */
  98396. static GetTypeFromCharacter(keyCode: number): number;
  98397. }
  98398. }
  98399. declare module BABYLON {
  98400. /**
  98401. * Class used to represent data loading progression
  98402. */
  98403. export class SceneLoaderProgressEvent {
  98404. /** defines if data length to load can be evaluated */
  98405. readonly lengthComputable: boolean;
  98406. /** defines the loaded data length */
  98407. readonly loaded: number;
  98408. /** defines the data length to load */
  98409. readonly total: number;
  98410. /**
  98411. * Create a new progress event
  98412. * @param lengthComputable defines if data length to load can be evaluated
  98413. * @param loaded defines the loaded data length
  98414. * @param total defines the data length to load
  98415. */
  98416. constructor(
  98417. /** defines if data length to load can be evaluated */
  98418. lengthComputable: boolean,
  98419. /** defines the loaded data length */
  98420. loaded: number,
  98421. /** defines the data length to load */
  98422. total: number);
  98423. /**
  98424. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98425. * @param event defines the source event
  98426. * @returns a new SceneLoaderProgressEvent
  98427. */
  98428. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98429. }
  98430. /**
  98431. * Interface used by SceneLoader plugins to define supported file extensions
  98432. */
  98433. export interface ISceneLoaderPluginExtensions {
  98434. /**
  98435. * Defines the list of supported extensions
  98436. */
  98437. [extension: string]: {
  98438. isBinary: boolean;
  98439. };
  98440. }
  98441. /**
  98442. * Interface used by SceneLoader plugin factory
  98443. */
  98444. export interface ISceneLoaderPluginFactory {
  98445. /**
  98446. * Defines the name of the factory
  98447. */
  98448. name: string;
  98449. /**
  98450. * Function called to create a new plugin
  98451. * @return the new plugin
  98452. */
  98453. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98454. /**
  98455. * Boolean indicating if the plugin can direct load specific data
  98456. */
  98457. canDirectLoad?: (data: string) => boolean;
  98458. }
  98459. /**
  98460. * Interface used to define a SceneLoader plugin
  98461. */
  98462. export interface ISceneLoaderPlugin {
  98463. /**
  98464. * The friendly name of this plugin.
  98465. */
  98466. name: string;
  98467. /**
  98468. * The file extensions supported by this plugin.
  98469. */
  98470. extensions: string | ISceneLoaderPluginExtensions;
  98471. /**
  98472. * Import meshes into a scene.
  98473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98474. * @param scene The scene to import into
  98475. * @param data The data to import
  98476. * @param rootUrl The root url for scene and resources
  98477. * @param meshes The meshes array to import into
  98478. * @param particleSystems The particle systems array to import into
  98479. * @param skeletons The skeletons array to import into
  98480. * @param onError The callback when import fails
  98481. * @returns True if successful or false otherwise
  98482. */
  98483. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98484. /**
  98485. * Load into a scene.
  98486. * @param scene The scene to load into
  98487. * @param data The data to import
  98488. * @param rootUrl The root url for scene and resources
  98489. * @param onError The callback when import fails
  98490. * @returns true if successful or false otherwise
  98491. */
  98492. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98493. /**
  98494. * The callback that returns true if the data can be directly loaded.
  98495. */
  98496. canDirectLoad?: (data: string) => boolean;
  98497. /**
  98498. * The callback that allows custom handling of the root url based on the response url.
  98499. */
  98500. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98501. /**
  98502. * Load into an asset container.
  98503. * @param scene The scene to load into
  98504. * @param data The data to import
  98505. * @param rootUrl The root url for scene and resources
  98506. * @param onError The callback when import fails
  98507. * @returns The loaded asset container
  98508. */
  98509. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98510. }
  98511. /**
  98512. * Interface used to define an async SceneLoader plugin
  98513. */
  98514. export interface ISceneLoaderPluginAsync {
  98515. /**
  98516. * The friendly name of this plugin.
  98517. */
  98518. name: string;
  98519. /**
  98520. * The file extensions supported by this plugin.
  98521. */
  98522. extensions: string | ISceneLoaderPluginExtensions;
  98523. /**
  98524. * Import meshes into a scene.
  98525. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98526. * @param scene The scene to import into
  98527. * @param data The data to import
  98528. * @param rootUrl The root url for scene and resources
  98529. * @param onProgress The callback when the load progresses
  98530. * @param fileName Defines the name of the file to load
  98531. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98532. */
  98533. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98534. meshes: AbstractMesh[];
  98535. particleSystems: IParticleSystem[];
  98536. skeletons: Skeleton[];
  98537. animationGroups: AnimationGroup[];
  98538. }>;
  98539. /**
  98540. * Load into a scene.
  98541. * @param scene The scene to load into
  98542. * @param data The data to import
  98543. * @param rootUrl The root url for scene and resources
  98544. * @param onProgress The callback when the load progresses
  98545. * @param fileName Defines the name of the file to load
  98546. * @returns Nothing
  98547. */
  98548. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98549. /**
  98550. * The callback that returns true if the data can be directly loaded.
  98551. */
  98552. canDirectLoad?: (data: string) => boolean;
  98553. /**
  98554. * The callback that allows custom handling of the root url based on the response url.
  98555. */
  98556. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98557. /**
  98558. * Load into an asset container.
  98559. * @param scene The scene to load into
  98560. * @param data The data to import
  98561. * @param rootUrl The root url for scene and resources
  98562. * @param onProgress The callback when the load progresses
  98563. * @param fileName Defines the name of the file to load
  98564. * @returns The loaded asset container
  98565. */
  98566. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98567. }
  98568. /**
  98569. * Class used to load scene from various file formats using registered plugins
  98570. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98571. */
  98572. export class SceneLoader {
  98573. /**
  98574. * No logging while loading
  98575. */
  98576. static readonly NO_LOGGING: number;
  98577. /**
  98578. * Minimal logging while loading
  98579. */
  98580. static readonly MINIMAL_LOGGING: number;
  98581. /**
  98582. * Summary logging while loading
  98583. */
  98584. static readonly SUMMARY_LOGGING: number;
  98585. /**
  98586. * Detailled logging while loading
  98587. */
  98588. static readonly DETAILED_LOGGING: number;
  98589. /**
  98590. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98591. */
  98592. static ForceFullSceneLoadingForIncremental: boolean;
  98593. /**
  98594. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98595. */
  98596. static ShowLoadingScreen: boolean;
  98597. /**
  98598. * Defines the current logging level (while loading the scene)
  98599. * @ignorenaming
  98600. */
  98601. static loggingLevel: number;
  98602. /**
  98603. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98604. */
  98605. static CleanBoneMatrixWeights: boolean;
  98606. /**
  98607. * Event raised when a plugin is used to load a scene
  98608. */
  98609. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98610. private static _registeredPlugins;
  98611. private static _getDefaultPlugin;
  98612. private static _getPluginForExtension;
  98613. private static _getPluginForDirectLoad;
  98614. private static _getPluginForFilename;
  98615. private static _getDirectLoad;
  98616. private static _loadData;
  98617. private static _getFileInfo;
  98618. /**
  98619. * Gets a plugin that can load the given extension
  98620. * @param extension defines the extension to load
  98621. * @returns a plugin or null if none works
  98622. */
  98623. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98624. /**
  98625. * Gets a boolean indicating that the given extension can be loaded
  98626. * @param extension defines the extension to load
  98627. * @returns true if the extension is supported
  98628. */
  98629. static IsPluginForExtensionAvailable(extension: string): boolean;
  98630. /**
  98631. * Adds a new plugin to the list of registered plugins
  98632. * @param plugin defines the plugin to add
  98633. */
  98634. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98635. /**
  98636. * Import meshes into a scene
  98637. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98638. * @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)
  98639. * @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)
  98640. * @param scene the instance of BABYLON.Scene to append to
  98641. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98642. * @param onProgress a callback with a progress event for each file being loaded
  98643. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98644. * @param pluginExtension the extension used to determine the plugin
  98645. * @returns The loaded plugin
  98646. */
  98647. 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>;
  98648. /**
  98649. * Import meshes into a scene
  98650. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98651. * @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)
  98652. * @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)
  98653. * @param scene the instance of BABYLON.Scene to append to
  98654. * @param onProgress a callback with a progress event for each file being loaded
  98655. * @param pluginExtension the extension used to determine the plugin
  98656. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98657. */
  98658. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98659. meshes: AbstractMesh[];
  98660. particleSystems: IParticleSystem[];
  98661. skeletons: Skeleton[];
  98662. animationGroups: AnimationGroup[];
  98663. }>;
  98664. /**
  98665. * Load a scene
  98666. * @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)
  98667. * @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)
  98668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98669. * @param onSuccess a callback with the scene when import succeeds
  98670. * @param onProgress a callback with a progress event for each file being loaded
  98671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98672. * @param pluginExtension the extension used to determine the plugin
  98673. * @returns The loaded plugin
  98674. */
  98675. 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>;
  98676. /**
  98677. * Load a scene
  98678. * @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)
  98679. * @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)
  98680. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98681. * @param onProgress a callback with a progress event for each file being loaded
  98682. * @param pluginExtension the extension used to determine the plugin
  98683. * @returns The loaded scene
  98684. */
  98685. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98686. /**
  98687. * Append a scene
  98688. * @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)
  98689. * @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)
  98690. * @param scene is the instance of BABYLON.Scene to append to
  98691. * @param onSuccess a callback with the scene when import succeeds
  98692. * @param onProgress a callback with a progress event for each file being loaded
  98693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98694. * @param pluginExtension the extension used to determine the plugin
  98695. * @returns The loaded plugin
  98696. */
  98697. 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>;
  98698. /**
  98699. * Append a scene
  98700. * @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)
  98701. * @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)
  98702. * @param scene is the instance of BABYLON.Scene to append to
  98703. * @param onProgress a callback with a progress event for each file being loaded
  98704. * @param pluginExtension the extension used to determine the plugin
  98705. * @returns The given scene
  98706. */
  98707. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98708. /**
  98709. * Load a scene into an asset container
  98710. * @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)
  98711. * @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)
  98712. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98713. * @param onSuccess a callback with the scene when import succeeds
  98714. * @param onProgress a callback with a progress event for each file being loaded
  98715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98716. * @param pluginExtension the extension used to determine the plugin
  98717. * @returns The loaded plugin
  98718. */
  98719. 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>;
  98720. /**
  98721. * Load a scene into an asset container
  98722. * @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)
  98723. * @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)
  98724. * @param scene is the instance of Scene to append to
  98725. * @param onProgress a callback with a progress event for each file being loaded
  98726. * @param pluginExtension the extension used to determine the plugin
  98727. * @returns The loaded asset container
  98728. */
  98729. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98730. }
  98731. }
  98732. declare module BABYLON {
  98733. /**
  98734. * Google Daydream controller
  98735. */
  98736. export class DaydreamController extends WebVRController {
  98737. /**
  98738. * Base Url for the controller model.
  98739. */
  98740. static MODEL_BASE_URL: string;
  98741. /**
  98742. * File name for the controller model.
  98743. */
  98744. static MODEL_FILENAME: string;
  98745. /**
  98746. * Gamepad Id prefix used to identify Daydream Controller.
  98747. */
  98748. static readonly GAMEPAD_ID_PREFIX: string;
  98749. /**
  98750. * Creates a new DaydreamController from a gamepad
  98751. * @param vrGamepad the gamepad that the controller should be created from
  98752. */
  98753. constructor(vrGamepad: any);
  98754. /**
  98755. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98756. * @param scene scene in which to add meshes
  98757. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98758. */
  98759. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98760. /**
  98761. * Called once for each button that changed state since the last frame
  98762. * @param buttonIdx Which button index changed
  98763. * @param state New state of the button
  98764. * @param changes Which properties on the state changed since last frame
  98765. */
  98766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98767. }
  98768. }
  98769. declare module BABYLON {
  98770. /**
  98771. * Gear VR Controller
  98772. */
  98773. export class GearVRController extends WebVRController {
  98774. /**
  98775. * Base Url for the controller model.
  98776. */
  98777. static MODEL_BASE_URL: string;
  98778. /**
  98779. * File name for the controller model.
  98780. */
  98781. static MODEL_FILENAME: string;
  98782. /**
  98783. * Gamepad Id prefix used to identify this controller.
  98784. */
  98785. static readonly GAMEPAD_ID_PREFIX: string;
  98786. private readonly _buttonIndexToObservableNameMap;
  98787. /**
  98788. * Creates a new GearVRController from a gamepad
  98789. * @param vrGamepad the gamepad that the controller should be created from
  98790. */
  98791. constructor(vrGamepad: any);
  98792. /**
  98793. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98794. * @param scene scene in which to add meshes
  98795. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98796. */
  98797. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98798. /**
  98799. * Called once for each button that changed state since the last frame
  98800. * @param buttonIdx Which button index changed
  98801. * @param state New state of the button
  98802. * @param changes Which properties on the state changed since last frame
  98803. */
  98804. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98805. }
  98806. }
  98807. declare module BABYLON {
  98808. /**
  98809. * Generic Controller
  98810. */
  98811. export class GenericController extends WebVRController {
  98812. /**
  98813. * Base Url for the controller model.
  98814. */
  98815. static readonly MODEL_BASE_URL: string;
  98816. /**
  98817. * File name for the controller model.
  98818. */
  98819. static readonly MODEL_FILENAME: string;
  98820. /**
  98821. * Creates a new GenericController from a gamepad
  98822. * @param vrGamepad the gamepad that the controller should be created from
  98823. */
  98824. constructor(vrGamepad: any);
  98825. /**
  98826. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98827. * @param scene scene in which to add meshes
  98828. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98829. */
  98830. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98831. /**
  98832. * Called once for each button that changed state since the last frame
  98833. * @param buttonIdx Which button index changed
  98834. * @param state New state of the button
  98835. * @param changes Which properties on the state changed since last frame
  98836. */
  98837. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98838. }
  98839. }
  98840. declare module BABYLON {
  98841. /**
  98842. * Oculus Touch Controller
  98843. */
  98844. export class OculusTouchController extends WebVRController {
  98845. /**
  98846. * Base Url for the controller model.
  98847. */
  98848. static MODEL_BASE_URL: string;
  98849. /**
  98850. * File name for the left controller model.
  98851. */
  98852. static MODEL_LEFT_FILENAME: string;
  98853. /**
  98854. * File name for the right controller model.
  98855. */
  98856. static MODEL_RIGHT_FILENAME: string;
  98857. /**
  98858. * Fired when the secondary trigger on this controller is modified
  98859. */
  98860. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98861. /**
  98862. * Fired when the thumb rest on this controller is modified
  98863. */
  98864. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98865. /**
  98866. * Creates a new OculusTouchController from a gamepad
  98867. * @param vrGamepad the gamepad that the controller should be created from
  98868. */
  98869. constructor(vrGamepad: any);
  98870. /**
  98871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98872. * @param scene scene in which to add meshes
  98873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98874. */
  98875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98876. /**
  98877. * Fired when the A button on this controller is modified
  98878. */
  98879. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98880. /**
  98881. * Fired when the B button on this controller is modified
  98882. */
  98883. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98884. /**
  98885. * Fired when the X button on this controller is modified
  98886. */
  98887. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98888. /**
  98889. * Fired when the Y button on this controller is modified
  98890. */
  98891. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98892. /**
  98893. * Called once for each button that changed state since the last frame
  98894. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98895. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98896. * 2) secondary trigger (same)
  98897. * 3) A (right) X (left), touch, pressed = value
  98898. * 4) B / Y
  98899. * 5) thumb rest
  98900. * @param buttonIdx Which button index changed
  98901. * @param state New state of the button
  98902. * @param changes Which properties on the state changed since last frame
  98903. */
  98904. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98905. }
  98906. }
  98907. declare module BABYLON {
  98908. /**
  98909. * Vive Controller
  98910. */
  98911. export class ViveController extends WebVRController {
  98912. /**
  98913. * Base Url for the controller model.
  98914. */
  98915. static MODEL_BASE_URL: string;
  98916. /**
  98917. * File name for the controller model.
  98918. */
  98919. static MODEL_FILENAME: string;
  98920. /**
  98921. * Creates a new ViveController from a gamepad
  98922. * @param vrGamepad the gamepad that the controller should be created from
  98923. */
  98924. constructor(vrGamepad: any);
  98925. /**
  98926. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98927. * @param scene scene in which to add meshes
  98928. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98929. */
  98930. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98931. /**
  98932. * Fired when the left button on this controller is modified
  98933. */
  98934. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98935. /**
  98936. * Fired when the right button on this controller is modified
  98937. */
  98938. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98939. /**
  98940. * Fired when the menu button on this controller is modified
  98941. */
  98942. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98943. /**
  98944. * Called once for each button that changed state since the last frame
  98945. * Vive mapping:
  98946. * 0: touchpad
  98947. * 1: trigger
  98948. * 2: left AND right buttons
  98949. * 3: menu button
  98950. * @param buttonIdx Which button index changed
  98951. * @param state New state of the button
  98952. * @param changes Which properties on the state changed since last frame
  98953. */
  98954. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98955. }
  98956. }
  98957. declare module BABYLON {
  98958. /**
  98959. * Defines the WindowsMotionController object that the state of the windows motion controller
  98960. */
  98961. export class WindowsMotionController extends WebVRController {
  98962. /**
  98963. * The base url used to load the left and right controller models
  98964. */
  98965. static MODEL_BASE_URL: string;
  98966. /**
  98967. * The name of the left controller model file
  98968. */
  98969. static MODEL_LEFT_FILENAME: string;
  98970. /**
  98971. * The name of the right controller model file
  98972. */
  98973. static MODEL_RIGHT_FILENAME: string;
  98974. /**
  98975. * The controller name prefix for this controller type
  98976. */
  98977. static readonly GAMEPAD_ID_PREFIX: string;
  98978. /**
  98979. * The controller id pattern for this controller type
  98980. */
  98981. private static readonly GAMEPAD_ID_PATTERN;
  98982. private _loadedMeshInfo;
  98983. private readonly _mapping;
  98984. /**
  98985. * Fired when the trackpad on this controller is clicked
  98986. */
  98987. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98988. /**
  98989. * Fired when the trackpad on this controller is modified
  98990. */
  98991. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98992. /**
  98993. * The current x and y values of this controller's trackpad
  98994. */
  98995. trackpad: StickValues;
  98996. /**
  98997. * Creates a new WindowsMotionController from a gamepad
  98998. * @param vrGamepad the gamepad that the controller should be created from
  98999. */
  99000. constructor(vrGamepad: any);
  99001. /**
  99002. * Fired when the trigger on this controller is modified
  99003. */
  99004. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99005. /**
  99006. * Fired when the menu button on this controller is modified
  99007. */
  99008. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99009. /**
  99010. * Fired when the grip button on this controller is modified
  99011. */
  99012. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99013. /**
  99014. * Fired when the thumbstick button on this controller is modified
  99015. */
  99016. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99017. /**
  99018. * Fired when the touchpad button on this controller is modified
  99019. */
  99020. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99021. /**
  99022. * Fired when the touchpad values on this controller are modified
  99023. */
  99024. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99025. private _updateTrackpad;
  99026. /**
  99027. * Called once per frame by the engine.
  99028. */
  99029. update(): void;
  99030. /**
  99031. * Called once for each button that changed state since the last frame
  99032. * @param buttonIdx Which button index changed
  99033. * @param state New state of the button
  99034. * @param changes Which properties on the state changed since last frame
  99035. */
  99036. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99037. /**
  99038. * Moves the buttons on the controller mesh based on their current state
  99039. * @param buttonName the name of the button to move
  99040. * @param buttonValue the value of the button which determines the buttons new position
  99041. */
  99042. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99043. /**
  99044. * Moves the axis on the controller mesh based on its current state
  99045. * @param axis the index of the axis
  99046. * @param axisValue the value of the axis which determines the meshes new position
  99047. * @hidden
  99048. */
  99049. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99050. /**
  99051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99052. * @param scene scene in which to add meshes
  99053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99054. */
  99055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99056. /**
  99057. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99058. * can be transformed by button presses and axes values, based on this._mapping.
  99059. *
  99060. * @param scene scene in which the meshes exist
  99061. * @param meshes list of meshes that make up the controller model to process
  99062. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99063. */
  99064. private processModel;
  99065. private createMeshInfo;
  99066. /**
  99067. * Gets the ray of the controller in the direction the controller is pointing
  99068. * @param length the length the resulting ray should be
  99069. * @returns a ray in the direction the controller is pointing
  99070. */
  99071. getForwardRay(length?: number): Ray;
  99072. /**
  99073. * Disposes of the controller
  99074. */
  99075. dispose(): void;
  99076. }
  99077. }
  99078. declare module BABYLON {
  99079. /**
  99080. * Single axis scale gizmo
  99081. */
  99082. export class AxisScaleGizmo extends Gizmo {
  99083. private _coloredMaterial;
  99084. /**
  99085. * Drag behavior responsible for the gizmos dragging interactions
  99086. */
  99087. dragBehavior: PointerDragBehavior;
  99088. private _pointerObserver;
  99089. /**
  99090. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99091. */
  99092. snapDistance: number;
  99093. /**
  99094. * Event that fires each time the gizmo snaps to a new location.
  99095. * * snapDistance is the the change in distance
  99096. */
  99097. onSnapObservable: Observable<{
  99098. snapDistance: number;
  99099. }>;
  99100. /**
  99101. * If the scaling operation should be done on all axis (default: false)
  99102. */
  99103. uniformScaling: boolean;
  99104. /**
  99105. * Creates an AxisScaleGizmo
  99106. * @param gizmoLayer The utility layer the gizmo will be added to
  99107. * @param dragAxis The axis which the gizmo will be able to scale on
  99108. * @param color The color of the gizmo
  99109. */
  99110. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99111. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99112. /**
  99113. * Disposes of the gizmo
  99114. */
  99115. dispose(): void;
  99116. /**
  99117. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99118. * @param mesh The mesh to replace the default mesh of the gizmo
  99119. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99120. */
  99121. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99122. }
  99123. }
  99124. declare module BABYLON {
  99125. /**
  99126. * Bounding box gizmo
  99127. */
  99128. export class BoundingBoxGizmo extends Gizmo {
  99129. private _lineBoundingBox;
  99130. private _rotateSpheresParent;
  99131. private _scaleBoxesParent;
  99132. private _boundingDimensions;
  99133. private _renderObserver;
  99134. private _pointerObserver;
  99135. private _scaleDragSpeed;
  99136. private _tmpQuaternion;
  99137. private _tmpVector;
  99138. private _tmpRotationMatrix;
  99139. /**
  99140. * 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)
  99141. */
  99142. ignoreChildren: boolean;
  99143. /**
  99144. * 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)
  99145. */
  99146. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99147. /**
  99148. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99149. */
  99150. rotationSphereSize: number;
  99151. /**
  99152. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99153. */
  99154. scaleBoxSize: number;
  99155. /**
  99156. * 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)
  99157. */
  99158. fixedDragMeshScreenSize: boolean;
  99159. /**
  99160. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99161. */
  99162. fixedDragMeshScreenSizeDistanceFactor: number;
  99163. /**
  99164. * Fired when a rotation sphere or scale box is dragged
  99165. */
  99166. onDragStartObservable: Observable<{}>;
  99167. /**
  99168. * Fired when a scale box is dragged
  99169. */
  99170. onScaleBoxDragObservable: Observable<{}>;
  99171. /**
  99172. * Fired when a scale box drag is ended
  99173. */
  99174. onScaleBoxDragEndObservable: Observable<{}>;
  99175. /**
  99176. * Fired when a rotation sphere is dragged
  99177. */
  99178. onRotationSphereDragObservable: Observable<{}>;
  99179. /**
  99180. * Fired when a rotation sphere drag is ended
  99181. */
  99182. onRotationSphereDragEndObservable: Observable<{}>;
  99183. /**
  99184. * 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)
  99185. */
  99186. scalePivot: Nullable<Vector3>;
  99187. private _anchorMesh;
  99188. private _existingMeshScale;
  99189. private _dragMesh;
  99190. private pointerDragBehavior;
  99191. private coloredMaterial;
  99192. private hoverColoredMaterial;
  99193. /**
  99194. * Sets the color of the bounding box gizmo
  99195. * @param color the color to set
  99196. */
  99197. setColor(color: Color3): void;
  99198. /**
  99199. * Creates an BoundingBoxGizmo
  99200. * @param gizmoLayer The utility layer the gizmo will be added to
  99201. * @param color The color of the gizmo
  99202. */
  99203. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99204. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99205. private _selectNode;
  99206. /**
  99207. * Updates the bounding box information for the Gizmo
  99208. */
  99209. updateBoundingBox(): void;
  99210. private _updateRotationSpheres;
  99211. private _updateScaleBoxes;
  99212. /**
  99213. * Enables rotation on the specified axis and disables rotation on the others
  99214. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99215. */
  99216. setEnabledRotationAxis(axis: string): void;
  99217. /**
  99218. * Enables/disables scaling
  99219. * @param enable if scaling should be enabled
  99220. */
  99221. setEnabledScaling(enable: boolean): void;
  99222. private _updateDummy;
  99223. /**
  99224. * Enables a pointer drag behavior on the bounding box of the gizmo
  99225. */
  99226. enableDragBehavior(): void;
  99227. /**
  99228. * Disposes of the gizmo
  99229. */
  99230. dispose(): void;
  99231. /**
  99232. * 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)
  99233. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99234. * @returns the bounding box mesh with the passed in mesh as a child
  99235. */
  99236. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99237. /**
  99238. * CustomMeshes are not supported by this gizmo
  99239. * @param mesh The mesh to replace the default mesh of the gizmo
  99240. */
  99241. setCustomMesh(mesh: Mesh): void;
  99242. }
  99243. }
  99244. declare module BABYLON {
  99245. /**
  99246. * Single plane rotation gizmo
  99247. */
  99248. export class PlaneRotationGizmo extends Gizmo {
  99249. /**
  99250. * Drag behavior responsible for the gizmos dragging interactions
  99251. */
  99252. dragBehavior: PointerDragBehavior;
  99253. private _pointerObserver;
  99254. /**
  99255. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99256. */
  99257. snapDistance: number;
  99258. /**
  99259. * Event that fires each time the gizmo snaps to a new location.
  99260. * * snapDistance is the the change in distance
  99261. */
  99262. onSnapObservable: Observable<{
  99263. snapDistance: number;
  99264. }>;
  99265. /**
  99266. * Creates a PlaneRotationGizmo
  99267. * @param gizmoLayer The utility layer the gizmo will be added to
  99268. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99269. * @param color The color of the gizmo
  99270. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99271. */
  99272. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99273. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99274. /**
  99275. * Disposes of the gizmo
  99276. */
  99277. dispose(): void;
  99278. }
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * Gizmo that enables rotating a mesh along 3 axis
  99283. */
  99284. export class RotationGizmo extends Gizmo {
  99285. /**
  99286. * Internal gizmo used for interactions on the x axis
  99287. */
  99288. xGizmo: PlaneRotationGizmo;
  99289. /**
  99290. * Internal gizmo used for interactions on the y axis
  99291. */
  99292. yGizmo: PlaneRotationGizmo;
  99293. /**
  99294. * Internal gizmo used for interactions on the z axis
  99295. */
  99296. zGizmo: PlaneRotationGizmo;
  99297. /** Fires an event when any of it's sub gizmos are dragged */
  99298. onDragStartObservable: Observable<{}>;
  99299. /** Fires an event when any of it's sub gizmos are released from dragging */
  99300. onDragEndObservable: Observable<{}>;
  99301. attachedMesh: Nullable<AbstractMesh>;
  99302. /**
  99303. * Creates a RotationGizmo
  99304. * @param gizmoLayer The utility layer the gizmo will be added to
  99305. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99306. */
  99307. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99308. updateGizmoRotationToMatchAttachedMesh: boolean;
  99309. /**
  99310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99311. */
  99312. snapDistance: number;
  99313. /**
  99314. * Ratio for the scale of the gizmo (Default: 1)
  99315. */
  99316. scaleRatio: number;
  99317. /**
  99318. * Disposes of the gizmo
  99319. */
  99320. dispose(): void;
  99321. /**
  99322. * CustomMeshes are not supported by this gizmo
  99323. * @param mesh The mesh to replace the default mesh of the gizmo
  99324. */
  99325. setCustomMesh(mesh: Mesh): void;
  99326. }
  99327. }
  99328. declare module BABYLON {
  99329. /**
  99330. * Gizmo that enables dragging a mesh along 3 axis
  99331. */
  99332. export class PositionGizmo extends Gizmo {
  99333. /**
  99334. * Internal gizmo used for interactions on the x axis
  99335. */
  99336. xGizmo: AxisDragGizmo;
  99337. /**
  99338. * Internal gizmo used for interactions on the y axis
  99339. */
  99340. yGizmo: AxisDragGizmo;
  99341. /**
  99342. * Internal gizmo used for interactions on the z axis
  99343. */
  99344. zGizmo: AxisDragGizmo;
  99345. /** Fires an event when any of it's sub gizmos are dragged */
  99346. onDragStartObservable: Observable<{}>;
  99347. /** Fires an event when any of it's sub gizmos are released from dragging */
  99348. onDragEndObservable: Observable<{}>;
  99349. attachedMesh: Nullable<AbstractMesh>;
  99350. /**
  99351. * Creates a PositionGizmo
  99352. * @param gizmoLayer The utility layer the gizmo will be added to
  99353. */
  99354. constructor(gizmoLayer?: UtilityLayerRenderer);
  99355. updateGizmoRotationToMatchAttachedMesh: boolean;
  99356. /**
  99357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99358. */
  99359. snapDistance: number;
  99360. /**
  99361. * Ratio for the scale of the gizmo (Default: 1)
  99362. */
  99363. scaleRatio: number;
  99364. /**
  99365. * Disposes of the gizmo
  99366. */
  99367. dispose(): void;
  99368. /**
  99369. * CustomMeshes are not supported by this gizmo
  99370. * @param mesh The mesh to replace the default mesh of the gizmo
  99371. */
  99372. setCustomMesh(mesh: Mesh): void;
  99373. }
  99374. }
  99375. declare module BABYLON {
  99376. /**
  99377. * Class containing static functions to help procedurally build meshes
  99378. */
  99379. export class PolyhedronBuilder {
  99380. /**
  99381. * Creates a polyhedron mesh
  99382. * * 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
  99383. * * The parameter `size` (positive float, default 1) sets the polygon size
  99384. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99385. * * 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`
  99386. * * 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
  99387. * * 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)`)
  99388. * * 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
  99389. * * 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
  99390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99391. * * If you create a double-sided mesh, you can choose what parts of 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
  99392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99393. * @param name defines the name of the mesh
  99394. * @param options defines the options used to create the mesh
  99395. * @param scene defines the hosting scene
  99396. * @returns the polyhedron mesh
  99397. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99398. */
  99399. static CreatePolyhedron(name: string, options: {
  99400. type?: number;
  99401. size?: number;
  99402. sizeX?: number;
  99403. sizeY?: number;
  99404. sizeZ?: number;
  99405. custom?: any;
  99406. faceUV?: Vector4[];
  99407. faceColors?: Color4[];
  99408. flat?: boolean;
  99409. updatable?: boolean;
  99410. sideOrientation?: number;
  99411. frontUVs?: Vector4;
  99412. backUVs?: Vector4;
  99413. }, scene: Scene): Mesh;
  99414. }
  99415. }
  99416. declare module BABYLON {
  99417. /**
  99418. * Gizmo that enables scaling a mesh along 3 axis
  99419. */
  99420. export class ScaleGizmo extends Gizmo {
  99421. /**
  99422. * Internal gizmo used for interactions on the x axis
  99423. */
  99424. xGizmo: AxisScaleGizmo;
  99425. /**
  99426. * Internal gizmo used for interactions on the y axis
  99427. */
  99428. yGizmo: AxisScaleGizmo;
  99429. /**
  99430. * Internal gizmo used for interactions on the z axis
  99431. */
  99432. zGizmo: AxisScaleGizmo;
  99433. /**
  99434. * Internal gizmo used to scale all axis equally
  99435. */
  99436. uniformScaleGizmo: AxisScaleGizmo;
  99437. /** Fires an event when any of it's sub gizmos are dragged */
  99438. onDragStartObservable: Observable<{}>;
  99439. /** Fires an event when any of it's sub gizmos are released from dragging */
  99440. onDragEndObservable: Observable<{}>;
  99441. attachedMesh: Nullable<AbstractMesh>;
  99442. /**
  99443. * Creates a ScaleGizmo
  99444. * @param gizmoLayer The utility layer the gizmo will be added to
  99445. */
  99446. constructor(gizmoLayer?: UtilityLayerRenderer);
  99447. updateGizmoRotationToMatchAttachedMesh: boolean;
  99448. /**
  99449. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99450. */
  99451. snapDistance: number;
  99452. /**
  99453. * Ratio for the scale of the gizmo (Default: 1)
  99454. */
  99455. scaleRatio: number;
  99456. /**
  99457. * Disposes of the gizmo
  99458. */
  99459. dispose(): void;
  99460. }
  99461. }
  99462. declare module BABYLON {
  99463. /**
  99464. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99465. */
  99466. export class GizmoManager implements IDisposable {
  99467. private scene;
  99468. /**
  99469. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99470. */
  99471. gizmos: {
  99472. positionGizmo: Nullable<PositionGizmo>;
  99473. rotationGizmo: Nullable<RotationGizmo>;
  99474. scaleGizmo: Nullable<ScaleGizmo>;
  99475. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99476. };
  99477. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99478. clearGizmoOnEmptyPointerEvent: boolean;
  99479. /** Fires an event when the manager is attached to a mesh */
  99480. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99481. private _gizmosEnabled;
  99482. private _pointerObserver;
  99483. private _attachedMesh;
  99484. private _boundingBoxColor;
  99485. private _defaultUtilityLayer;
  99486. private _defaultKeepDepthUtilityLayer;
  99487. /**
  99488. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99489. */
  99490. boundingBoxDragBehavior: SixDofDragBehavior;
  99491. /**
  99492. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99493. */
  99494. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99495. /**
  99496. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99497. */
  99498. usePointerToAttachGizmos: boolean;
  99499. /**
  99500. * Instatiates a gizmo manager
  99501. * @param scene the scene to overlay the gizmos on top of
  99502. */
  99503. constructor(scene: Scene);
  99504. /**
  99505. * Attaches a set of gizmos to the specified mesh
  99506. * @param mesh The mesh the gizmo's should be attached to
  99507. */
  99508. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99509. /**
  99510. * If the position gizmo is enabled
  99511. */
  99512. positionGizmoEnabled: boolean;
  99513. /**
  99514. * If the rotation gizmo is enabled
  99515. */
  99516. rotationGizmoEnabled: boolean;
  99517. /**
  99518. * If the scale gizmo is enabled
  99519. */
  99520. scaleGizmoEnabled: boolean;
  99521. /**
  99522. * If the boundingBox gizmo is enabled
  99523. */
  99524. boundingBoxGizmoEnabled: boolean;
  99525. /**
  99526. * Disposes of the gizmo manager
  99527. */
  99528. dispose(): void;
  99529. }
  99530. }
  99531. declare module BABYLON {
  99532. /**
  99533. * Gizmo that enables viewing a light
  99534. */
  99535. export class LightGizmo extends Gizmo {
  99536. private _box;
  99537. /**
  99538. * Creates a LightGizmo
  99539. * @param gizmoLayer The utility layer the gizmo will be added to
  99540. */
  99541. constructor(gizmoLayer?: UtilityLayerRenderer);
  99542. private _light;
  99543. /**
  99544. * The light that the gizmo is attached to
  99545. */
  99546. light: Nullable<Light>;
  99547. /**
  99548. * @hidden
  99549. * Updates the gizmo to match the attached mesh's position/rotation
  99550. */
  99551. protected _update(): void;
  99552. }
  99553. }
  99554. declare module BABYLON {
  99555. /** @hidden */
  99556. export var backgroundFragmentDeclaration: {
  99557. name: string;
  99558. shader: string;
  99559. };
  99560. }
  99561. declare module BABYLON {
  99562. /** @hidden */
  99563. export var backgroundUboDeclaration: {
  99564. name: string;
  99565. shader: string;
  99566. };
  99567. }
  99568. declare module BABYLON {
  99569. /** @hidden */
  99570. export var backgroundPixelShader: {
  99571. name: string;
  99572. shader: string;
  99573. };
  99574. }
  99575. declare module BABYLON {
  99576. /** @hidden */
  99577. export var backgroundVertexDeclaration: {
  99578. name: string;
  99579. shader: string;
  99580. };
  99581. }
  99582. declare module BABYLON {
  99583. /** @hidden */
  99584. export var backgroundVertexShader: {
  99585. name: string;
  99586. shader: string;
  99587. };
  99588. }
  99589. declare module BABYLON {
  99590. /**
  99591. * Background material used to create an efficient environement around your scene.
  99592. */
  99593. export class BackgroundMaterial extends PushMaterial {
  99594. /**
  99595. * Standard reflectance value at parallel view angle.
  99596. */
  99597. static StandardReflectance0: number;
  99598. /**
  99599. * Standard reflectance value at grazing angle.
  99600. */
  99601. static StandardReflectance90: number;
  99602. protected _primaryColor: Color3;
  99603. /**
  99604. * Key light Color (multiply against the environement texture)
  99605. */
  99606. primaryColor: Color3;
  99607. protected __perceptualColor: Nullable<Color3>;
  99608. /**
  99609. * Experimental Internal Use Only.
  99610. *
  99611. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99612. * This acts as a helper to set the primary color to a more "human friendly" value.
  99613. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99614. * output color as close as possible from the chosen value.
  99615. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99616. * part of lighting setup.)
  99617. */
  99618. _perceptualColor: Nullable<Color3>;
  99619. protected _primaryColorShadowLevel: float;
  99620. /**
  99621. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99622. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99623. */
  99624. primaryColorShadowLevel: float;
  99625. protected _primaryColorHighlightLevel: float;
  99626. /**
  99627. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99628. * The primary color is used at the level chosen to define what the white area would look.
  99629. */
  99630. primaryColorHighlightLevel: float;
  99631. protected _reflectionTexture: Nullable<BaseTexture>;
  99632. /**
  99633. * Reflection Texture used in the material.
  99634. * Should be author in a specific way for the best result (refer to the documentation).
  99635. */
  99636. reflectionTexture: Nullable<BaseTexture>;
  99637. protected _reflectionBlur: float;
  99638. /**
  99639. * Reflection Texture level of blur.
  99640. *
  99641. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99642. * texture twice.
  99643. */
  99644. reflectionBlur: float;
  99645. protected _diffuseTexture: Nullable<BaseTexture>;
  99646. /**
  99647. * Diffuse Texture used in the material.
  99648. * Should be author in a specific way for the best result (refer to the documentation).
  99649. */
  99650. diffuseTexture: Nullable<BaseTexture>;
  99651. protected _shadowLights: Nullable<IShadowLight[]>;
  99652. /**
  99653. * Specify the list of lights casting shadow on the material.
  99654. * All scene shadow lights will be included if null.
  99655. */
  99656. shadowLights: Nullable<IShadowLight[]>;
  99657. protected _shadowLevel: float;
  99658. /**
  99659. * Helps adjusting the shadow to a softer level if required.
  99660. * 0 means black shadows and 1 means no shadows.
  99661. */
  99662. shadowLevel: float;
  99663. protected _sceneCenter: Vector3;
  99664. /**
  99665. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99666. * It is usually zero but might be interesting to modify according to your setup.
  99667. */
  99668. sceneCenter: Vector3;
  99669. protected _opacityFresnel: boolean;
  99670. /**
  99671. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99672. * This helps ensuring a nice transition when the camera goes under the ground.
  99673. */
  99674. opacityFresnel: boolean;
  99675. protected _reflectionFresnel: boolean;
  99676. /**
  99677. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99678. * This helps adding a mirror texture on the ground.
  99679. */
  99680. reflectionFresnel: boolean;
  99681. protected _reflectionFalloffDistance: number;
  99682. /**
  99683. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99684. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99685. */
  99686. reflectionFalloffDistance: number;
  99687. protected _reflectionAmount: number;
  99688. /**
  99689. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99690. */
  99691. reflectionAmount: number;
  99692. protected _reflectionReflectance0: number;
  99693. /**
  99694. * This specifies the weight of the reflection at grazing angle.
  99695. */
  99696. reflectionReflectance0: number;
  99697. protected _reflectionReflectance90: number;
  99698. /**
  99699. * This specifies the weight of the reflection at a perpendicular point of view.
  99700. */
  99701. reflectionReflectance90: number;
  99702. /**
  99703. * Sets the reflection reflectance fresnel values according to the default standard
  99704. * empirically know to work well :-)
  99705. */
  99706. reflectionStandardFresnelWeight: number;
  99707. protected _useRGBColor: boolean;
  99708. /**
  99709. * Helps to directly use the maps channels instead of their level.
  99710. */
  99711. useRGBColor: boolean;
  99712. protected _enableNoise: boolean;
  99713. /**
  99714. * This helps reducing the banding effect that could occur on the background.
  99715. */
  99716. enableNoise: boolean;
  99717. /**
  99718. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99719. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99720. * Recommended to be keep at 1.0 except for special cases.
  99721. */
  99722. fovMultiplier: number;
  99723. private _fovMultiplier;
  99724. /**
  99725. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99726. */
  99727. useEquirectangularFOV: boolean;
  99728. private _maxSimultaneousLights;
  99729. /**
  99730. * Number of Simultaneous lights allowed on the material.
  99731. */
  99732. maxSimultaneousLights: int;
  99733. /**
  99734. * Default configuration related to image processing available in the Background Material.
  99735. */
  99736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99737. /**
  99738. * Keep track of the image processing observer to allow dispose and replace.
  99739. */
  99740. private _imageProcessingObserver;
  99741. /**
  99742. * Attaches a new image processing configuration to the PBR Material.
  99743. * @param configuration (if null the scene configuration will be use)
  99744. */
  99745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99746. /**
  99747. * Gets the image processing configuration used either in this material.
  99748. */
  99749. /**
  99750. * Sets the Default image processing configuration used either in the this material.
  99751. *
  99752. * If sets to null, the scene one is in use.
  99753. */
  99754. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99755. /**
  99756. * Gets wether the color curves effect is enabled.
  99757. */
  99758. /**
  99759. * Sets wether the color curves effect is enabled.
  99760. */
  99761. cameraColorCurvesEnabled: boolean;
  99762. /**
  99763. * Gets wether the color grading effect is enabled.
  99764. */
  99765. /**
  99766. * Gets wether the color grading effect is enabled.
  99767. */
  99768. cameraColorGradingEnabled: boolean;
  99769. /**
  99770. * Gets wether tonemapping is enabled or not.
  99771. */
  99772. /**
  99773. * Sets wether tonemapping is enabled or not
  99774. */
  99775. cameraToneMappingEnabled: boolean;
  99776. /**
  99777. * The camera exposure used on this material.
  99778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99779. * This corresponds to a photographic exposure.
  99780. */
  99781. /**
  99782. * The camera exposure used on this material.
  99783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99784. * This corresponds to a photographic exposure.
  99785. */
  99786. cameraExposure: float;
  99787. /**
  99788. * Gets The camera contrast used on this material.
  99789. */
  99790. /**
  99791. * Sets The camera contrast used on this material.
  99792. */
  99793. cameraContrast: float;
  99794. /**
  99795. * Gets the Color Grading 2D Lookup Texture.
  99796. */
  99797. /**
  99798. * Sets the Color Grading 2D Lookup Texture.
  99799. */
  99800. cameraColorGradingTexture: Nullable<BaseTexture>;
  99801. /**
  99802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99804. * 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;
  99805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99806. */
  99807. /**
  99808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99810. * 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;
  99811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99812. */
  99813. cameraColorCurves: Nullable<ColorCurves>;
  99814. /**
  99815. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99816. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99817. */
  99818. switchToBGR: boolean;
  99819. private _renderTargets;
  99820. private _reflectionControls;
  99821. private _white;
  99822. private _primaryShadowColor;
  99823. private _primaryHighlightColor;
  99824. /**
  99825. * Instantiates a Background Material in the given scene
  99826. * @param name The friendly name of the material
  99827. * @param scene The scene to add the material to
  99828. */
  99829. constructor(name: string, scene: Scene);
  99830. /**
  99831. * Gets a boolean indicating that current material needs to register RTT
  99832. */
  99833. readonly hasRenderTargetTextures: boolean;
  99834. /**
  99835. * The entire material has been created in order to prevent overdraw.
  99836. * @returns false
  99837. */
  99838. needAlphaTesting(): boolean;
  99839. /**
  99840. * The entire material has been created in order to prevent overdraw.
  99841. * @returns true if blending is enable
  99842. */
  99843. needAlphaBlending(): boolean;
  99844. /**
  99845. * Checks wether the material is ready to be rendered for a given mesh.
  99846. * @param mesh The mesh to render
  99847. * @param subMesh The submesh to check against
  99848. * @param useInstances Specify wether or not the material is used with instances
  99849. * @returns true if all the dependencies are ready (Textures, Effects...)
  99850. */
  99851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99852. /**
  99853. * Compute the primary color according to the chosen perceptual color.
  99854. */
  99855. private _computePrimaryColorFromPerceptualColor;
  99856. /**
  99857. * Compute the highlights and shadow colors according to their chosen levels.
  99858. */
  99859. private _computePrimaryColors;
  99860. /**
  99861. * Build the uniform buffer used in the material.
  99862. */
  99863. buildUniformLayout(): void;
  99864. /**
  99865. * Unbind the material.
  99866. */
  99867. unbind(): void;
  99868. /**
  99869. * Bind only the world matrix to the material.
  99870. * @param world The world matrix to bind.
  99871. */
  99872. bindOnlyWorldMatrix(world: Matrix): void;
  99873. /**
  99874. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99875. * @param world The world matrix to bind.
  99876. * @param subMesh The submesh to bind for.
  99877. */
  99878. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99879. /**
  99880. * Dispose the material.
  99881. * @param forceDisposeEffect Force disposal of the associated effect.
  99882. * @param forceDisposeTextures Force disposal of the associated textures.
  99883. */
  99884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99885. /**
  99886. * Clones the material.
  99887. * @param name The cloned name.
  99888. * @returns The cloned material.
  99889. */
  99890. clone(name: string): BackgroundMaterial;
  99891. /**
  99892. * Serializes the current material to its JSON representation.
  99893. * @returns The JSON representation.
  99894. */
  99895. serialize(): any;
  99896. /**
  99897. * Gets the class name of the material
  99898. * @returns "BackgroundMaterial"
  99899. */
  99900. getClassName(): string;
  99901. /**
  99902. * Parse a JSON input to create back a background material.
  99903. * @param source The JSON data to parse
  99904. * @param scene The scene to create the parsed material in
  99905. * @param rootUrl The root url of the assets the material depends upon
  99906. * @returns the instantiated BackgroundMaterial.
  99907. */
  99908. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99909. }
  99910. }
  99911. declare module BABYLON {
  99912. /**
  99913. * Represents the different options available during the creation of
  99914. * a Environment helper.
  99915. *
  99916. * This can control the default ground, skybox and image processing setup of your scene.
  99917. */
  99918. export interface IEnvironmentHelperOptions {
  99919. /**
  99920. * Specifies wether or not to create a ground.
  99921. * True by default.
  99922. */
  99923. createGround: boolean;
  99924. /**
  99925. * Specifies the ground size.
  99926. * 15 by default.
  99927. */
  99928. groundSize: number;
  99929. /**
  99930. * The texture used on the ground for the main color.
  99931. * Comes from the BabylonJS CDN by default.
  99932. *
  99933. * Remarks: Can be either a texture or a url.
  99934. */
  99935. groundTexture: string | BaseTexture;
  99936. /**
  99937. * The color mixed in the ground texture by default.
  99938. * BabylonJS clearColor by default.
  99939. */
  99940. groundColor: Color3;
  99941. /**
  99942. * Specifies the ground opacity.
  99943. * 1 by default.
  99944. */
  99945. groundOpacity: number;
  99946. /**
  99947. * Enables the ground to receive shadows.
  99948. * True by default.
  99949. */
  99950. enableGroundShadow: boolean;
  99951. /**
  99952. * Helps preventing the shadow to be fully black on the ground.
  99953. * 0.5 by default.
  99954. */
  99955. groundShadowLevel: number;
  99956. /**
  99957. * Creates a mirror texture attach to the ground.
  99958. * false by default.
  99959. */
  99960. enableGroundMirror: boolean;
  99961. /**
  99962. * Specifies the ground mirror size ratio.
  99963. * 0.3 by default as the default kernel is 64.
  99964. */
  99965. groundMirrorSizeRatio: number;
  99966. /**
  99967. * Specifies the ground mirror blur kernel size.
  99968. * 64 by default.
  99969. */
  99970. groundMirrorBlurKernel: number;
  99971. /**
  99972. * Specifies the ground mirror visibility amount.
  99973. * 1 by default
  99974. */
  99975. groundMirrorAmount: number;
  99976. /**
  99977. * Specifies the ground mirror reflectance weight.
  99978. * This uses the standard weight of the background material to setup the fresnel effect
  99979. * of the mirror.
  99980. * 1 by default.
  99981. */
  99982. groundMirrorFresnelWeight: number;
  99983. /**
  99984. * Specifies the ground mirror Falloff distance.
  99985. * This can helps reducing the size of the reflection.
  99986. * 0 by Default.
  99987. */
  99988. groundMirrorFallOffDistance: number;
  99989. /**
  99990. * Specifies the ground mirror texture type.
  99991. * Unsigned Int by Default.
  99992. */
  99993. groundMirrorTextureType: number;
  99994. /**
  99995. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99996. * the shown objects.
  99997. */
  99998. groundYBias: number;
  99999. /**
  100000. * Specifies wether or not to create a skybox.
  100001. * True by default.
  100002. */
  100003. createSkybox: boolean;
  100004. /**
  100005. * Specifies the skybox size.
  100006. * 20 by default.
  100007. */
  100008. skyboxSize: number;
  100009. /**
  100010. * The texture used on the skybox for the main color.
  100011. * Comes from the BabylonJS CDN by default.
  100012. *
  100013. * Remarks: Can be either a texture or a url.
  100014. */
  100015. skyboxTexture: string | BaseTexture;
  100016. /**
  100017. * The color mixed in the skybox texture by default.
  100018. * BabylonJS clearColor by default.
  100019. */
  100020. skyboxColor: Color3;
  100021. /**
  100022. * The background rotation around the Y axis of the scene.
  100023. * This helps aligning the key lights of your scene with the background.
  100024. * 0 by default.
  100025. */
  100026. backgroundYRotation: number;
  100027. /**
  100028. * Compute automatically the size of the elements to best fit with the scene.
  100029. */
  100030. sizeAuto: boolean;
  100031. /**
  100032. * Default position of the rootMesh if autoSize is not true.
  100033. */
  100034. rootPosition: Vector3;
  100035. /**
  100036. * Sets up the image processing in the scene.
  100037. * true by default.
  100038. */
  100039. setupImageProcessing: boolean;
  100040. /**
  100041. * The texture used as your environment texture in the scene.
  100042. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100043. *
  100044. * Remarks: Can be either a texture or a url.
  100045. */
  100046. environmentTexture: string | BaseTexture;
  100047. /**
  100048. * The value of the exposure to apply to the scene.
  100049. * 0.6 by default if setupImageProcessing is true.
  100050. */
  100051. cameraExposure: number;
  100052. /**
  100053. * The value of the contrast to apply to the scene.
  100054. * 1.6 by default if setupImageProcessing is true.
  100055. */
  100056. cameraContrast: number;
  100057. /**
  100058. * Specifies wether or not tonemapping should be enabled in the scene.
  100059. * true by default if setupImageProcessing is true.
  100060. */
  100061. toneMappingEnabled: boolean;
  100062. }
  100063. /**
  100064. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100065. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100066. * It also helps with the default setup of your imageProcessing configuration.
  100067. */
  100068. export class EnvironmentHelper {
  100069. /**
  100070. * Default ground texture URL.
  100071. */
  100072. private static _groundTextureCDNUrl;
  100073. /**
  100074. * Default skybox texture URL.
  100075. */
  100076. private static _skyboxTextureCDNUrl;
  100077. /**
  100078. * Default environment texture URL.
  100079. */
  100080. private static _environmentTextureCDNUrl;
  100081. /**
  100082. * Creates the default options for the helper.
  100083. */
  100084. private static _getDefaultOptions;
  100085. private _rootMesh;
  100086. /**
  100087. * Gets the root mesh created by the helper.
  100088. */
  100089. readonly rootMesh: Mesh;
  100090. private _skybox;
  100091. /**
  100092. * Gets the skybox created by the helper.
  100093. */
  100094. readonly skybox: Nullable<Mesh>;
  100095. private _skyboxTexture;
  100096. /**
  100097. * Gets the skybox texture created by the helper.
  100098. */
  100099. readonly skyboxTexture: Nullable<BaseTexture>;
  100100. private _skyboxMaterial;
  100101. /**
  100102. * Gets the skybox material created by the helper.
  100103. */
  100104. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100105. private _ground;
  100106. /**
  100107. * Gets the ground mesh created by the helper.
  100108. */
  100109. readonly ground: Nullable<Mesh>;
  100110. private _groundTexture;
  100111. /**
  100112. * Gets the ground texture created by the helper.
  100113. */
  100114. readonly groundTexture: Nullable<BaseTexture>;
  100115. private _groundMirror;
  100116. /**
  100117. * Gets the ground mirror created by the helper.
  100118. */
  100119. readonly groundMirror: Nullable<MirrorTexture>;
  100120. /**
  100121. * Gets the ground mirror render list to helps pushing the meshes
  100122. * you wish in the ground reflection.
  100123. */
  100124. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100125. private _groundMaterial;
  100126. /**
  100127. * Gets the ground material created by the helper.
  100128. */
  100129. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100130. /**
  100131. * Stores the creation options.
  100132. */
  100133. private readonly _scene;
  100134. private _options;
  100135. /**
  100136. * This observable will be notified with any error during the creation of the environment,
  100137. * mainly texture creation errors.
  100138. */
  100139. onErrorObservable: Observable<{
  100140. message?: string;
  100141. exception?: any;
  100142. }>;
  100143. /**
  100144. * constructor
  100145. * @param options Defines the options we want to customize the helper
  100146. * @param scene The scene to add the material to
  100147. */
  100148. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100149. /**
  100150. * Updates the background according to the new options
  100151. * @param options
  100152. */
  100153. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100154. /**
  100155. * Sets the primary color of all the available elements.
  100156. * @param color the main color to affect to the ground and the background
  100157. */
  100158. setMainColor(color: Color3): void;
  100159. /**
  100160. * Setup the image processing according to the specified options.
  100161. */
  100162. private _setupImageProcessing;
  100163. /**
  100164. * Setup the environment texture according to the specified options.
  100165. */
  100166. private _setupEnvironmentTexture;
  100167. /**
  100168. * Setup the background according to the specified options.
  100169. */
  100170. private _setupBackground;
  100171. /**
  100172. * Get the scene sizes according to the setup.
  100173. */
  100174. private _getSceneSize;
  100175. /**
  100176. * Setup the ground according to the specified options.
  100177. */
  100178. private _setupGround;
  100179. /**
  100180. * Setup the ground material according to the specified options.
  100181. */
  100182. private _setupGroundMaterial;
  100183. /**
  100184. * Setup the ground diffuse texture according to the specified options.
  100185. */
  100186. private _setupGroundDiffuseTexture;
  100187. /**
  100188. * Setup the ground mirror texture according to the specified options.
  100189. */
  100190. private _setupGroundMirrorTexture;
  100191. /**
  100192. * Setup the ground to receive the mirror texture.
  100193. */
  100194. private _setupMirrorInGroundMaterial;
  100195. /**
  100196. * Setup the skybox according to the specified options.
  100197. */
  100198. private _setupSkybox;
  100199. /**
  100200. * Setup the skybox material according to the specified options.
  100201. */
  100202. private _setupSkyboxMaterial;
  100203. /**
  100204. * Setup the skybox reflection texture according to the specified options.
  100205. */
  100206. private _setupSkyboxReflectionTexture;
  100207. private _errorHandler;
  100208. /**
  100209. * Dispose all the elements created by the Helper.
  100210. */
  100211. dispose(): void;
  100212. }
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100217. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100218. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100219. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100220. */
  100221. export class PhotoDome extends TransformNode {
  100222. private _useDirectMapping;
  100223. /**
  100224. * The texture being displayed on the sphere
  100225. */
  100226. protected _photoTexture: Texture;
  100227. /**
  100228. * Gets or sets the texture being displayed on the sphere
  100229. */
  100230. photoTexture: Texture;
  100231. /**
  100232. * Observable raised when an error occured while loading the 360 image
  100233. */
  100234. onLoadErrorObservable: Observable<string>;
  100235. /**
  100236. * The skybox material
  100237. */
  100238. protected _material: BackgroundMaterial;
  100239. /**
  100240. * The surface used for the skybox
  100241. */
  100242. protected _mesh: Mesh;
  100243. /**
  100244. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100245. * Also see the options.resolution property.
  100246. */
  100247. fovMultiplier: number;
  100248. /**
  100249. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100250. * @param name Element's name, child elements will append suffixes for their own names.
  100251. * @param urlsOfPhoto defines the url of the photo to display
  100252. * @param options defines an object containing optional or exposed sub element properties
  100253. * @param onError defines a callback called when an error occured while loading the texture
  100254. */
  100255. constructor(name: string, urlOfPhoto: string, options: {
  100256. resolution?: number;
  100257. size?: number;
  100258. useDirectMapping?: boolean;
  100259. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100260. /**
  100261. * Releases resources associated with this node.
  100262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100264. */
  100265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100266. }
  100267. }
  100268. declare module BABYLON {
  100269. /**
  100270. * Class used to host texture specific utilities
  100271. */
  100272. export class TextureTools {
  100273. /**
  100274. * Uses the GPU to create a copy texture rescaled at a given size
  100275. * @param texture Texture to copy from
  100276. * @param width defines the desired width
  100277. * @param height defines the desired height
  100278. * @param useBilinearMode defines if bilinear mode has to be used
  100279. * @return the generated texture
  100280. */
  100281. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100282. /**
  100283. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100284. * @param scene defines the hosting scene
  100285. * @returns the environment BRDF texture
  100286. */
  100287. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100288. private static _environmentBRDFBase64Texture;
  100289. }
  100290. }
  100291. declare module BABYLON {
  100292. /**
  100293. * @hidden
  100294. */
  100295. export interface IMaterialClearCoatDefines {
  100296. CLEARCOAT: boolean;
  100297. CLEARCOAT_DEFAULTIOR: boolean;
  100298. CLEARCOAT_TEXTURE: boolean;
  100299. CLEARCOAT_TEXTUREDIRECTUV: number;
  100300. CLEARCOAT_BUMP: boolean;
  100301. CLEARCOAT_BUMPDIRECTUV: number;
  100302. CLEARCOAT_TINT: boolean;
  100303. CLEARCOAT_TINT_TEXTURE: boolean;
  100304. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100305. /** @hidden */
  100306. _areTexturesDirty: boolean;
  100307. }
  100308. /**
  100309. * Define the code related to the clear coat parameters of the pbr material.
  100310. */
  100311. export class PBRClearCoatConfiguration {
  100312. /**
  100313. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100314. * The default fits with a polyurethane material.
  100315. */
  100316. private static readonly _DefaultIndiceOfRefraction;
  100317. private _isEnabled;
  100318. /**
  100319. * Defines if the clear coat is enabled in the material.
  100320. */
  100321. isEnabled: boolean;
  100322. /**
  100323. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100324. */
  100325. intensity: number;
  100326. /**
  100327. * Defines the clear coat layer roughness.
  100328. */
  100329. roughness: number;
  100330. private _indiceOfRefraction;
  100331. /**
  100332. * Defines the indice of refraction of the clear coat.
  100333. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100334. * The default fits with a polyurethane material.
  100335. * Changing the default value is more performance intensive.
  100336. */
  100337. indiceOfRefraction: number;
  100338. private _texture;
  100339. /**
  100340. * Stores the clear coat values in a texture.
  100341. */
  100342. texture: Nullable<BaseTexture>;
  100343. private _bumpTexture;
  100344. /**
  100345. * Define the clear coat specific bump texture.
  100346. */
  100347. bumpTexture: Nullable<BaseTexture>;
  100348. private _isTintEnabled;
  100349. /**
  100350. * Defines if the clear coat tint is enabled in the material.
  100351. */
  100352. isTintEnabled: boolean;
  100353. /**
  100354. * Defines if the clear coat tint is enabled in the material.
  100355. * This is only use if tint is enabled
  100356. */
  100357. tintColor: Color3;
  100358. /**
  100359. * Defines if the distance at which the tint color should be found in the
  100360. * clear coat media.
  100361. * This is only use if tint is enabled
  100362. */
  100363. tintColorAtDistance: number;
  100364. /**
  100365. * Defines the clear coat layer thickness.
  100366. * This is only use if tint is enabled
  100367. */
  100368. tintThickness: number;
  100369. private _tintTexture;
  100370. /**
  100371. * Stores the clear tint values in a texture.
  100372. * rgb is tint
  100373. * a is a thickness factor
  100374. */
  100375. tintTexture: Nullable<BaseTexture>;
  100376. /** @hidden */
  100377. private _internalMarkAllSubMeshesAsTexturesDirty;
  100378. /** @hidden */
  100379. _markAllSubMeshesAsTexturesDirty(): void;
  100380. /**
  100381. * Instantiate a new istance of clear coat configuration.
  100382. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100383. */
  100384. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100385. /**
  100386. * Specifies that the submesh is ready to be used.
  100387. * @param defines the list of "defines" to update.
  100388. * @param scene defines the scene the material belongs to.
  100389. * @param engine defines the engine the material belongs to.
  100390. * @param disableBumpMap defines wether the material disables bump or not.
  100391. * @returns - boolean indicating that the submesh is ready or not.
  100392. */
  100393. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100394. /**
  100395. * Checks to see if a texture is used in the material.
  100396. * @param defines the list of "defines" to update.
  100397. * @param scene defines the scene to the material belongs to.
  100398. */
  100399. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100400. /**
  100401. * Binds the material data.
  100402. * @param uniformBuffer defines the Uniform buffer to fill in.
  100403. * @param scene defines the scene the material belongs to.
  100404. * @param engine defines the engine the material belongs to.
  100405. * @param disableBumpMap defines wether the material disables bump or not.
  100406. * @param isFrozen defines wether the material is frozen or not.
  100407. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100408. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100409. */
  100410. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100411. /**
  100412. * Checks to see if a texture is used in the material.
  100413. * @param texture - Base texture to use.
  100414. * @returns - Boolean specifying if a texture is used in the material.
  100415. */
  100416. hasTexture(texture: BaseTexture): boolean;
  100417. /**
  100418. * Returns an array of the actively used textures.
  100419. * @param activeTextures Array of BaseTextures
  100420. */
  100421. getActiveTextures(activeTextures: BaseTexture[]): void;
  100422. /**
  100423. * Returns the animatable textures.
  100424. * @param animatables Array of animatable textures.
  100425. */
  100426. getAnimatables(animatables: IAnimatable[]): void;
  100427. /**
  100428. * Disposes the resources of the material.
  100429. * @param forceDisposeTextures - Forces the disposal of all textures.
  100430. */
  100431. dispose(forceDisposeTextures?: boolean): void;
  100432. /**
  100433. * Get the current class name of the texture useful for serialization or dynamic coding.
  100434. * @returns "PBRClearCoatConfiguration"
  100435. */
  100436. getClassName(): string;
  100437. /**
  100438. * Add fallbacks to the effect fallbacks list.
  100439. * @param defines defines the Base texture to use.
  100440. * @param fallbacks defines the current fallback list.
  100441. * @param currentRank defines the current fallback rank.
  100442. * @returns the new fallback rank.
  100443. */
  100444. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100445. /**
  100446. * Add the required uniforms to the current list.
  100447. * @param uniforms defines the current uniform list.
  100448. */
  100449. static AddUniforms(uniforms: string[]): void;
  100450. /**
  100451. * Add the required samplers to the current list.
  100452. * @param samplers defines the current sampler list.
  100453. */
  100454. static AddSamplers(samplers: string[]): void;
  100455. /**
  100456. * Add the required uniforms to the current buffer.
  100457. * @param uniformBuffer defines the current uniform buffer.
  100458. */
  100459. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100460. /**
  100461. * Makes a duplicate of the current configuration into another one.
  100462. * @param clearCoatConfiguration define the config where to copy the info
  100463. */
  100464. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100465. /**
  100466. * Serializes this clear coat configuration.
  100467. * @returns - An object with the serialized config.
  100468. */
  100469. serialize(): any;
  100470. /**
  100471. * Parses a Clear Coat Configuration from a serialized object.
  100472. * @param source - Serialized object.
  100473. */
  100474. parse(source: any): void;
  100475. }
  100476. }
  100477. declare module BABYLON {
  100478. /**
  100479. * @hidden
  100480. */
  100481. export interface IMaterialAnisotropicDefines {
  100482. ANISOTROPIC: boolean;
  100483. ANISOTROPIC_TEXTURE: boolean;
  100484. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100485. MAINUV1: boolean;
  100486. _areTexturesDirty: boolean;
  100487. _needUVs: boolean;
  100488. }
  100489. /**
  100490. * Define the code related to the anisotropic parameters of the pbr material.
  100491. */
  100492. export class PBRAnisotropicConfiguration {
  100493. private _isEnabled;
  100494. /**
  100495. * Defines if the anisotropy is enabled in the material.
  100496. */
  100497. isEnabled: boolean;
  100498. /**
  100499. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100500. */
  100501. intensity: number;
  100502. /**
  100503. * Defines if the effect is along the tangents, bitangents or in between.
  100504. * By default, the effect is "strectching" the highlights along the tangents.
  100505. */
  100506. direction: Vector2;
  100507. private _texture;
  100508. /**
  100509. * Stores the anisotropy values in a texture.
  100510. * rg is direction (like normal from -1 to 1)
  100511. * b is a intensity
  100512. */
  100513. texture: Nullable<BaseTexture>;
  100514. /** @hidden */
  100515. private _internalMarkAllSubMeshesAsTexturesDirty;
  100516. /** @hidden */
  100517. _markAllSubMeshesAsTexturesDirty(): void;
  100518. /**
  100519. * Instantiate a new istance of anisotropy configuration.
  100520. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100521. */
  100522. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100523. /**
  100524. * Specifies that the submesh is ready to be used.
  100525. * @param defines the list of "defines" to update.
  100526. * @param scene defines the scene the material belongs to.
  100527. * @returns - boolean indicating that the submesh is ready or not.
  100528. */
  100529. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100530. /**
  100531. * Checks to see if a texture is used in the material.
  100532. * @param defines the list of "defines" to update.
  100533. * @param mesh the mesh we are preparing the defines for.
  100534. * @param scene defines the scene the material belongs to.
  100535. */
  100536. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100537. /**
  100538. * Binds the material data.
  100539. * @param uniformBuffer defines the Uniform buffer to fill in.
  100540. * @param scene defines the scene the material belongs to.
  100541. * @param isFrozen defines wether the material is frozen or not.
  100542. */
  100543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100544. /**
  100545. * Checks to see if a texture is used in the material.
  100546. * @param texture - Base texture to use.
  100547. * @returns - Boolean specifying if a texture is used in the material.
  100548. */
  100549. hasTexture(texture: BaseTexture): boolean;
  100550. /**
  100551. * Returns an array of the actively used textures.
  100552. * @param activeTextures Array of BaseTextures
  100553. */
  100554. getActiveTextures(activeTextures: BaseTexture[]): void;
  100555. /**
  100556. * Returns the animatable textures.
  100557. * @param animatables Array of animatable textures.
  100558. */
  100559. getAnimatables(animatables: IAnimatable[]): void;
  100560. /**
  100561. * Disposes the resources of the material.
  100562. * @param forceDisposeTextures - Forces the disposal of all textures.
  100563. */
  100564. dispose(forceDisposeTextures?: boolean): void;
  100565. /**
  100566. * Get the current class name of the texture useful for serialization or dynamic coding.
  100567. * @returns "PBRAnisotropicConfiguration"
  100568. */
  100569. getClassName(): string;
  100570. /**
  100571. * Add fallbacks to the effect fallbacks list.
  100572. * @param defines defines the Base texture to use.
  100573. * @param fallbacks defines the current fallback list.
  100574. * @param currentRank defines the current fallback rank.
  100575. * @returns the new fallback rank.
  100576. */
  100577. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100578. /**
  100579. * Add the required uniforms to the current list.
  100580. * @param uniforms defines the current uniform list.
  100581. */
  100582. static AddUniforms(uniforms: string[]): void;
  100583. /**
  100584. * Add the required uniforms to the current buffer.
  100585. * @param uniformBuffer defines the current uniform buffer.
  100586. */
  100587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100588. /**
  100589. * Add the required samplers to the current list.
  100590. * @param samplers defines the current sampler list.
  100591. */
  100592. static AddSamplers(samplers: string[]): void;
  100593. /**
  100594. * Makes a duplicate of the current configuration into another one.
  100595. * @param anisotropicConfiguration define the config where to copy the info
  100596. */
  100597. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100598. /**
  100599. * Serializes this anisotropy configuration.
  100600. * @returns - An object with the serialized config.
  100601. */
  100602. serialize(): any;
  100603. /**
  100604. * Parses a anisotropy Configuration from a serialized object.
  100605. * @param source - Serialized object.
  100606. */
  100607. parse(source: any): void;
  100608. }
  100609. }
  100610. declare module BABYLON {
  100611. /**
  100612. * @hidden
  100613. */
  100614. export interface IMaterialBRDFDefines {
  100615. BRDF_V_HEIGHT_CORRELATED: boolean;
  100616. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100617. /** @hidden */
  100618. _areMiscDirty: boolean;
  100619. }
  100620. /**
  100621. * Define the code related to the BRDF parameters of the pbr material.
  100622. */
  100623. export class PBRBRDFConfiguration {
  100624. private _useEnergyConservation;
  100625. /**
  100626. * Defines if the material uses energy conservation.
  100627. */
  100628. useEnergyConservation: boolean;
  100629. private _useSmithVisibilityHeightCorrelated;
  100630. /**
  100631. * LEGACY Mode set to false
  100632. * Defines if the material uses height smith correlated visibility term.
  100633. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100634. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100635. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100636. * Not relying on height correlated will also disable energy conservation.
  100637. */
  100638. useSmithVisibilityHeightCorrelated: boolean;
  100639. /** @hidden */
  100640. private _internalMarkAllSubMeshesAsMiscDirty;
  100641. /** @hidden */
  100642. _markAllSubMeshesAsMiscDirty(): void;
  100643. /**
  100644. * Instantiate a new istance of clear coat configuration.
  100645. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100646. */
  100647. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100648. /**
  100649. * Checks to see if a texture is used in the material.
  100650. * @param defines the list of "defines" to update.
  100651. */
  100652. prepareDefines(defines: IMaterialBRDFDefines): void;
  100653. /**
  100654. * Get the current class name of the texture useful for serialization or dynamic coding.
  100655. * @returns "PBRClearCoatConfiguration"
  100656. */
  100657. getClassName(): string;
  100658. /**
  100659. * Makes a duplicate of the current configuration into another one.
  100660. * @param brdfConfiguration define the config where to copy the info
  100661. */
  100662. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100663. /**
  100664. * Serializes this BRDF configuration.
  100665. * @returns - An object with the serialized config.
  100666. */
  100667. serialize(): any;
  100668. /**
  100669. * Parses a BRDF Configuration from a serialized object.
  100670. * @param source - Serialized object.
  100671. */
  100672. parse(source: any): void;
  100673. }
  100674. }
  100675. declare module BABYLON {
  100676. /**
  100677. * @hidden
  100678. */
  100679. export interface IMaterialSheenDefines {
  100680. SHEEN: boolean;
  100681. SHEEN_TEXTURE: boolean;
  100682. SHEEN_TEXTUREDIRECTUV: number;
  100683. SHEEN_LINKWITHALBEDO: boolean;
  100684. /** @hidden */
  100685. _areTexturesDirty: boolean;
  100686. }
  100687. /**
  100688. * Define the code related to the Sheen parameters of the pbr material.
  100689. */
  100690. export class PBRSheenConfiguration {
  100691. private _isEnabled;
  100692. /**
  100693. * Defines if the material uses sheen.
  100694. */
  100695. isEnabled: boolean;
  100696. private _linkSheenWithAlbedo;
  100697. /**
  100698. * Defines if the sheen is linked to the sheen color.
  100699. */
  100700. linkSheenWithAlbedo: boolean;
  100701. /**
  100702. * Defines the sheen intensity.
  100703. */
  100704. intensity: number;
  100705. /**
  100706. * Defines the sheen color.
  100707. */
  100708. color: Color3;
  100709. private _texture;
  100710. /**
  100711. * Stores the sheen tint values in a texture.
  100712. * rgb is tint
  100713. * a is a intensity
  100714. */
  100715. texture: Nullable<BaseTexture>;
  100716. /** @hidden */
  100717. private _internalMarkAllSubMeshesAsTexturesDirty;
  100718. /** @hidden */
  100719. _markAllSubMeshesAsTexturesDirty(): void;
  100720. /**
  100721. * Instantiate a new istance of clear coat configuration.
  100722. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100723. */
  100724. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100725. /**
  100726. * Specifies that the submesh is ready to be used.
  100727. * @param defines the list of "defines" to update.
  100728. * @param scene defines the scene the material belongs to.
  100729. * @returns - boolean indicating that the submesh is ready or not.
  100730. */
  100731. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100732. /**
  100733. * Checks to see if a texture is used in the material.
  100734. * @param defines the list of "defines" to update.
  100735. * @param scene defines the scene the material belongs to.
  100736. */
  100737. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100738. /**
  100739. * Binds the material data.
  100740. * @param uniformBuffer defines the Uniform buffer to fill in.
  100741. * @param scene defines the scene the material belongs to.
  100742. * @param isFrozen defines wether the material is frozen or not.
  100743. */
  100744. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100745. /**
  100746. * Checks to see if a texture is used in the material.
  100747. * @param texture - Base texture to use.
  100748. * @returns - Boolean specifying if a texture is used in the material.
  100749. */
  100750. hasTexture(texture: BaseTexture): boolean;
  100751. /**
  100752. * Returns an array of the actively used textures.
  100753. * @param activeTextures Array of BaseTextures
  100754. */
  100755. getActiveTextures(activeTextures: BaseTexture[]): void;
  100756. /**
  100757. * Returns the animatable textures.
  100758. * @param animatables Array of animatable textures.
  100759. */
  100760. getAnimatables(animatables: IAnimatable[]): void;
  100761. /**
  100762. * Disposes the resources of the material.
  100763. * @param forceDisposeTextures - Forces the disposal of all textures.
  100764. */
  100765. dispose(forceDisposeTextures?: boolean): void;
  100766. /**
  100767. * Get the current class name of the texture useful for serialization or dynamic coding.
  100768. * @returns "PBRSheenConfiguration"
  100769. */
  100770. getClassName(): string;
  100771. /**
  100772. * Add fallbacks to the effect fallbacks list.
  100773. * @param defines defines the Base texture to use.
  100774. * @param fallbacks defines the current fallback list.
  100775. * @param currentRank defines the current fallback rank.
  100776. * @returns the new fallback rank.
  100777. */
  100778. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100779. /**
  100780. * Add the required uniforms to the current list.
  100781. * @param uniforms defines the current uniform list.
  100782. */
  100783. static AddUniforms(uniforms: string[]): void;
  100784. /**
  100785. * Add the required uniforms to the current buffer.
  100786. * @param uniformBuffer defines the current uniform buffer.
  100787. */
  100788. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100789. /**
  100790. * Add the required samplers to the current list.
  100791. * @param samplers defines the current sampler list.
  100792. */
  100793. static AddSamplers(samplers: string[]): void;
  100794. /**
  100795. * Makes a duplicate of the current configuration into another one.
  100796. * @param sheenConfiguration define the config where to copy the info
  100797. */
  100798. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  100799. /**
  100800. * Serializes this BRDF configuration.
  100801. * @returns - An object with the serialized config.
  100802. */
  100803. serialize(): any;
  100804. /**
  100805. * Parses a Sheen Configuration from a serialized object.
  100806. * @param source - Serialized object.
  100807. */
  100808. parse(source: any): void;
  100809. }
  100810. }
  100811. declare module BABYLON {
  100812. /** @hidden */
  100813. export var pbrFragmentDeclaration: {
  100814. name: string;
  100815. shader: string;
  100816. };
  100817. }
  100818. declare module BABYLON {
  100819. /** @hidden */
  100820. export var pbrUboDeclaration: {
  100821. name: string;
  100822. shader: string;
  100823. };
  100824. }
  100825. declare module BABYLON {
  100826. /** @hidden */
  100827. export var pbrFunctions: {
  100828. name: string;
  100829. shader: string;
  100830. };
  100831. }
  100832. declare module BABYLON {
  100833. /** @hidden */
  100834. export var harmonicsFunctions: {
  100835. name: string;
  100836. shader: string;
  100837. };
  100838. }
  100839. declare module BABYLON {
  100840. /** @hidden */
  100841. export var pbrPreLightingFunctions: {
  100842. name: string;
  100843. shader: string;
  100844. };
  100845. }
  100846. declare module BABYLON {
  100847. /** @hidden */
  100848. export var pbrFalloffLightingFunctions: {
  100849. name: string;
  100850. shader: string;
  100851. };
  100852. }
  100853. declare module BABYLON {
  100854. /** @hidden */
  100855. export var pbrLightingFunctions: {
  100856. name: string;
  100857. shader: string;
  100858. };
  100859. }
  100860. declare module BABYLON {
  100861. /** @hidden */
  100862. export var pbrDebug: {
  100863. name: string;
  100864. shader: string;
  100865. };
  100866. }
  100867. declare module BABYLON {
  100868. /** @hidden */
  100869. export var pbrPixelShader: {
  100870. name: string;
  100871. shader: string;
  100872. };
  100873. }
  100874. declare module BABYLON {
  100875. /** @hidden */
  100876. export var pbrVertexDeclaration: {
  100877. name: string;
  100878. shader: string;
  100879. };
  100880. }
  100881. declare module BABYLON {
  100882. /** @hidden */
  100883. export var pbrVertexShader: {
  100884. name: string;
  100885. shader: string;
  100886. };
  100887. }
  100888. declare module BABYLON {
  100889. /**
  100890. * The Physically based material base class of BJS.
  100891. *
  100892. * This offers the main features of a standard PBR material.
  100893. * For more information, please refer to the documentation :
  100894. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100895. */
  100896. export abstract class PBRBaseMaterial extends PushMaterial {
  100897. /**
  100898. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100899. */
  100900. static readonly PBRMATERIAL_OPAQUE: number;
  100901. /**
  100902. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100903. */
  100904. static readonly PBRMATERIAL_ALPHATEST: number;
  100905. /**
  100906. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100907. */
  100908. static readonly PBRMATERIAL_ALPHABLEND: number;
  100909. /**
  100910. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100911. * They are also discarded below the alpha cutoff threshold to improve performances.
  100912. */
  100913. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100914. /**
  100915. * Defines the default value of how much AO map is occluding the analytical lights
  100916. * (point spot...).
  100917. */
  100918. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100919. /**
  100920. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100921. */
  100922. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100923. /**
  100924. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100925. * to enhance interoperability with other engines.
  100926. */
  100927. static readonly LIGHTFALLOFF_GLTF: number;
  100928. /**
  100929. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100930. * to enhance interoperability with other materials.
  100931. */
  100932. static readonly LIGHTFALLOFF_STANDARD: number;
  100933. /**
  100934. * Intensity of the direct lights e.g. the four lights available in your scene.
  100935. * This impacts both the direct diffuse and specular highlights.
  100936. */
  100937. protected _directIntensity: number;
  100938. /**
  100939. * Intensity of the emissive part of the material.
  100940. * This helps controlling the emissive effect without modifying the emissive color.
  100941. */
  100942. protected _emissiveIntensity: number;
  100943. /**
  100944. * Intensity of the environment e.g. how much the environment will light the object
  100945. * either through harmonics for rough material or through the refelction for shiny ones.
  100946. */
  100947. protected _environmentIntensity: number;
  100948. /**
  100949. * This is a special control allowing the reduction of the specular highlights coming from the
  100950. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100951. */
  100952. protected _specularIntensity: number;
  100953. /**
  100954. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100955. */
  100956. private _lightingInfos;
  100957. /**
  100958. * Debug Control allowing disabling the bump map on this material.
  100959. */
  100960. protected _disableBumpMap: boolean;
  100961. /**
  100962. * AKA Diffuse Texture in standard nomenclature.
  100963. */
  100964. protected _albedoTexture: BaseTexture;
  100965. /**
  100966. * AKA Occlusion Texture in other nomenclature.
  100967. */
  100968. protected _ambientTexture: BaseTexture;
  100969. /**
  100970. * AKA Occlusion Texture Intensity in other nomenclature.
  100971. */
  100972. protected _ambientTextureStrength: number;
  100973. /**
  100974. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100975. * 1 means it completely occludes it
  100976. * 0 mean it has no impact
  100977. */
  100978. protected _ambientTextureImpactOnAnalyticalLights: number;
  100979. /**
  100980. * Stores the alpha values in a texture.
  100981. */
  100982. protected _opacityTexture: BaseTexture;
  100983. /**
  100984. * Stores the reflection values in a texture.
  100985. */
  100986. protected _reflectionTexture: BaseTexture;
  100987. /**
  100988. * Stores the refraction values in a texture.
  100989. */
  100990. protected _refractionTexture: BaseTexture;
  100991. /**
  100992. * Stores the emissive values in a texture.
  100993. */
  100994. protected _emissiveTexture: BaseTexture;
  100995. /**
  100996. * AKA Specular texture in other nomenclature.
  100997. */
  100998. protected _reflectivityTexture: BaseTexture;
  100999. /**
  101000. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101001. */
  101002. protected _metallicTexture: BaseTexture;
  101003. /**
  101004. * Specifies the metallic scalar of the metallic/roughness workflow.
  101005. * Can also be used to scale the metalness values of the metallic texture.
  101006. */
  101007. protected _metallic: Nullable<number>;
  101008. /**
  101009. * Specifies the roughness scalar of the metallic/roughness workflow.
  101010. * Can also be used to scale the roughness values of the metallic texture.
  101011. */
  101012. protected _roughness: Nullable<number>;
  101013. /**
  101014. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101015. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101016. */
  101017. protected _microSurfaceTexture: BaseTexture;
  101018. /**
  101019. * Stores surface normal data used to displace a mesh in a texture.
  101020. */
  101021. protected _bumpTexture: BaseTexture;
  101022. /**
  101023. * Stores the pre-calculated light information of a mesh in a texture.
  101024. */
  101025. protected _lightmapTexture: BaseTexture;
  101026. /**
  101027. * The color of a material in ambient lighting.
  101028. */
  101029. protected _ambientColor: Color3;
  101030. /**
  101031. * AKA Diffuse Color in other nomenclature.
  101032. */
  101033. protected _albedoColor: Color3;
  101034. /**
  101035. * AKA Specular Color in other nomenclature.
  101036. */
  101037. protected _reflectivityColor: Color3;
  101038. /**
  101039. * The color applied when light is reflected from a material.
  101040. */
  101041. protected _reflectionColor: Color3;
  101042. /**
  101043. * The color applied when light is emitted from a material.
  101044. */
  101045. protected _emissiveColor: Color3;
  101046. /**
  101047. * AKA Glossiness in other nomenclature.
  101048. */
  101049. protected _microSurface: number;
  101050. /**
  101051. * source material index of refraction (IOR)' / 'destination material IOR.
  101052. */
  101053. protected _indexOfRefraction: number;
  101054. /**
  101055. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101056. */
  101057. protected _invertRefractionY: boolean;
  101058. /**
  101059. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101060. * Materials half opaque for instance using refraction could benefit from this control.
  101061. */
  101062. protected _linkRefractionWithTransparency: boolean;
  101063. /**
  101064. * Specifies that the material will use the light map as a show map.
  101065. */
  101066. protected _useLightmapAsShadowmap: boolean;
  101067. /**
  101068. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101069. * makes the reflect vector face the model (under horizon).
  101070. */
  101071. protected _useHorizonOcclusion: boolean;
  101072. /**
  101073. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101074. * too much the area relying on ambient texture to define their ambient occlusion.
  101075. */
  101076. protected _useRadianceOcclusion: boolean;
  101077. /**
  101078. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101079. */
  101080. protected _useAlphaFromAlbedoTexture: boolean;
  101081. /**
  101082. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101083. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101084. */
  101085. protected _useSpecularOverAlpha: boolean;
  101086. /**
  101087. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101088. */
  101089. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101090. /**
  101091. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101092. */
  101093. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101094. /**
  101095. * Specifies if the metallic texture contains the roughness information in its green channel.
  101096. */
  101097. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101098. /**
  101099. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101100. */
  101101. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101102. /**
  101103. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101104. */
  101105. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101106. /**
  101107. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101108. */
  101109. protected _useAmbientInGrayScale: boolean;
  101110. /**
  101111. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101112. * The material will try to infer what glossiness each pixel should be.
  101113. */
  101114. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101115. /**
  101116. * Defines the falloff type used in this material.
  101117. * It by default is Physical.
  101118. */
  101119. protected _lightFalloff: number;
  101120. /**
  101121. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101122. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101123. */
  101124. protected _useRadianceOverAlpha: boolean;
  101125. /**
  101126. * Allows using an object space normal map (instead of tangent space).
  101127. */
  101128. protected _useObjectSpaceNormalMap: boolean;
  101129. /**
  101130. * Allows using the bump map in parallax mode.
  101131. */
  101132. protected _useParallax: boolean;
  101133. /**
  101134. * Allows using the bump map in parallax occlusion mode.
  101135. */
  101136. protected _useParallaxOcclusion: boolean;
  101137. /**
  101138. * Controls the scale bias of the parallax mode.
  101139. */
  101140. protected _parallaxScaleBias: number;
  101141. /**
  101142. * If sets to true, disables all the lights affecting the material.
  101143. */
  101144. protected _disableLighting: boolean;
  101145. /**
  101146. * Number of Simultaneous lights allowed on the material.
  101147. */
  101148. protected _maxSimultaneousLights: number;
  101149. /**
  101150. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101151. */
  101152. protected _invertNormalMapX: boolean;
  101153. /**
  101154. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101155. */
  101156. protected _invertNormalMapY: boolean;
  101157. /**
  101158. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101159. */
  101160. protected _twoSidedLighting: boolean;
  101161. /**
  101162. * Defines the alpha limits in alpha test mode.
  101163. */
  101164. protected _alphaCutOff: number;
  101165. /**
  101166. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101167. */
  101168. protected _forceAlphaTest: boolean;
  101169. /**
  101170. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101171. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101172. */
  101173. protected _useAlphaFresnel: boolean;
  101174. /**
  101175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101176. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101177. */
  101178. protected _useLinearAlphaFresnel: boolean;
  101179. /**
  101180. * The transparency mode of the material.
  101181. */
  101182. protected _transparencyMode: Nullable<number>;
  101183. /**
  101184. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101185. * from cos thetav and roughness:
  101186. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101187. */
  101188. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101189. /**
  101190. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101191. */
  101192. protected _forceIrradianceInFragment: boolean;
  101193. /**
  101194. * Force normal to face away from face.
  101195. */
  101196. protected _forceNormalForward: boolean;
  101197. /**
  101198. * Enables specular anti aliasing in the PBR shader.
  101199. * It will both interacts on the Geometry for analytical and IBL lighting.
  101200. * It also prefilter the roughness map based on the bump values.
  101201. */
  101202. protected _enableSpecularAntiAliasing: boolean;
  101203. /**
  101204. * Default configuration related to image processing available in the PBR Material.
  101205. */
  101206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101207. /**
  101208. * Keep track of the image processing observer to allow dispose and replace.
  101209. */
  101210. private _imageProcessingObserver;
  101211. /**
  101212. * Attaches a new image processing configuration to the PBR Material.
  101213. * @param configuration
  101214. */
  101215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101216. /**
  101217. * Stores the available render targets.
  101218. */
  101219. private _renderTargets;
  101220. /**
  101221. * Sets the global ambient color for the material used in lighting calculations.
  101222. */
  101223. private _globalAmbientColor;
  101224. /**
  101225. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101226. */
  101227. private _useLogarithmicDepth;
  101228. /**
  101229. * If set to true, no lighting calculations will be applied.
  101230. */
  101231. private _unlit;
  101232. private _debugMode;
  101233. /**
  101234. * @hidden
  101235. * This is reserved for the inspector.
  101236. * Defines the material debug mode.
  101237. * It helps seeing only some components of the material while troubleshooting.
  101238. */
  101239. debugMode: number;
  101240. /**
  101241. * @hidden
  101242. * This is reserved for the inspector.
  101243. * Specify from where on screen the debug mode should start.
  101244. * The value goes from -1 (full screen) to 1 (not visible)
  101245. * It helps with side by side comparison against the final render
  101246. * This defaults to -1
  101247. */
  101248. private debugLimit;
  101249. /**
  101250. * @hidden
  101251. * This is reserved for the inspector.
  101252. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101253. * You can use the factor to better multiply the final value.
  101254. */
  101255. private debugFactor;
  101256. /**
  101257. * Defines the clear coat layer parameters for the material.
  101258. */
  101259. readonly clearCoat: PBRClearCoatConfiguration;
  101260. /**
  101261. * Defines the anisotropic parameters for the material.
  101262. */
  101263. readonly anisotropy: PBRAnisotropicConfiguration;
  101264. /**
  101265. * Defines the BRDF parameters for the material.
  101266. */
  101267. readonly brdf: PBRBRDFConfiguration;
  101268. /**
  101269. * Defines the Sheen parameters for the material.
  101270. */
  101271. readonly sheen: PBRSheenConfiguration;
  101272. /**
  101273. * Instantiates a new PBRMaterial instance.
  101274. *
  101275. * @param name The material name
  101276. * @param scene The scene the material will be use in.
  101277. */
  101278. constructor(name: string, scene: Scene);
  101279. /**
  101280. * Gets a boolean indicating that current material needs to register RTT
  101281. */
  101282. readonly hasRenderTargetTextures: boolean;
  101283. /**
  101284. * Gets the name of the material class.
  101285. */
  101286. getClassName(): string;
  101287. /**
  101288. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101289. */
  101290. /**
  101291. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101292. */
  101293. useLogarithmicDepth: boolean;
  101294. /**
  101295. * Gets the current transparency mode.
  101296. */
  101297. /**
  101298. * Sets the transparency mode of the material.
  101299. *
  101300. * | Value | Type | Description |
  101301. * | ----- | ----------------------------------- | ----------- |
  101302. * | 0 | OPAQUE | |
  101303. * | 1 | ALPHATEST | |
  101304. * | 2 | ALPHABLEND | |
  101305. * | 3 | ALPHATESTANDBLEND | |
  101306. *
  101307. */
  101308. transparencyMode: Nullable<number>;
  101309. /**
  101310. * Returns true if alpha blending should be disabled.
  101311. */
  101312. private readonly _disableAlphaBlending;
  101313. /**
  101314. * Specifies whether or not this material should be rendered in alpha blend mode.
  101315. */
  101316. needAlphaBlending(): boolean;
  101317. /**
  101318. * Specifies if the mesh will require alpha blending.
  101319. * @param mesh - BJS mesh.
  101320. */
  101321. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101322. /**
  101323. * Specifies whether or not this material should be rendered in alpha test mode.
  101324. */
  101325. needAlphaTesting(): boolean;
  101326. /**
  101327. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101328. */
  101329. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101330. /**
  101331. * Gets the texture used for the alpha test.
  101332. */
  101333. getAlphaTestTexture(): BaseTexture;
  101334. /**
  101335. * Specifies that the submesh is ready to be used.
  101336. * @param mesh - BJS mesh.
  101337. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101338. * @param useInstances - Specifies that instances should be used.
  101339. * @returns - boolean indicating that the submesh is ready or not.
  101340. */
  101341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101342. /**
  101343. * Specifies if the material uses metallic roughness workflow.
  101344. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101345. */
  101346. isMetallicWorkflow(): boolean;
  101347. private _prepareEffect;
  101348. private _prepareDefines;
  101349. /**
  101350. * Force shader compilation
  101351. */
  101352. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101353. clipPlane: boolean;
  101354. }>): void;
  101355. /**
  101356. * Initializes the uniform buffer layout for the shader.
  101357. */
  101358. buildUniformLayout(): void;
  101359. /**
  101360. * Unbinds the textures.
  101361. */
  101362. unbind(): void;
  101363. /**
  101364. * Binds the submesh data.
  101365. * @param world - The world matrix.
  101366. * @param mesh - The BJS mesh.
  101367. * @param subMesh - A submesh of the BJS mesh.
  101368. */
  101369. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101370. /**
  101371. * Returns the animatable textures.
  101372. * @returns - Array of animatable textures.
  101373. */
  101374. getAnimatables(): IAnimatable[];
  101375. /**
  101376. * Returns the texture used for reflections.
  101377. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101378. */
  101379. private _getReflectionTexture;
  101380. /**
  101381. * Returns the texture used for refraction or null if none is used.
  101382. * @returns - Refection texture if present. If no refraction texture and refraction
  101383. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101384. */
  101385. private _getRefractionTexture;
  101386. /**
  101387. * Returns an array of the actively used textures.
  101388. * @returns - Array of BaseTextures
  101389. */
  101390. getActiveTextures(): BaseTexture[];
  101391. /**
  101392. * Checks to see if a texture is used in the material.
  101393. * @param texture - Base texture to use.
  101394. * @returns - Boolean specifying if a texture is used in the material.
  101395. */
  101396. hasTexture(texture: BaseTexture): boolean;
  101397. /**
  101398. * Disposes the resources of the material.
  101399. * @param forceDisposeEffect - Forces the disposal of effects.
  101400. * @param forceDisposeTextures - Forces the disposal of all textures.
  101401. */
  101402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101403. }
  101404. }
  101405. declare module BABYLON {
  101406. /**
  101407. * The Physically based material of BJS.
  101408. *
  101409. * This offers the main features of a standard PBR material.
  101410. * For more information, please refer to the documentation :
  101411. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101412. */
  101413. export class PBRMaterial extends PBRBaseMaterial {
  101414. /**
  101415. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101416. */
  101417. static readonly PBRMATERIAL_OPAQUE: number;
  101418. /**
  101419. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101420. */
  101421. static readonly PBRMATERIAL_ALPHATEST: number;
  101422. /**
  101423. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101424. */
  101425. static readonly PBRMATERIAL_ALPHABLEND: number;
  101426. /**
  101427. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101428. * They are also discarded below the alpha cutoff threshold to improve performances.
  101429. */
  101430. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101431. /**
  101432. * Defines the default value of how much AO map is occluding the analytical lights
  101433. * (point spot...).
  101434. */
  101435. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101436. /**
  101437. * Intensity of the direct lights e.g. the four lights available in your scene.
  101438. * This impacts both the direct diffuse and specular highlights.
  101439. */
  101440. directIntensity: number;
  101441. /**
  101442. * Intensity of the emissive part of the material.
  101443. * This helps controlling the emissive effect without modifying the emissive color.
  101444. */
  101445. emissiveIntensity: number;
  101446. /**
  101447. * Intensity of the environment e.g. how much the environment will light the object
  101448. * either through harmonics for rough material or through the refelction for shiny ones.
  101449. */
  101450. environmentIntensity: number;
  101451. /**
  101452. * This is a special control allowing the reduction of the specular highlights coming from the
  101453. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101454. */
  101455. specularIntensity: number;
  101456. /**
  101457. * Debug Control allowing disabling the bump map on this material.
  101458. */
  101459. disableBumpMap: boolean;
  101460. /**
  101461. * AKA Diffuse Texture in standard nomenclature.
  101462. */
  101463. albedoTexture: BaseTexture;
  101464. /**
  101465. * AKA Occlusion Texture in other nomenclature.
  101466. */
  101467. ambientTexture: BaseTexture;
  101468. /**
  101469. * AKA Occlusion Texture Intensity in other nomenclature.
  101470. */
  101471. ambientTextureStrength: number;
  101472. /**
  101473. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101474. * 1 means it completely occludes it
  101475. * 0 mean it has no impact
  101476. */
  101477. ambientTextureImpactOnAnalyticalLights: number;
  101478. /**
  101479. * Stores the alpha values in a texture.
  101480. */
  101481. opacityTexture: BaseTexture;
  101482. /**
  101483. * Stores the reflection values in a texture.
  101484. */
  101485. reflectionTexture: Nullable<BaseTexture>;
  101486. /**
  101487. * Stores the emissive values in a texture.
  101488. */
  101489. emissiveTexture: BaseTexture;
  101490. /**
  101491. * AKA Specular texture in other nomenclature.
  101492. */
  101493. reflectivityTexture: BaseTexture;
  101494. /**
  101495. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101496. */
  101497. metallicTexture: BaseTexture;
  101498. /**
  101499. * Specifies the metallic scalar of the metallic/roughness workflow.
  101500. * Can also be used to scale the metalness values of the metallic texture.
  101501. */
  101502. metallic: Nullable<number>;
  101503. /**
  101504. * Specifies the roughness scalar of the metallic/roughness workflow.
  101505. * Can also be used to scale the roughness values of the metallic texture.
  101506. */
  101507. roughness: Nullable<number>;
  101508. /**
  101509. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101510. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101511. */
  101512. microSurfaceTexture: BaseTexture;
  101513. /**
  101514. * Stores surface normal data used to displace a mesh in a texture.
  101515. */
  101516. bumpTexture: BaseTexture;
  101517. /**
  101518. * Stores the pre-calculated light information of a mesh in a texture.
  101519. */
  101520. lightmapTexture: BaseTexture;
  101521. /**
  101522. * Stores the refracted light information in a texture.
  101523. */
  101524. refractionTexture: BaseTexture;
  101525. /**
  101526. * The color of a material in ambient lighting.
  101527. */
  101528. ambientColor: Color3;
  101529. /**
  101530. * AKA Diffuse Color in other nomenclature.
  101531. */
  101532. albedoColor: Color3;
  101533. /**
  101534. * AKA Specular Color in other nomenclature.
  101535. */
  101536. reflectivityColor: Color3;
  101537. /**
  101538. * The color reflected from the material.
  101539. */
  101540. reflectionColor: Color3;
  101541. /**
  101542. * The color emitted from the material.
  101543. */
  101544. emissiveColor: Color3;
  101545. /**
  101546. * AKA Glossiness in other nomenclature.
  101547. */
  101548. microSurface: number;
  101549. /**
  101550. * source material index of refraction (IOR)' / 'destination material IOR.
  101551. */
  101552. indexOfRefraction: number;
  101553. /**
  101554. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101555. */
  101556. invertRefractionY: boolean;
  101557. /**
  101558. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101559. * Materials half opaque for instance using refraction could benefit from this control.
  101560. */
  101561. linkRefractionWithTransparency: boolean;
  101562. /**
  101563. * If true, the light map contains occlusion information instead of lighting info.
  101564. */
  101565. useLightmapAsShadowmap: boolean;
  101566. /**
  101567. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101568. */
  101569. useAlphaFromAlbedoTexture: boolean;
  101570. /**
  101571. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101572. */
  101573. forceAlphaTest: boolean;
  101574. /**
  101575. * Defines the alpha limits in alpha test mode.
  101576. */
  101577. alphaCutOff: number;
  101578. /**
  101579. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101580. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101581. */
  101582. useSpecularOverAlpha: boolean;
  101583. /**
  101584. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101585. */
  101586. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101587. /**
  101588. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101589. */
  101590. useRoughnessFromMetallicTextureAlpha: boolean;
  101591. /**
  101592. * Specifies if the metallic texture contains the roughness information in its green channel.
  101593. */
  101594. useRoughnessFromMetallicTextureGreen: boolean;
  101595. /**
  101596. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101597. */
  101598. useMetallnessFromMetallicTextureBlue: boolean;
  101599. /**
  101600. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101601. */
  101602. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101603. /**
  101604. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101605. */
  101606. useAmbientInGrayScale: boolean;
  101607. /**
  101608. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101609. * The material will try to infer what glossiness each pixel should be.
  101610. */
  101611. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101612. /**
  101613. * BJS is using an harcoded light falloff based on a manually sets up range.
  101614. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101615. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101616. */
  101617. /**
  101618. * BJS is using an harcoded light falloff based on a manually sets up range.
  101619. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101620. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101621. */
  101622. usePhysicalLightFalloff: boolean;
  101623. /**
  101624. * In order to support the falloff compatibility with gltf, a special mode has been added
  101625. * to reproduce the gltf light falloff.
  101626. */
  101627. /**
  101628. * In order to support the falloff compatibility with gltf, a special mode has been added
  101629. * to reproduce the gltf light falloff.
  101630. */
  101631. useGLTFLightFalloff: boolean;
  101632. /**
  101633. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101634. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101635. */
  101636. useRadianceOverAlpha: boolean;
  101637. /**
  101638. * Allows using an object space normal map (instead of tangent space).
  101639. */
  101640. useObjectSpaceNormalMap: boolean;
  101641. /**
  101642. * Allows using the bump map in parallax mode.
  101643. */
  101644. useParallax: boolean;
  101645. /**
  101646. * Allows using the bump map in parallax occlusion mode.
  101647. */
  101648. useParallaxOcclusion: boolean;
  101649. /**
  101650. * Controls the scale bias of the parallax mode.
  101651. */
  101652. parallaxScaleBias: number;
  101653. /**
  101654. * If sets to true, disables all the lights affecting the material.
  101655. */
  101656. disableLighting: boolean;
  101657. /**
  101658. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101659. */
  101660. forceIrradianceInFragment: boolean;
  101661. /**
  101662. * Number of Simultaneous lights allowed on the material.
  101663. */
  101664. maxSimultaneousLights: number;
  101665. /**
  101666. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101667. */
  101668. invertNormalMapX: boolean;
  101669. /**
  101670. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101671. */
  101672. invertNormalMapY: boolean;
  101673. /**
  101674. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101675. */
  101676. twoSidedLighting: boolean;
  101677. /**
  101678. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101679. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101680. */
  101681. useAlphaFresnel: boolean;
  101682. /**
  101683. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101684. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101685. */
  101686. useLinearAlphaFresnel: boolean;
  101687. /**
  101688. * Let user defines the brdf lookup texture used for IBL.
  101689. * A default 8bit version is embedded but you could point at :
  101690. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101691. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101692. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101693. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101694. */
  101695. environmentBRDFTexture: Nullable<BaseTexture>;
  101696. /**
  101697. * Force normal to face away from face.
  101698. */
  101699. forceNormalForward: boolean;
  101700. /**
  101701. * Enables specular anti aliasing in the PBR shader.
  101702. * It will both interacts on the Geometry for analytical and IBL lighting.
  101703. * It also prefilter the roughness map based on the bump values.
  101704. */
  101705. enableSpecularAntiAliasing: boolean;
  101706. /**
  101707. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101708. * makes the reflect vector face the model (under horizon).
  101709. */
  101710. useHorizonOcclusion: boolean;
  101711. /**
  101712. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101713. * too much the area relying on ambient texture to define their ambient occlusion.
  101714. */
  101715. useRadianceOcclusion: boolean;
  101716. /**
  101717. * If set to true, no lighting calculations will be applied.
  101718. */
  101719. unlit: boolean;
  101720. /**
  101721. * Gets the image processing configuration used either in this material.
  101722. */
  101723. /**
  101724. * Sets the Default image processing configuration used either in the this material.
  101725. *
  101726. * If sets to null, the scene one is in use.
  101727. */
  101728. imageProcessingConfiguration: ImageProcessingConfiguration;
  101729. /**
  101730. * Gets wether the color curves effect is enabled.
  101731. */
  101732. /**
  101733. * Sets wether the color curves effect is enabled.
  101734. */
  101735. cameraColorCurvesEnabled: boolean;
  101736. /**
  101737. * Gets wether the color grading effect is enabled.
  101738. */
  101739. /**
  101740. * Gets wether the color grading effect is enabled.
  101741. */
  101742. cameraColorGradingEnabled: boolean;
  101743. /**
  101744. * Gets wether tonemapping is enabled or not.
  101745. */
  101746. /**
  101747. * Sets wether tonemapping is enabled or not
  101748. */
  101749. cameraToneMappingEnabled: boolean;
  101750. /**
  101751. * The camera exposure used on this material.
  101752. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101753. * This corresponds to a photographic exposure.
  101754. */
  101755. /**
  101756. * The camera exposure used on this material.
  101757. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101758. * This corresponds to a photographic exposure.
  101759. */
  101760. cameraExposure: number;
  101761. /**
  101762. * Gets The camera contrast used on this material.
  101763. */
  101764. /**
  101765. * Sets The camera contrast used on this material.
  101766. */
  101767. cameraContrast: number;
  101768. /**
  101769. * Gets the Color Grading 2D Lookup Texture.
  101770. */
  101771. /**
  101772. * Sets the Color Grading 2D Lookup Texture.
  101773. */
  101774. cameraColorGradingTexture: Nullable<BaseTexture>;
  101775. /**
  101776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101778. * 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;
  101779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101780. */
  101781. /**
  101782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101784. * 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;
  101785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101786. */
  101787. cameraColorCurves: Nullable<ColorCurves>;
  101788. /**
  101789. * Instantiates a new PBRMaterial instance.
  101790. *
  101791. * @param name The material name
  101792. * @param scene The scene the material will be use in.
  101793. */
  101794. constructor(name: string, scene: Scene);
  101795. /**
  101796. * Returns the name of this material class.
  101797. */
  101798. getClassName(): string;
  101799. /**
  101800. * Makes a duplicate of the current material.
  101801. * @param name - name to use for the new material.
  101802. */
  101803. clone(name: string): PBRMaterial;
  101804. /**
  101805. * Serializes this PBR Material.
  101806. * @returns - An object with the serialized material.
  101807. */
  101808. serialize(): any;
  101809. /**
  101810. * Parses a PBR Material from a serialized object.
  101811. * @param source - Serialized object.
  101812. * @param scene - BJS scene instance.
  101813. * @param rootUrl - url for the scene object
  101814. * @returns - PBRMaterial
  101815. */
  101816. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101817. }
  101818. }
  101819. declare module BABYLON {
  101820. /**
  101821. * Direct draw surface info
  101822. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  101823. */
  101824. export interface DDSInfo {
  101825. /**
  101826. * Width of the texture
  101827. */
  101828. width: number;
  101829. /**
  101830. * Width of the texture
  101831. */
  101832. height: number;
  101833. /**
  101834. * Number of Mipmaps for the texture
  101835. * @see https://en.wikipedia.org/wiki/Mipmap
  101836. */
  101837. mipmapCount: number;
  101838. /**
  101839. * If the textures format is a known fourCC format
  101840. * @see https://www.fourcc.org/
  101841. */
  101842. isFourCC: boolean;
  101843. /**
  101844. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  101845. */
  101846. isRGB: boolean;
  101847. /**
  101848. * If the texture is a lumincance format
  101849. */
  101850. isLuminance: boolean;
  101851. /**
  101852. * If this is a cube texture
  101853. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  101854. */
  101855. isCube: boolean;
  101856. /**
  101857. * If the texture is a compressed format eg. FOURCC_DXT1
  101858. */
  101859. isCompressed: boolean;
  101860. /**
  101861. * The dxgiFormat of the texture
  101862. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  101863. */
  101864. dxgiFormat: number;
  101865. /**
  101866. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  101867. */
  101868. textureType: number;
  101869. /**
  101870. * Sphericle polynomial created for the dds texture
  101871. */
  101872. sphericalPolynomial?: SphericalPolynomial;
  101873. }
  101874. /**
  101875. * Class used to provide DDS decompression tools
  101876. */
  101877. export class DDSTools {
  101878. /**
  101879. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  101880. */
  101881. static StoreLODInAlphaChannel: boolean;
  101882. /**
  101883. * Gets DDS information from an array buffer
  101884. * @param arrayBuffer defines the array buffer to read data from
  101885. * @returns the DDS information
  101886. */
  101887. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  101888. private static _FloatView;
  101889. private static _Int32View;
  101890. private static _ToHalfFloat;
  101891. private static _FromHalfFloat;
  101892. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  101893. private static _GetHalfFloatRGBAArrayBuffer;
  101894. private static _GetFloatRGBAArrayBuffer;
  101895. private static _GetFloatAsUIntRGBAArrayBuffer;
  101896. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  101897. private static _GetRGBAArrayBuffer;
  101898. private static _ExtractLongWordOrder;
  101899. private static _GetRGBArrayBuffer;
  101900. private static _GetLuminanceArrayBuffer;
  101901. /**
  101902. * Uploads DDS Levels to a Babylon Texture
  101903. * @hidden
  101904. */
  101905. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  101906. }
  101907. interface Engine {
  101908. /**
  101909. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  101910. * @param rootUrl defines the url where the file to load is located
  101911. * @param scene defines the current scene
  101912. * @param lodScale defines scale to apply to the mip map selection
  101913. * @param lodOffset defines offset to apply to the mip map selection
  101914. * @param onLoad defines an optional callback raised when the texture is loaded
  101915. * @param onError defines an optional callback raised if there is an issue to load the texture
  101916. * @param format defines the format of the data
  101917. * @param forcedExtension defines the extension to use to pick the right loader
  101918. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  101919. * @returns the cube texture as an InternalTexture
  101920. */
  101921. 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;
  101922. }
  101923. }
  101924. declare module BABYLON {
  101925. /**
  101926. * Implementation of the DDS Texture Loader.
  101927. * @hidden
  101928. */
  101929. export class _DDSTextureLoader implements IInternalTextureLoader {
  101930. /**
  101931. * Defines wether the loader supports cascade loading the different faces.
  101932. */
  101933. readonly supportCascades: boolean;
  101934. /**
  101935. * This returns if the loader support the current file information.
  101936. * @param extension defines the file extension of the file being loaded
  101937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101938. * @param fallback defines the fallback internal texture if any
  101939. * @param isBase64 defines whether the texture is encoded as a base64
  101940. * @param isBuffer defines whether the texture data are stored as a buffer
  101941. * @returns true if the loader can load the specified file
  101942. */
  101943. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101944. /**
  101945. * Transform the url before loading if required.
  101946. * @param rootUrl the url of the texture
  101947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101948. * @returns the transformed texture
  101949. */
  101950. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101951. /**
  101952. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101953. * @param rootUrl the url of the texture
  101954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101955. * @returns the fallback texture
  101956. */
  101957. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101958. /**
  101959. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101960. * @param data contains the texture data
  101961. * @param texture defines the BabylonJS internal texture
  101962. * @param createPolynomials will be true if polynomials have been requested
  101963. * @param onLoad defines the callback to trigger once the texture is ready
  101964. * @param onError defines the callback to trigger in case of error
  101965. */
  101966. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101967. /**
  101968. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101969. * @param data contains the texture data
  101970. * @param texture defines the BabylonJS internal texture
  101971. * @param callback defines the method to call once ready to upload
  101972. */
  101973. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  101974. }
  101975. }
  101976. declare module BABYLON {
  101977. /** @hidden */
  101978. export var rgbdEncodePixelShader: {
  101979. name: string;
  101980. shader: string;
  101981. };
  101982. }
  101983. declare module BABYLON {
  101984. /** @hidden */
  101985. export var rgbdDecodePixelShader: {
  101986. name: string;
  101987. shader: string;
  101988. };
  101989. }
  101990. declare module BABYLON {
  101991. /**
  101992. * Raw texture data and descriptor sufficient for WebGL texture upload
  101993. */
  101994. export interface EnvironmentTextureInfo {
  101995. /**
  101996. * Version of the environment map
  101997. */
  101998. version: number;
  101999. /**
  102000. * Width of image
  102001. */
  102002. width: number;
  102003. /**
  102004. * Irradiance information stored in the file.
  102005. */
  102006. irradiance: any;
  102007. /**
  102008. * Specular information stored in the file.
  102009. */
  102010. specular: any;
  102011. }
  102012. /**
  102013. * Sets of helpers addressing the serialization and deserialization of environment texture
  102014. * stored in a BabylonJS env file.
  102015. * Those files are usually stored as .env files.
  102016. */
  102017. export class EnvironmentTextureTools {
  102018. /**
  102019. * Magic number identifying the env file.
  102020. */
  102021. private static _MagicBytes;
  102022. /**
  102023. * Gets the environment info from an env file.
  102024. * @param data The array buffer containing the .env bytes.
  102025. * @returns the environment file info (the json header) if successfully parsed.
  102026. */
  102027. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102028. /**
  102029. * Creates an environment texture from a loaded cube texture.
  102030. * @param texture defines the cube texture to convert in env file
  102031. * @return a promise containing the environment data if succesfull.
  102032. */
  102033. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102034. /**
  102035. * Creates a JSON representation of the spherical data.
  102036. * @param texture defines the texture containing the polynomials
  102037. * @return the JSON representation of the spherical info
  102038. */
  102039. private static _CreateEnvTextureIrradiance;
  102040. /**
  102041. * Uploads the texture info contained in the env file to the GPU.
  102042. * @param texture defines the internal texture to upload to
  102043. * @param arrayBuffer defines the buffer cotaining the data to load
  102044. * @param info defines the texture info retrieved through the GetEnvInfo method
  102045. * @returns a promise
  102046. */
  102047. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102048. /**
  102049. * Uploads the levels of image data to the GPU.
  102050. * @param texture defines the internal texture to upload to
  102051. * @param imageData defines the array buffer views of image data [mipmap][face]
  102052. * @returns a promise
  102053. */
  102054. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102055. /**
  102056. * Uploads spherical polynomials information to the texture.
  102057. * @param texture defines the texture we are trying to upload the information to
  102058. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102059. */
  102060. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102061. /** @hidden */
  102062. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102063. }
  102064. }
  102065. declare module BABYLON {
  102066. /**
  102067. * Implementation of the ENV Texture Loader.
  102068. * @hidden
  102069. */
  102070. export class _ENVTextureLoader implements IInternalTextureLoader {
  102071. /**
  102072. * Defines wether the loader supports cascade loading the different faces.
  102073. */
  102074. readonly supportCascades: boolean;
  102075. /**
  102076. * This returns if the loader support the current file information.
  102077. * @param extension defines the file extension of the file being loaded
  102078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102079. * @param fallback defines the fallback internal texture if any
  102080. * @param isBase64 defines whether the texture is encoded as a base64
  102081. * @param isBuffer defines whether the texture data are stored as a buffer
  102082. * @returns true if the loader can load the specified file
  102083. */
  102084. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102085. /**
  102086. * Transform the url before loading if required.
  102087. * @param rootUrl the url of the texture
  102088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102089. * @returns the transformed texture
  102090. */
  102091. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102092. /**
  102093. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102094. * @param rootUrl the url of the texture
  102095. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102096. * @returns the fallback texture
  102097. */
  102098. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102099. /**
  102100. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102101. * @param data contains the texture data
  102102. * @param texture defines the BabylonJS internal texture
  102103. * @param createPolynomials will be true if polynomials have been requested
  102104. * @param onLoad defines the callback to trigger once the texture is ready
  102105. * @param onError defines the callback to trigger in case of error
  102106. */
  102107. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102108. /**
  102109. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102110. * @param data contains the texture data
  102111. * @param texture defines the BabylonJS internal texture
  102112. * @param callback defines the method to call once ready to upload
  102113. */
  102114. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102115. }
  102116. }
  102117. declare module BABYLON {
  102118. /**
  102119. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102120. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102121. */
  102122. export class KhronosTextureContainer {
  102123. /** contents of the KTX container file */
  102124. arrayBuffer: any;
  102125. private static HEADER_LEN;
  102126. private static COMPRESSED_2D;
  102127. private static COMPRESSED_3D;
  102128. private static TEX_2D;
  102129. private static TEX_3D;
  102130. /**
  102131. * Gets the openGL type
  102132. */
  102133. glType: number;
  102134. /**
  102135. * Gets the openGL type size
  102136. */
  102137. glTypeSize: number;
  102138. /**
  102139. * Gets the openGL format
  102140. */
  102141. glFormat: number;
  102142. /**
  102143. * Gets the openGL internal format
  102144. */
  102145. glInternalFormat: number;
  102146. /**
  102147. * Gets the base internal format
  102148. */
  102149. glBaseInternalFormat: number;
  102150. /**
  102151. * Gets image width in pixel
  102152. */
  102153. pixelWidth: number;
  102154. /**
  102155. * Gets image height in pixel
  102156. */
  102157. pixelHeight: number;
  102158. /**
  102159. * Gets image depth in pixels
  102160. */
  102161. pixelDepth: number;
  102162. /**
  102163. * Gets the number of array elements
  102164. */
  102165. numberOfArrayElements: number;
  102166. /**
  102167. * Gets the number of faces
  102168. */
  102169. numberOfFaces: number;
  102170. /**
  102171. * Gets the number of mipmap levels
  102172. */
  102173. numberOfMipmapLevels: number;
  102174. /**
  102175. * Gets the bytes of key value data
  102176. */
  102177. bytesOfKeyValueData: number;
  102178. /**
  102179. * Gets the load type
  102180. */
  102181. loadType: number;
  102182. /**
  102183. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102184. */
  102185. isInvalid: boolean;
  102186. /**
  102187. * Creates a new KhronosTextureContainer
  102188. * @param arrayBuffer contents of the KTX container file
  102189. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102190. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102191. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102192. */
  102193. constructor(
  102194. /** contents of the KTX container file */
  102195. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102196. /**
  102197. * Uploads KTX content to a Babylon Texture.
  102198. * It is assumed that the texture has already been created & is currently bound
  102199. * @hidden
  102200. */
  102201. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102202. private _upload2DCompressedLevels;
  102203. }
  102204. }
  102205. declare module BABYLON {
  102206. /**
  102207. * Implementation of the KTX Texture Loader.
  102208. * @hidden
  102209. */
  102210. export class _KTXTextureLoader implements IInternalTextureLoader {
  102211. /**
  102212. * Defines wether the loader supports cascade loading the different faces.
  102213. */
  102214. readonly supportCascades: boolean;
  102215. /**
  102216. * This returns if the loader support the current file information.
  102217. * @param extension defines the file extension of the file being loaded
  102218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102219. * @param fallback defines the fallback internal texture if any
  102220. * @param isBase64 defines whether the texture is encoded as a base64
  102221. * @param isBuffer defines whether the texture data are stored as a buffer
  102222. * @returns true if the loader can load the specified file
  102223. */
  102224. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102225. /**
  102226. * Transform the url before loading if required.
  102227. * @param rootUrl the url of the texture
  102228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102229. * @returns the transformed texture
  102230. */
  102231. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102232. /**
  102233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102234. * @param rootUrl the url of the texture
  102235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102236. * @returns the fallback texture
  102237. */
  102238. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102239. /**
  102240. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102241. * @param data contains the texture data
  102242. * @param texture defines the BabylonJS internal texture
  102243. * @param createPolynomials will be true if polynomials have been requested
  102244. * @param onLoad defines the callback to trigger once the texture is ready
  102245. * @param onError defines the callback to trigger in case of error
  102246. */
  102247. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102248. /**
  102249. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102250. * @param data contains the texture data
  102251. * @param texture defines the BabylonJS internal texture
  102252. * @param callback defines the method to call once ready to upload
  102253. */
  102254. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102255. }
  102256. }
  102257. declare module BABYLON {
  102258. /** @hidden */
  102259. export var _forceSceneHelpersToBundle: boolean;
  102260. interface Scene {
  102261. /**
  102262. * Creates a default light for the scene.
  102263. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102264. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102265. */
  102266. createDefaultLight(replace?: boolean): void;
  102267. /**
  102268. * Creates a default camera for the scene.
  102269. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102270. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102271. * @param replace has default false, when true replaces the active camera in the scene
  102272. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102273. */
  102274. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102275. /**
  102276. * Creates a default camera and a default light.
  102277. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102278. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102279. * @param replace has the default false, when true replaces the active camera/light in the scene
  102280. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102281. */
  102282. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102283. /**
  102284. * Creates a new sky box
  102285. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102286. * @param environmentTexture defines the texture to use as environment texture
  102287. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102288. * @param scale defines the overall scale of the skybox
  102289. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102290. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102291. * @returns a new mesh holding the sky box
  102292. */
  102293. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102294. /**
  102295. * Creates a new environment
  102296. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102297. * @param options defines the options you can use to configure the environment
  102298. * @returns the new EnvironmentHelper
  102299. */
  102300. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102301. /**
  102302. * Creates a new VREXperienceHelper
  102303. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102304. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102305. * @returns a new VREXperienceHelper
  102306. */
  102307. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102308. /**
  102309. * Creates a new XREXperienceHelper
  102310. * @see http://doc.babylonjs.com/how_to/webxr
  102311. * @returns a promise for a new XREXperienceHelper
  102312. */
  102313. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102314. }
  102315. }
  102316. declare module BABYLON {
  102317. /**
  102318. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102319. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102320. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102321. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102322. */
  102323. export class VideoDome extends TransformNode {
  102324. /**
  102325. * Define the video source as a Monoscopic panoramic 360 video.
  102326. */
  102327. static readonly MODE_MONOSCOPIC: number;
  102328. /**
  102329. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102330. */
  102331. static readonly MODE_TOPBOTTOM: number;
  102332. /**
  102333. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102334. */
  102335. static readonly MODE_SIDEBYSIDE: number;
  102336. private _useDirectMapping;
  102337. /**
  102338. * The video texture being displayed on the sphere
  102339. */
  102340. protected _videoTexture: VideoTexture;
  102341. /**
  102342. * Gets the video texture being displayed on the sphere
  102343. */
  102344. readonly videoTexture: VideoTexture;
  102345. /**
  102346. * The skybox material
  102347. */
  102348. protected _material: BackgroundMaterial;
  102349. /**
  102350. * The surface used for the skybox
  102351. */
  102352. protected _mesh: Mesh;
  102353. /**
  102354. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102355. * Also see the options.resolution property.
  102356. */
  102357. fovMultiplier: number;
  102358. private _videoMode;
  102359. /**
  102360. * Gets or set the current video mode for the video. It can be:
  102361. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102362. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102363. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102364. */
  102365. videoMode: number;
  102366. /**
  102367. * Oberserver used in Stereoscopic VR Mode.
  102368. */
  102369. private _onBeforeCameraRenderObserver;
  102370. /**
  102371. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102372. * @param name Element's name, child elements will append suffixes for their own names.
  102373. * @param urlsOrVideo defines the url(s) or the video element to use
  102374. * @param options An object containing optional or exposed sub element properties
  102375. */
  102376. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102377. resolution?: number;
  102378. clickToPlay?: boolean;
  102379. autoPlay?: boolean;
  102380. loop?: boolean;
  102381. size?: number;
  102382. poster?: string;
  102383. useDirectMapping?: boolean;
  102384. }, scene: Scene);
  102385. private _changeVideoMode;
  102386. /**
  102387. * Releases resources associated with this node.
  102388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102390. */
  102391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102392. }
  102393. }
  102394. declare module BABYLON {
  102395. /**
  102396. * This class can be used to get instrumentation data from a Babylon engine
  102397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102398. */
  102399. export class EngineInstrumentation implements IDisposable {
  102400. /**
  102401. * Define the instrumented engine.
  102402. */
  102403. engine: Engine;
  102404. private _captureGPUFrameTime;
  102405. private _gpuFrameTimeToken;
  102406. private _gpuFrameTime;
  102407. private _captureShaderCompilationTime;
  102408. private _shaderCompilationTime;
  102409. private _onBeginFrameObserver;
  102410. private _onEndFrameObserver;
  102411. private _onBeforeShaderCompilationObserver;
  102412. private _onAfterShaderCompilationObserver;
  102413. /**
  102414. * Gets the perf counter used for GPU frame time
  102415. */
  102416. readonly gpuFrameTimeCounter: PerfCounter;
  102417. /**
  102418. * Gets the GPU frame time capture status
  102419. */
  102420. /**
  102421. * Enable or disable the GPU frame time capture
  102422. */
  102423. captureGPUFrameTime: boolean;
  102424. /**
  102425. * Gets the perf counter used for shader compilation time
  102426. */
  102427. readonly shaderCompilationTimeCounter: PerfCounter;
  102428. /**
  102429. * Gets the shader compilation time capture status
  102430. */
  102431. /**
  102432. * Enable or disable the shader compilation time capture
  102433. */
  102434. captureShaderCompilationTime: boolean;
  102435. /**
  102436. * Instantiates a new engine instrumentation.
  102437. * This class can be used to get instrumentation data from a Babylon engine
  102438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102439. * @param engine Defines the engine to instrument
  102440. */
  102441. constructor(
  102442. /**
  102443. * Define the instrumented engine.
  102444. */
  102445. engine: Engine);
  102446. /**
  102447. * Dispose and release associated resources.
  102448. */
  102449. dispose(): void;
  102450. }
  102451. }
  102452. declare module BABYLON {
  102453. /**
  102454. * This class can be used to get instrumentation data from a Babylon engine
  102455. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102456. */
  102457. export class SceneInstrumentation implements IDisposable {
  102458. /**
  102459. * Defines the scene to instrument
  102460. */
  102461. scene: Scene;
  102462. private _captureActiveMeshesEvaluationTime;
  102463. private _activeMeshesEvaluationTime;
  102464. private _captureRenderTargetsRenderTime;
  102465. private _renderTargetsRenderTime;
  102466. private _captureFrameTime;
  102467. private _frameTime;
  102468. private _captureRenderTime;
  102469. private _renderTime;
  102470. private _captureInterFrameTime;
  102471. private _interFrameTime;
  102472. private _captureParticlesRenderTime;
  102473. private _particlesRenderTime;
  102474. private _captureSpritesRenderTime;
  102475. private _spritesRenderTime;
  102476. private _capturePhysicsTime;
  102477. private _physicsTime;
  102478. private _captureAnimationsTime;
  102479. private _animationsTime;
  102480. private _captureCameraRenderTime;
  102481. private _cameraRenderTime;
  102482. private _onBeforeActiveMeshesEvaluationObserver;
  102483. private _onAfterActiveMeshesEvaluationObserver;
  102484. private _onBeforeRenderTargetsRenderObserver;
  102485. private _onAfterRenderTargetsRenderObserver;
  102486. private _onAfterRenderObserver;
  102487. private _onBeforeDrawPhaseObserver;
  102488. private _onAfterDrawPhaseObserver;
  102489. private _onBeforeAnimationsObserver;
  102490. private _onBeforeParticlesRenderingObserver;
  102491. private _onAfterParticlesRenderingObserver;
  102492. private _onBeforeSpritesRenderingObserver;
  102493. private _onAfterSpritesRenderingObserver;
  102494. private _onBeforePhysicsObserver;
  102495. private _onAfterPhysicsObserver;
  102496. private _onAfterAnimationsObserver;
  102497. private _onBeforeCameraRenderObserver;
  102498. private _onAfterCameraRenderObserver;
  102499. /**
  102500. * Gets the perf counter used for active meshes evaluation time
  102501. */
  102502. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102503. /**
  102504. * Gets the active meshes evaluation time capture status
  102505. */
  102506. /**
  102507. * Enable or disable the active meshes evaluation time capture
  102508. */
  102509. captureActiveMeshesEvaluationTime: boolean;
  102510. /**
  102511. * Gets the perf counter used for render targets render time
  102512. */
  102513. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102514. /**
  102515. * Gets the render targets render time capture status
  102516. */
  102517. /**
  102518. * Enable or disable the render targets render time capture
  102519. */
  102520. captureRenderTargetsRenderTime: boolean;
  102521. /**
  102522. * Gets the perf counter used for particles render time
  102523. */
  102524. readonly particlesRenderTimeCounter: PerfCounter;
  102525. /**
  102526. * Gets the particles render time capture status
  102527. */
  102528. /**
  102529. * Enable or disable the particles render time capture
  102530. */
  102531. captureParticlesRenderTime: boolean;
  102532. /**
  102533. * Gets the perf counter used for sprites render time
  102534. */
  102535. readonly spritesRenderTimeCounter: PerfCounter;
  102536. /**
  102537. * Gets the sprites render time capture status
  102538. */
  102539. /**
  102540. * Enable or disable the sprites render time capture
  102541. */
  102542. captureSpritesRenderTime: boolean;
  102543. /**
  102544. * Gets the perf counter used for physics time
  102545. */
  102546. readonly physicsTimeCounter: PerfCounter;
  102547. /**
  102548. * Gets the physics time capture status
  102549. */
  102550. /**
  102551. * Enable or disable the physics time capture
  102552. */
  102553. capturePhysicsTime: boolean;
  102554. /**
  102555. * Gets the perf counter used for animations time
  102556. */
  102557. readonly animationsTimeCounter: PerfCounter;
  102558. /**
  102559. * Gets the animations time capture status
  102560. */
  102561. /**
  102562. * Enable or disable the animations time capture
  102563. */
  102564. captureAnimationsTime: boolean;
  102565. /**
  102566. * Gets the perf counter used for frame time capture
  102567. */
  102568. readonly frameTimeCounter: PerfCounter;
  102569. /**
  102570. * Gets the frame time capture status
  102571. */
  102572. /**
  102573. * Enable or disable the frame time capture
  102574. */
  102575. captureFrameTime: boolean;
  102576. /**
  102577. * Gets the perf counter used for inter-frames time capture
  102578. */
  102579. readonly interFrameTimeCounter: PerfCounter;
  102580. /**
  102581. * Gets the inter-frames time capture status
  102582. */
  102583. /**
  102584. * Enable or disable the inter-frames time capture
  102585. */
  102586. captureInterFrameTime: boolean;
  102587. /**
  102588. * Gets the perf counter used for render time capture
  102589. */
  102590. readonly renderTimeCounter: PerfCounter;
  102591. /**
  102592. * Gets the render time capture status
  102593. */
  102594. /**
  102595. * Enable or disable the render time capture
  102596. */
  102597. captureRenderTime: boolean;
  102598. /**
  102599. * Gets the perf counter used for camera render time capture
  102600. */
  102601. readonly cameraRenderTimeCounter: PerfCounter;
  102602. /**
  102603. * Gets the camera render time capture status
  102604. */
  102605. /**
  102606. * Enable or disable the camera render time capture
  102607. */
  102608. captureCameraRenderTime: boolean;
  102609. /**
  102610. * Gets the perf counter used for draw calls
  102611. */
  102612. readonly drawCallsCounter: PerfCounter;
  102613. /**
  102614. * Gets the perf counter used for texture collisions
  102615. */
  102616. readonly textureCollisionsCounter: PerfCounter;
  102617. /**
  102618. * Instantiates a new scene instrumentation.
  102619. * This class can be used to get instrumentation data from a Babylon engine
  102620. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102621. * @param scene Defines the scene to instrument
  102622. */
  102623. constructor(
  102624. /**
  102625. * Defines the scene to instrument
  102626. */
  102627. scene: Scene);
  102628. /**
  102629. * Dispose and release associated resources.
  102630. */
  102631. dispose(): void;
  102632. }
  102633. }
  102634. declare module BABYLON {
  102635. /** @hidden */
  102636. export var glowMapGenerationPixelShader: {
  102637. name: string;
  102638. shader: string;
  102639. };
  102640. }
  102641. declare module BABYLON {
  102642. /** @hidden */
  102643. export var glowMapGenerationVertexShader: {
  102644. name: string;
  102645. shader: string;
  102646. };
  102647. }
  102648. declare module BABYLON {
  102649. /**
  102650. * Effect layer options. This helps customizing the behaviour
  102651. * of the effect layer.
  102652. */
  102653. export interface IEffectLayerOptions {
  102654. /**
  102655. * Multiplication factor apply to the canvas size to compute the render target size
  102656. * used to generated the objects (the smaller the faster).
  102657. */
  102658. mainTextureRatio: number;
  102659. /**
  102660. * Enforces a fixed size texture to ensure effect stability across devices.
  102661. */
  102662. mainTextureFixedSize?: number;
  102663. /**
  102664. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102665. */
  102666. alphaBlendingMode: number;
  102667. /**
  102668. * The camera attached to the layer.
  102669. */
  102670. camera: Nullable<Camera>;
  102671. /**
  102672. * The rendering group to draw the layer in.
  102673. */
  102674. renderingGroupId: number;
  102675. }
  102676. /**
  102677. * The effect layer Helps adding post process effect blended with the main pass.
  102678. *
  102679. * This can be for instance use to generate glow or higlight effects on the scene.
  102680. *
  102681. * The effect layer class can not be used directly and is intented to inherited from to be
  102682. * customized per effects.
  102683. */
  102684. export abstract class EffectLayer {
  102685. private _vertexBuffers;
  102686. private _indexBuffer;
  102687. private _cachedDefines;
  102688. private _effectLayerMapGenerationEffect;
  102689. private _effectLayerOptions;
  102690. private _mergeEffect;
  102691. protected _scene: Scene;
  102692. protected _engine: Engine;
  102693. protected _maxSize: number;
  102694. protected _mainTextureDesiredSize: ISize;
  102695. protected _mainTexture: RenderTargetTexture;
  102696. protected _shouldRender: boolean;
  102697. protected _postProcesses: PostProcess[];
  102698. protected _textures: BaseTexture[];
  102699. protected _emissiveTextureAndColor: {
  102700. texture: Nullable<BaseTexture>;
  102701. color: Color4;
  102702. };
  102703. /**
  102704. * The name of the layer
  102705. */
  102706. name: string;
  102707. /**
  102708. * The clear color of the texture used to generate the glow map.
  102709. */
  102710. neutralColor: Color4;
  102711. /**
  102712. * Specifies wether the highlight layer is enabled or not.
  102713. */
  102714. isEnabled: boolean;
  102715. /**
  102716. * Gets the camera attached to the layer.
  102717. */
  102718. readonly camera: Nullable<Camera>;
  102719. /**
  102720. * Gets the rendering group id the layer should render in.
  102721. */
  102722. readonly renderingGroupId: number;
  102723. /**
  102724. * An event triggered when the effect layer has been disposed.
  102725. */
  102726. onDisposeObservable: Observable<EffectLayer>;
  102727. /**
  102728. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102729. */
  102730. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102731. /**
  102732. * An event triggered when the generated texture is being merged in the scene.
  102733. */
  102734. onBeforeComposeObservable: Observable<EffectLayer>;
  102735. /**
  102736. * An event triggered when the generated texture has been merged in the scene.
  102737. */
  102738. onAfterComposeObservable: Observable<EffectLayer>;
  102739. /**
  102740. * An event triggered when the efffect layer changes its size.
  102741. */
  102742. onSizeChangedObservable: Observable<EffectLayer>;
  102743. /** @hidden */
  102744. static _SceneComponentInitialization: (scene: Scene) => void;
  102745. /**
  102746. * Instantiates a new effect Layer and references it in the scene.
  102747. * @param name The name of the layer
  102748. * @param scene The scene to use the layer in
  102749. */
  102750. constructor(
  102751. /** The Friendly of the effect in the scene */
  102752. name: string, scene: Scene);
  102753. /**
  102754. * Get the effect name of the layer.
  102755. * @return The effect name
  102756. */
  102757. abstract getEffectName(): string;
  102758. /**
  102759. * Checks for the readiness of the element composing the layer.
  102760. * @param subMesh the mesh to check for
  102761. * @param useInstances specify wether or not to use instances to render the mesh
  102762. * @return true if ready otherwise, false
  102763. */
  102764. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102765. /**
  102766. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102767. * @returns true if the effect requires stencil during the main canvas render pass.
  102768. */
  102769. abstract needStencil(): boolean;
  102770. /**
  102771. * Create the merge effect. This is the shader use to blit the information back
  102772. * to the main canvas at the end of the scene rendering.
  102773. * @returns The effect containing the shader used to merge the effect on the main canvas
  102774. */
  102775. protected abstract _createMergeEffect(): Effect;
  102776. /**
  102777. * Creates the render target textures and post processes used in the effect layer.
  102778. */
  102779. protected abstract _createTextureAndPostProcesses(): void;
  102780. /**
  102781. * Implementation specific of rendering the generating effect on the main canvas.
  102782. * @param effect The effect used to render through
  102783. */
  102784. protected abstract _internalRender(effect: Effect): void;
  102785. /**
  102786. * Sets the required values for both the emissive texture and and the main color.
  102787. */
  102788. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102789. /**
  102790. * Free any resources and references associated to a mesh.
  102791. * Internal use
  102792. * @param mesh The mesh to free.
  102793. */
  102794. abstract _disposeMesh(mesh: Mesh): void;
  102795. /**
  102796. * Serializes this layer (Glow or Highlight for example)
  102797. * @returns a serialized layer object
  102798. */
  102799. abstract serialize?(): any;
  102800. /**
  102801. * Initializes the effect layer with the required options.
  102802. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102803. */
  102804. protected _init(options: Partial<IEffectLayerOptions>): void;
  102805. /**
  102806. * Generates the index buffer of the full screen quad blending to the main canvas.
  102807. */
  102808. private _generateIndexBuffer;
  102809. /**
  102810. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  102811. */
  102812. private _genrateVertexBuffer;
  102813. /**
  102814. * Sets the main texture desired size which is the closest power of two
  102815. * of the engine canvas size.
  102816. */
  102817. private _setMainTextureSize;
  102818. /**
  102819. * Creates the main texture for the effect layer.
  102820. */
  102821. protected _createMainTexture(): void;
  102822. /**
  102823. * Adds specific effects defines.
  102824. * @param defines The defines to add specifics to.
  102825. */
  102826. protected _addCustomEffectDefines(defines: string[]): void;
  102827. /**
  102828. * Checks for the readiness of the element composing the layer.
  102829. * @param subMesh the mesh to check for
  102830. * @param useInstances specify wether or not to use instances to render the mesh
  102831. * @param emissiveTexture the associated emissive texture used to generate the glow
  102832. * @return true if ready otherwise, false
  102833. */
  102834. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  102835. /**
  102836. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  102837. */
  102838. render(): void;
  102839. /**
  102840. * Determine if a given mesh will be used in the current effect.
  102841. * @param mesh mesh to test
  102842. * @returns true if the mesh will be used
  102843. */
  102844. hasMesh(mesh: AbstractMesh): boolean;
  102845. /**
  102846. * Returns true if the layer contains information to display, otherwise false.
  102847. * @returns true if the glow layer should be rendered
  102848. */
  102849. shouldRender(): boolean;
  102850. /**
  102851. * Returns true if the mesh should render, otherwise false.
  102852. * @param mesh The mesh to render
  102853. * @returns true if it should render otherwise false
  102854. */
  102855. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  102856. /**
  102857. * Returns true if the mesh can be rendered, otherwise false.
  102858. * @param mesh The mesh to render
  102859. * @param material The material used on the mesh
  102860. * @returns true if it can be rendered otherwise false
  102861. */
  102862. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102863. /**
  102864. * Returns true if the mesh should render, otherwise false.
  102865. * @param mesh The mesh to render
  102866. * @returns true if it should render otherwise false
  102867. */
  102868. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  102869. /**
  102870. * Renders the submesh passed in parameter to the generation map.
  102871. */
  102872. protected _renderSubMesh(subMesh: SubMesh): void;
  102873. /**
  102874. * Rebuild the required buffers.
  102875. * @hidden Internal use only.
  102876. */
  102877. _rebuild(): void;
  102878. /**
  102879. * Dispose only the render target textures and post process.
  102880. */
  102881. private _disposeTextureAndPostProcesses;
  102882. /**
  102883. * Dispose the highlight layer and free resources.
  102884. */
  102885. dispose(): void;
  102886. /**
  102887. * Gets the class name of the effect layer
  102888. * @returns the string with the class name of the effect layer
  102889. */
  102890. getClassName(): string;
  102891. /**
  102892. * Creates an effect layer from parsed effect layer data
  102893. * @param parsedEffectLayer defines effect layer data
  102894. * @param scene defines the current scene
  102895. * @param rootUrl defines the root URL containing the effect layer information
  102896. * @returns a parsed effect Layer
  102897. */
  102898. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102899. }
  102900. }
  102901. declare module BABYLON {
  102902. interface AbstractScene {
  102903. /**
  102904. * The list of effect layers (highlights/glow) added to the scene
  102905. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102906. * @see http://doc.babylonjs.com/how_to/glow_layer
  102907. */
  102908. effectLayers: Array<EffectLayer>;
  102909. /**
  102910. * Removes the given effect layer from this scene.
  102911. * @param toRemove defines the effect layer to remove
  102912. * @returns the index of the removed effect layer
  102913. */
  102914. removeEffectLayer(toRemove: EffectLayer): number;
  102915. /**
  102916. * Adds the given effect layer to this scene
  102917. * @param newEffectLayer defines the effect layer to add
  102918. */
  102919. addEffectLayer(newEffectLayer: EffectLayer): void;
  102920. }
  102921. /**
  102922. * Defines the layer scene component responsible to manage any effect layers
  102923. * in a given scene.
  102924. */
  102925. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102926. /**
  102927. * The component name helpfull to identify the component in the list of scene components.
  102928. */
  102929. readonly name: string;
  102930. /**
  102931. * The scene the component belongs to.
  102932. */
  102933. scene: Scene;
  102934. private _engine;
  102935. private _renderEffects;
  102936. private _needStencil;
  102937. private _previousStencilState;
  102938. /**
  102939. * Creates a new instance of the component for the given scene
  102940. * @param scene Defines the scene to register the component in
  102941. */
  102942. constructor(scene: Scene);
  102943. /**
  102944. * Registers the component in a given scene
  102945. */
  102946. register(): void;
  102947. /**
  102948. * Rebuilds the elements related to this component in case of
  102949. * context lost for instance.
  102950. */
  102951. rebuild(): void;
  102952. /**
  102953. * Serializes the component data to the specified json object
  102954. * @param serializationObject The object to serialize to
  102955. */
  102956. serialize(serializationObject: any): void;
  102957. /**
  102958. * Adds all the element from the container to the scene
  102959. * @param container the container holding the elements
  102960. */
  102961. addFromContainer(container: AbstractScene): void;
  102962. /**
  102963. * Removes all the elements in the container from the scene
  102964. * @param container contains the elements to remove
  102965. */
  102966. removeFromContainer(container: AbstractScene): void;
  102967. /**
  102968. * Disposes the component and the associated ressources.
  102969. */
  102970. dispose(): void;
  102971. private _isReadyForMesh;
  102972. private _renderMainTexture;
  102973. private _setStencil;
  102974. private _setStencilBack;
  102975. private _draw;
  102976. private _drawCamera;
  102977. private _drawRenderingGroup;
  102978. }
  102979. }
  102980. declare module BABYLON {
  102981. /** @hidden */
  102982. export var glowMapMergePixelShader: {
  102983. name: string;
  102984. shader: string;
  102985. };
  102986. }
  102987. declare module BABYLON {
  102988. /** @hidden */
  102989. export var glowMapMergeVertexShader: {
  102990. name: string;
  102991. shader: string;
  102992. };
  102993. }
  102994. declare module BABYLON {
  102995. interface AbstractScene {
  102996. /**
  102997. * Return a the first highlight layer of the scene with a given name.
  102998. * @param name The name of the highlight layer to look for.
  102999. * @return The highlight layer if found otherwise null.
  103000. */
  103001. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  103002. }
  103003. /**
  103004. * Glow layer options. This helps customizing the behaviour
  103005. * of the glow layer.
  103006. */
  103007. export interface IGlowLayerOptions {
  103008. /**
  103009. * Multiplication factor apply to the canvas size to compute the render target size
  103010. * used to generated the glowing objects (the smaller the faster).
  103011. */
  103012. mainTextureRatio: number;
  103013. /**
  103014. * Enforces a fixed size texture to ensure resize independant blur.
  103015. */
  103016. mainTextureFixedSize?: number;
  103017. /**
  103018. * How big is the kernel of the blur texture.
  103019. */
  103020. blurKernelSize: number;
  103021. /**
  103022. * The camera attached to the layer.
  103023. */
  103024. camera: Nullable<Camera>;
  103025. /**
  103026. * Enable MSAA by chosing the number of samples.
  103027. */
  103028. mainTextureSamples?: number;
  103029. /**
  103030. * The rendering group to draw the layer in.
  103031. */
  103032. renderingGroupId: number;
  103033. }
  103034. /**
  103035. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103036. *
  103037. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103038. * glowy meshes to your scene.
  103039. *
  103040. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103041. */
  103042. export class GlowLayer extends EffectLayer {
  103043. /**
  103044. * Effect Name of the layer.
  103045. */
  103046. static readonly EffectName: string;
  103047. /**
  103048. * The default blur kernel size used for the glow.
  103049. */
  103050. static DefaultBlurKernelSize: number;
  103051. /**
  103052. * The default texture size ratio used for the glow.
  103053. */
  103054. static DefaultTextureRatio: number;
  103055. /**
  103056. * Sets the kernel size of the blur.
  103057. */
  103058. /**
  103059. * Gets the kernel size of the blur.
  103060. */
  103061. blurKernelSize: number;
  103062. /**
  103063. * Sets the glow intensity.
  103064. */
  103065. /**
  103066. * Gets the glow intensity.
  103067. */
  103068. intensity: number;
  103069. private _options;
  103070. private _intensity;
  103071. private _horizontalBlurPostprocess1;
  103072. private _verticalBlurPostprocess1;
  103073. private _horizontalBlurPostprocess2;
  103074. private _verticalBlurPostprocess2;
  103075. private _blurTexture1;
  103076. private _blurTexture2;
  103077. private _postProcesses1;
  103078. private _postProcesses2;
  103079. private _includedOnlyMeshes;
  103080. private _excludedMeshes;
  103081. /**
  103082. * Callback used to let the user override the color selection on a per mesh basis
  103083. */
  103084. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103085. /**
  103086. * Callback used to let the user override the texture selection on a per mesh basis
  103087. */
  103088. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103089. /**
  103090. * Instantiates a new glow Layer and references it to the scene.
  103091. * @param name The name of the layer
  103092. * @param scene The scene to use the layer in
  103093. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103094. */
  103095. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103096. /**
  103097. * Get the effect name of the layer.
  103098. * @return The effect name
  103099. */
  103100. getEffectName(): string;
  103101. /**
  103102. * Create the merge effect. This is the shader use to blit the information back
  103103. * to the main canvas at the end of the scene rendering.
  103104. */
  103105. protected _createMergeEffect(): Effect;
  103106. /**
  103107. * Creates the render target textures and post processes used in the glow layer.
  103108. */
  103109. protected _createTextureAndPostProcesses(): void;
  103110. /**
  103111. * Checks for the readiness of the element composing the layer.
  103112. * @param subMesh the mesh to check for
  103113. * @param useInstances specify wether or not to use instances to render the mesh
  103114. * @param emissiveTexture the associated emissive texture used to generate the glow
  103115. * @return true if ready otherwise, false
  103116. */
  103117. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103118. /**
  103119. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103120. */
  103121. needStencil(): boolean;
  103122. /**
  103123. * Returns true if the mesh can be rendered, otherwise false.
  103124. * @param mesh The mesh to render
  103125. * @param material The material used on the mesh
  103126. * @returns true if it can be rendered otherwise false
  103127. */
  103128. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103129. /**
  103130. * Implementation specific of rendering the generating effect on the main canvas.
  103131. * @param effect The effect used to render through
  103132. */
  103133. protected _internalRender(effect: Effect): void;
  103134. /**
  103135. * Sets the required values for both the emissive texture and and the main color.
  103136. */
  103137. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103138. /**
  103139. * Returns true if the mesh should render, otherwise false.
  103140. * @param mesh The mesh to render
  103141. * @returns true if it should render otherwise false
  103142. */
  103143. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103144. /**
  103145. * Adds specific effects defines.
  103146. * @param defines The defines to add specifics to.
  103147. */
  103148. protected _addCustomEffectDefines(defines: string[]): void;
  103149. /**
  103150. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103151. * @param mesh The mesh to exclude from the glow layer
  103152. */
  103153. addExcludedMesh(mesh: Mesh): void;
  103154. /**
  103155. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103156. * @param mesh The mesh to remove
  103157. */
  103158. removeExcludedMesh(mesh: Mesh): void;
  103159. /**
  103160. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103161. * @param mesh The mesh to include in the glow layer
  103162. */
  103163. addIncludedOnlyMesh(mesh: Mesh): void;
  103164. /**
  103165. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103166. * @param mesh The mesh to remove
  103167. */
  103168. removeIncludedOnlyMesh(mesh: Mesh): void;
  103169. /**
  103170. * Determine if a given mesh will be used in the glow layer
  103171. * @param mesh The mesh to test
  103172. * @returns true if the mesh will be highlighted by the current glow layer
  103173. */
  103174. hasMesh(mesh: AbstractMesh): boolean;
  103175. /**
  103176. * Free any resources and references associated to a mesh.
  103177. * Internal use
  103178. * @param mesh The mesh to free.
  103179. * @hidden
  103180. */
  103181. _disposeMesh(mesh: Mesh): void;
  103182. /**
  103183. * Gets the class name of the effect layer
  103184. * @returns the string with the class name of the effect layer
  103185. */
  103186. getClassName(): string;
  103187. /**
  103188. * Serializes this glow layer
  103189. * @returns a serialized glow layer object
  103190. */
  103191. serialize(): any;
  103192. /**
  103193. * Creates a Glow Layer from parsed glow layer data
  103194. * @param parsedGlowLayer defines glow layer data
  103195. * @param scene defines the current scene
  103196. * @param rootUrl defines the root URL containing the glow layer information
  103197. * @returns a parsed Glow Layer
  103198. */
  103199. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103200. }
  103201. }
  103202. declare module BABYLON {
  103203. /** @hidden */
  103204. export var glowBlurPostProcessPixelShader: {
  103205. name: string;
  103206. shader: string;
  103207. };
  103208. }
  103209. declare module BABYLON {
  103210. interface AbstractScene {
  103211. /**
  103212. * Return a the first highlight layer of the scene with a given name.
  103213. * @param name The name of the highlight layer to look for.
  103214. * @return The highlight layer if found otherwise null.
  103215. */
  103216. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103217. }
  103218. /**
  103219. * Highlight layer options. This helps customizing the behaviour
  103220. * of the highlight layer.
  103221. */
  103222. export interface IHighlightLayerOptions {
  103223. /**
  103224. * Multiplication factor apply to the canvas size to compute the render target size
  103225. * used to generated the glowing objects (the smaller the faster).
  103226. */
  103227. mainTextureRatio: number;
  103228. /**
  103229. * Enforces a fixed size texture to ensure resize independant blur.
  103230. */
  103231. mainTextureFixedSize?: number;
  103232. /**
  103233. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103234. * of the picture to blur (the smaller the faster).
  103235. */
  103236. blurTextureSizeRatio: number;
  103237. /**
  103238. * How big in texel of the blur texture is the vertical blur.
  103239. */
  103240. blurVerticalSize: number;
  103241. /**
  103242. * How big in texel of the blur texture is the horizontal blur.
  103243. */
  103244. blurHorizontalSize: number;
  103245. /**
  103246. * Alpha blending mode used to apply the blur. Default is combine.
  103247. */
  103248. alphaBlendingMode: number;
  103249. /**
  103250. * The camera attached to the layer.
  103251. */
  103252. camera: Nullable<Camera>;
  103253. /**
  103254. * Should we display highlight as a solid stroke?
  103255. */
  103256. isStroke?: boolean;
  103257. /**
  103258. * The rendering group to draw the layer in.
  103259. */
  103260. renderingGroupId: number;
  103261. }
  103262. /**
  103263. * The highlight layer Helps adding a glow effect around a mesh.
  103264. *
  103265. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103266. * glowy meshes to your scene.
  103267. *
  103268. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103269. */
  103270. export class HighlightLayer extends EffectLayer {
  103271. name: string;
  103272. /**
  103273. * Effect Name of the highlight layer.
  103274. */
  103275. static readonly EffectName: string;
  103276. /**
  103277. * The neutral color used during the preparation of the glow effect.
  103278. * This is black by default as the blend operation is a blend operation.
  103279. */
  103280. static NeutralColor: Color4;
  103281. /**
  103282. * Stencil value used for glowing meshes.
  103283. */
  103284. static GlowingMeshStencilReference: number;
  103285. /**
  103286. * Stencil value used for the other meshes in the scene.
  103287. */
  103288. static NormalMeshStencilReference: number;
  103289. /**
  103290. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103291. */
  103292. innerGlow: boolean;
  103293. /**
  103294. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103295. */
  103296. outerGlow: boolean;
  103297. /**
  103298. * Specifies the horizontal size of the blur.
  103299. */
  103300. /**
  103301. * Gets the horizontal size of the blur.
  103302. */
  103303. blurHorizontalSize: number;
  103304. /**
  103305. * Specifies the vertical size of the blur.
  103306. */
  103307. /**
  103308. * Gets the vertical size of the blur.
  103309. */
  103310. blurVerticalSize: number;
  103311. /**
  103312. * An event triggered when the highlight layer is being blurred.
  103313. */
  103314. onBeforeBlurObservable: Observable<HighlightLayer>;
  103315. /**
  103316. * An event triggered when the highlight layer has been blurred.
  103317. */
  103318. onAfterBlurObservable: Observable<HighlightLayer>;
  103319. private _instanceGlowingMeshStencilReference;
  103320. private _options;
  103321. private _downSamplePostprocess;
  103322. private _horizontalBlurPostprocess;
  103323. private _verticalBlurPostprocess;
  103324. private _blurTexture;
  103325. private _meshes;
  103326. private _excludedMeshes;
  103327. /**
  103328. * Instantiates a new highlight Layer and references it to the scene..
  103329. * @param name The name of the layer
  103330. * @param scene The scene to use the layer in
  103331. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103332. */
  103333. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103334. /**
  103335. * Get the effect name of the layer.
  103336. * @return The effect name
  103337. */
  103338. getEffectName(): string;
  103339. /**
  103340. * Create the merge effect. This is the shader use to blit the information back
  103341. * to the main canvas at the end of the scene rendering.
  103342. */
  103343. protected _createMergeEffect(): Effect;
  103344. /**
  103345. * Creates the render target textures and post processes used in the highlight layer.
  103346. */
  103347. protected _createTextureAndPostProcesses(): void;
  103348. /**
  103349. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103350. */
  103351. needStencil(): boolean;
  103352. /**
  103353. * Checks for the readiness of the element composing the layer.
  103354. * @param subMesh the mesh to check for
  103355. * @param useInstances specify wether or not to use instances to render the mesh
  103356. * @param emissiveTexture the associated emissive texture used to generate the glow
  103357. * @return true if ready otherwise, false
  103358. */
  103359. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103360. /**
  103361. * Implementation specific of rendering the generating effect on the main canvas.
  103362. * @param effect The effect used to render through
  103363. */
  103364. protected _internalRender(effect: Effect): void;
  103365. /**
  103366. * Returns true if the layer contains information to display, otherwise false.
  103367. */
  103368. shouldRender(): boolean;
  103369. /**
  103370. * Returns true if the mesh should render, otherwise false.
  103371. * @param mesh The mesh to render
  103372. * @returns true if it should render otherwise false
  103373. */
  103374. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103375. /**
  103376. * Sets the required values for both the emissive texture and and the main color.
  103377. */
  103378. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103379. /**
  103380. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103381. * @param mesh The mesh to exclude from the highlight layer
  103382. */
  103383. addExcludedMesh(mesh: Mesh): void;
  103384. /**
  103385. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103386. * @param mesh The mesh to highlight
  103387. */
  103388. removeExcludedMesh(mesh: Mesh): void;
  103389. /**
  103390. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103391. * @param mesh mesh to test
  103392. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103393. */
  103394. hasMesh(mesh: AbstractMesh): boolean;
  103395. /**
  103396. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103397. * @param mesh The mesh to highlight
  103398. * @param color The color of the highlight
  103399. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103400. */
  103401. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103402. /**
  103403. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103404. * @param mesh The mesh to highlight
  103405. */
  103406. removeMesh(mesh: Mesh): void;
  103407. /**
  103408. * Force the stencil to the normal expected value for none glowing parts
  103409. */
  103410. private _defaultStencilReference;
  103411. /**
  103412. * Free any resources and references associated to a mesh.
  103413. * Internal use
  103414. * @param mesh The mesh to free.
  103415. * @hidden
  103416. */
  103417. _disposeMesh(mesh: Mesh): void;
  103418. /**
  103419. * Dispose the highlight layer and free resources.
  103420. */
  103421. dispose(): void;
  103422. /**
  103423. * Gets the class name of the effect layer
  103424. * @returns the string with the class name of the effect layer
  103425. */
  103426. getClassName(): string;
  103427. /**
  103428. * Serializes this Highlight layer
  103429. * @returns a serialized Highlight layer object
  103430. */
  103431. serialize(): any;
  103432. /**
  103433. * Creates a Highlight layer from parsed Highlight layer data
  103434. * @param parsedHightlightLayer defines the Highlight layer data
  103435. * @param scene defines the current scene
  103436. * @param rootUrl defines the root URL containing the Highlight layer information
  103437. * @returns a parsed Highlight layer
  103438. */
  103439. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103440. }
  103441. }
  103442. declare module BABYLON {
  103443. /** @hidden */
  103444. export var lensFlarePixelShader: {
  103445. name: string;
  103446. shader: string;
  103447. };
  103448. }
  103449. declare module BABYLON {
  103450. /** @hidden */
  103451. export var lensFlareVertexShader: {
  103452. name: string;
  103453. shader: string;
  103454. };
  103455. }
  103456. declare module BABYLON {
  103457. /**
  103458. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103459. * It is usually composed of several `lensFlare`.
  103460. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103461. */
  103462. export class LensFlareSystem {
  103463. /**
  103464. * Define the name of the lens flare system
  103465. */
  103466. name: string;
  103467. /**
  103468. * List of lens flares used in this system.
  103469. */
  103470. lensFlares: LensFlare[];
  103471. /**
  103472. * Define a limit from the border the lens flare can be visible.
  103473. */
  103474. borderLimit: number;
  103475. /**
  103476. * Define a viewport border we do not want to see the lens flare in.
  103477. */
  103478. viewportBorder: number;
  103479. /**
  103480. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103481. */
  103482. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103483. /**
  103484. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103485. */
  103486. layerMask: number;
  103487. /**
  103488. * Define the id of the lens flare system in the scene.
  103489. * (equal to name by default)
  103490. */
  103491. id: string;
  103492. private _scene;
  103493. private _emitter;
  103494. private _vertexBuffers;
  103495. private _indexBuffer;
  103496. private _effect;
  103497. private _positionX;
  103498. private _positionY;
  103499. private _isEnabled;
  103500. /** @hidden */
  103501. static _SceneComponentInitialization: (scene: Scene) => void;
  103502. /**
  103503. * Instantiates a lens flare system.
  103504. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103505. * It is usually composed of several `lensFlare`.
  103506. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103507. * @param name Define the name of the lens flare system in the scene
  103508. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103509. * @param scene Define the scene the lens flare system belongs to
  103510. */
  103511. constructor(
  103512. /**
  103513. * Define the name of the lens flare system
  103514. */
  103515. name: string, emitter: any, scene: Scene);
  103516. /**
  103517. * Define if the lens flare system is enabled.
  103518. */
  103519. isEnabled: boolean;
  103520. /**
  103521. * Get the scene the effects belongs to.
  103522. * @returns the scene holding the lens flare system
  103523. */
  103524. getScene(): Scene;
  103525. /**
  103526. * Get the emitter of the lens flare system.
  103527. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103528. * @returns the emitter of the lens flare system
  103529. */
  103530. getEmitter(): any;
  103531. /**
  103532. * Set the emitter of the lens flare system.
  103533. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103534. * @param newEmitter Define the new emitter of the system
  103535. */
  103536. setEmitter(newEmitter: any): void;
  103537. /**
  103538. * Get the lens flare system emitter position.
  103539. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103540. * @returns the position
  103541. */
  103542. getEmitterPosition(): Vector3;
  103543. /**
  103544. * @hidden
  103545. */
  103546. computeEffectivePosition(globalViewport: Viewport): boolean;
  103547. /** @hidden */
  103548. _isVisible(): boolean;
  103549. /**
  103550. * @hidden
  103551. */
  103552. render(): boolean;
  103553. /**
  103554. * Dispose and release the lens flare with its associated resources.
  103555. */
  103556. dispose(): void;
  103557. /**
  103558. * Parse a lens flare system from a JSON repressentation
  103559. * @param parsedLensFlareSystem Define the JSON to parse
  103560. * @param scene Define the scene the parsed system should be instantiated in
  103561. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103562. * @returns the parsed system
  103563. */
  103564. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103565. /**
  103566. * Serialize the current Lens Flare System into a JSON representation.
  103567. * @returns the serialized JSON
  103568. */
  103569. serialize(): any;
  103570. }
  103571. }
  103572. declare module BABYLON {
  103573. /**
  103574. * This represents one of the lens effect in a `lensFlareSystem`.
  103575. * It controls one of the indiviual texture used in the effect.
  103576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103577. */
  103578. export class LensFlare {
  103579. /**
  103580. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103581. */
  103582. size: number;
  103583. /**
  103584. * 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.
  103585. */
  103586. position: number;
  103587. /**
  103588. * Define the lens color.
  103589. */
  103590. color: Color3;
  103591. /**
  103592. * Define the lens texture.
  103593. */
  103594. texture: Nullable<Texture>;
  103595. /**
  103596. * Define the alpha mode to render this particular lens.
  103597. */
  103598. alphaMode: number;
  103599. private _system;
  103600. /**
  103601. * Creates a new Lens Flare.
  103602. * This represents one of the lens effect in a `lensFlareSystem`.
  103603. * It controls one of the indiviual texture used in the effect.
  103604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103605. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103606. * @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.
  103607. * @param color Define the lens color
  103608. * @param imgUrl Define the lens texture url
  103609. * @param system Define the `lensFlareSystem` this flare is part of
  103610. * @returns The newly created Lens Flare
  103611. */
  103612. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103613. /**
  103614. * Instantiates a new Lens Flare.
  103615. * This represents one of the lens effect in a `lensFlareSystem`.
  103616. * It controls one of the indiviual texture used in the effect.
  103617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103618. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103619. * @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.
  103620. * @param color Define the lens color
  103621. * @param imgUrl Define the lens texture url
  103622. * @param system Define the `lensFlareSystem` this flare is part of
  103623. */
  103624. constructor(
  103625. /**
  103626. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103627. */
  103628. size: number,
  103629. /**
  103630. * 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.
  103631. */
  103632. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103633. /**
  103634. * Dispose and release the lens flare with its associated resources.
  103635. */
  103636. dispose(): void;
  103637. }
  103638. }
  103639. declare module BABYLON {
  103640. interface AbstractScene {
  103641. /**
  103642. * The list of lens flare system added to the scene
  103643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103644. */
  103645. lensFlareSystems: Array<LensFlareSystem>;
  103646. /**
  103647. * Removes the given lens flare system from this scene.
  103648. * @param toRemove The lens flare system to remove
  103649. * @returns The index of the removed lens flare system
  103650. */
  103651. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103652. /**
  103653. * Adds the given lens flare system to this scene
  103654. * @param newLensFlareSystem The lens flare system to add
  103655. */
  103656. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103657. /**
  103658. * Gets a lens flare system using its name
  103659. * @param name defines the name to look for
  103660. * @returns the lens flare system or null if not found
  103661. */
  103662. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103663. /**
  103664. * Gets a lens flare system using its id
  103665. * @param id defines the id to look for
  103666. * @returns the lens flare system or null if not found
  103667. */
  103668. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103669. }
  103670. /**
  103671. * Defines the lens flare scene component responsible to manage any lens flares
  103672. * in a given scene.
  103673. */
  103674. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103675. /**
  103676. * The component name helpfull to identify the component in the list of scene components.
  103677. */
  103678. readonly name: string;
  103679. /**
  103680. * The scene the component belongs to.
  103681. */
  103682. scene: Scene;
  103683. /**
  103684. * Creates a new instance of the component for the given scene
  103685. * @param scene Defines the scene to register the component in
  103686. */
  103687. constructor(scene: Scene);
  103688. /**
  103689. * Registers the component in a given scene
  103690. */
  103691. register(): void;
  103692. /**
  103693. * Rebuilds the elements related to this component in case of
  103694. * context lost for instance.
  103695. */
  103696. rebuild(): void;
  103697. /**
  103698. * Adds all the element from the container to the scene
  103699. * @param container the container holding the elements
  103700. */
  103701. addFromContainer(container: AbstractScene): void;
  103702. /**
  103703. * Removes all the elements in the container from the scene
  103704. * @param container contains the elements to remove
  103705. */
  103706. removeFromContainer(container: AbstractScene): void;
  103707. /**
  103708. * Serializes the component data to the specified json object
  103709. * @param serializationObject The object to serialize to
  103710. */
  103711. serialize(serializationObject: any): void;
  103712. /**
  103713. * Disposes the component and the associated ressources.
  103714. */
  103715. dispose(): void;
  103716. private _draw;
  103717. }
  103718. }
  103719. declare module BABYLON {
  103720. /**
  103721. * Defines the shadow generator component responsible to manage any shadow generators
  103722. * in a given scene.
  103723. */
  103724. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103725. /**
  103726. * The component name helpfull to identify the component in the list of scene components.
  103727. */
  103728. readonly name: string;
  103729. /**
  103730. * The scene the component belongs to.
  103731. */
  103732. scene: Scene;
  103733. /**
  103734. * Creates a new instance of the component for the given scene
  103735. * @param scene Defines the scene to register the component in
  103736. */
  103737. constructor(scene: Scene);
  103738. /**
  103739. * Registers the component in a given scene
  103740. */
  103741. register(): void;
  103742. /**
  103743. * Rebuilds the elements related to this component in case of
  103744. * context lost for instance.
  103745. */
  103746. rebuild(): void;
  103747. /**
  103748. * Serializes the component data to the specified json object
  103749. * @param serializationObject The object to serialize to
  103750. */
  103751. serialize(serializationObject: any): void;
  103752. /**
  103753. * Adds all the element from the container to the scene
  103754. * @param container the container holding the elements
  103755. */
  103756. addFromContainer(container: AbstractScene): void;
  103757. /**
  103758. * Removes all the elements in the container from the scene
  103759. * @param container contains the elements to remove
  103760. */
  103761. removeFromContainer(container: AbstractScene): void;
  103762. /**
  103763. * Rebuilds the elements related to this component in case of
  103764. * context lost for instance.
  103765. */
  103766. dispose(): void;
  103767. private _gatherRenderTargets;
  103768. }
  103769. }
  103770. declare module BABYLON {
  103771. /**
  103772. * A directional light is defined by a direction (what a surprise!).
  103773. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103774. * 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.
  103775. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103776. */
  103777. export class DirectionalLight extends ShadowLight {
  103778. private _shadowFrustumSize;
  103779. /**
  103780. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103781. */
  103782. /**
  103783. * Specifies a fix frustum size for the shadow generation.
  103784. */
  103785. shadowFrustumSize: number;
  103786. private _shadowOrthoScale;
  103787. /**
  103788. * Gets the shadow projection scale against the optimal computed one.
  103789. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103790. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103791. */
  103792. /**
  103793. * Sets the shadow projection scale against the optimal computed one.
  103794. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103795. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103796. */
  103797. shadowOrthoScale: number;
  103798. /**
  103799. * Automatically compute the projection matrix to best fit (including all the casters)
  103800. * on each frame.
  103801. */
  103802. autoUpdateExtends: boolean;
  103803. private _orthoLeft;
  103804. private _orthoRight;
  103805. private _orthoTop;
  103806. private _orthoBottom;
  103807. /**
  103808. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103809. * The directional light is emitted from everywhere in the given direction.
  103810. * It can cast shadows.
  103811. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103812. * @param name The friendly name of the light
  103813. * @param direction The direction of the light
  103814. * @param scene The scene the light belongs to
  103815. */
  103816. constructor(name: string, direction: Vector3, scene: Scene);
  103817. /**
  103818. * Returns the string "DirectionalLight".
  103819. * @return The class name
  103820. */
  103821. getClassName(): string;
  103822. /**
  103823. * Returns the integer 1.
  103824. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103825. */
  103826. getTypeID(): number;
  103827. /**
  103828. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103829. * Returns the DirectionalLight Shadow projection matrix.
  103830. */
  103831. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103832. /**
  103833. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103834. * Returns the DirectionalLight Shadow projection matrix.
  103835. */
  103836. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103837. /**
  103838. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103839. * Returns the DirectionalLight Shadow projection matrix.
  103840. */
  103841. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103842. protected _buildUniformLayout(): void;
  103843. /**
  103844. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103845. * @param effect The effect to update
  103846. * @param lightIndex The index of the light in the effect to update
  103847. * @returns The directional light
  103848. */
  103849. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103850. /**
  103851. * Gets the minZ used for shadow according to both the scene and the light.
  103852. *
  103853. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103854. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103855. * @param activeCamera The camera we are returning the min for
  103856. * @returns the depth min z
  103857. */
  103858. getDepthMinZ(activeCamera: Camera): number;
  103859. /**
  103860. * Gets the maxZ used for shadow according to both the scene and the light.
  103861. *
  103862. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103863. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103864. * @param activeCamera The camera we are returning the max for
  103865. * @returns the depth max z
  103866. */
  103867. getDepthMaxZ(activeCamera: Camera): number;
  103868. /**
  103869. * Prepares the list of defines specific to the light type.
  103870. * @param defines the list of defines
  103871. * @param lightIndex defines the index of the light for the effect
  103872. */
  103873. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103874. }
  103875. }
  103876. declare module BABYLON {
  103877. /**
  103878. * A point light is a light defined by an unique point in world space.
  103879. * The light is emitted in every direction from this point.
  103880. * A good example of a point light is a standard light bulb.
  103881. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103882. */
  103883. export class PointLight extends ShadowLight {
  103884. private _shadowAngle;
  103885. /**
  103886. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103887. * This specifies what angle the shadow will use to be created.
  103888. *
  103889. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103890. */
  103891. /**
  103892. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103893. * This specifies what angle the shadow will use to be created.
  103894. *
  103895. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103896. */
  103897. shadowAngle: number;
  103898. /**
  103899. * Gets the direction if it has been set.
  103900. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103901. */
  103902. /**
  103903. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103904. */
  103905. direction: Vector3;
  103906. /**
  103907. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103908. * A PointLight emits the light in every direction.
  103909. * It can cast shadows.
  103910. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103911. * ```javascript
  103912. * var pointLight = new PointLight("pl", camera.position, scene);
  103913. * ```
  103914. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103915. * @param name The light friendly name
  103916. * @param position The position of the point light in the scene
  103917. * @param scene The scene the lights belongs to
  103918. */
  103919. constructor(name: string, position: Vector3, scene: Scene);
  103920. /**
  103921. * Returns the string "PointLight"
  103922. * @returns the class name
  103923. */
  103924. getClassName(): string;
  103925. /**
  103926. * Returns the integer 0.
  103927. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103928. */
  103929. getTypeID(): number;
  103930. /**
  103931. * Specifies wether or not the shadowmap should be a cube texture.
  103932. * @returns true if the shadowmap needs to be a cube texture.
  103933. */
  103934. needCube(): boolean;
  103935. /**
  103936. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103937. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103938. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103939. */
  103940. getShadowDirection(faceIndex?: number): Vector3;
  103941. /**
  103942. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103943. * - fov = PI / 2
  103944. * - aspect ratio : 1.0
  103945. * - z-near and far equal to the active camera minZ and maxZ.
  103946. * Returns the PointLight.
  103947. */
  103948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103949. protected _buildUniformLayout(): void;
  103950. /**
  103951. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103952. * @param effect The effect to update
  103953. * @param lightIndex The index of the light in the effect to update
  103954. * @returns The point light
  103955. */
  103956. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103957. /**
  103958. * Prepares the list of defines specific to the light type.
  103959. * @param defines the list of defines
  103960. * @param lightIndex defines the index of the light for the effect
  103961. */
  103962. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103963. }
  103964. }
  103965. declare module BABYLON {
  103966. /**
  103967. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103968. * These values define a cone of light starting from the position, emitting toward the direction.
  103969. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103970. * and the exponent defines the speed of the decay of the light with distance (reach).
  103971. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103972. */
  103973. export class SpotLight extends ShadowLight {
  103974. private _angle;
  103975. private _innerAngle;
  103976. private _cosHalfAngle;
  103977. private _lightAngleScale;
  103978. private _lightAngleOffset;
  103979. /**
  103980. * Gets the cone angle of the spot light in Radians.
  103981. */
  103982. /**
  103983. * Sets the cone angle of the spot light in Radians.
  103984. */
  103985. angle: number;
  103986. /**
  103987. * Only used in gltf falloff mode, this defines the angle where
  103988. * the directional falloff will start before cutting at angle which could be seen
  103989. * as outer angle.
  103990. */
  103991. /**
  103992. * Only used in gltf falloff mode, this defines the angle where
  103993. * the directional falloff will start before cutting at angle which could be seen
  103994. * as outer angle.
  103995. */
  103996. innerAngle: number;
  103997. private _shadowAngleScale;
  103998. /**
  103999. * Allows scaling the angle of the light for shadow generation only.
  104000. */
  104001. /**
  104002. * Allows scaling the angle of the light for shadow generation only.
  104003. */
  104004. shadowAngleScale: number;
  104005. /**
  104006. * The light decay speed with the distance from the emission spot.
  104007. */
  104008. exponent: number;
  104009. private _projectionTextureMatrix;
  104010. /**
  104011. * Allows reading the projecton texture
  104012. */
  104013. readonly projectionTextureMatrix: Matrix;
  104014. protected _projectionTextureLightNear: number;
  104015. /**
  104016. * Gets the near clip of the Spotlight for texture projection.
  104017. */
  104018. /**
  104019. * Sets the near clip of the Spotlight for texture projection.
  104020. */
  104021. projectionTextureLightNear: number;
  104022. protected _projectionTextureLightFar: number;
  104023. /**
  104024. * Gets the far clip of the Spotlight for texture projection.
  104025. */
  104026. /**
  104027. * Sets the far clip of the Spotlight for texture projection.
  104028. */
  104029. projectionTextureLightFar: number;
  104030. protected _projectionTextureUpDirection: Vector3;
  104031. /**
  104032. * Gets the Up vector of the Spotlight for texture projection.
  104033. */
  104034. /**
  104035. * Sets the Up vector of the Spotlight for texture projection.
  104036. */
  104037. projectionTextureUpDirection: Vector3;
  104038. private _projectionTexture;
  104039. /**
  104040. * Gets the projection texture of the light.
  104041. */
  104042. /**
  104043. * Sets the projection texture of the light.
  104044. */
  104045. projectionTexture: Nullable<BaseTexture>;
  104046. private _projectionTextureViewLightDirty;
  104047. private _projectionTextureProjectionLightDirty;
  104048. private _projectionTextureDirty;
  104049. private _projectionTextureViewTargetVector;
  104050. private _projectionTextureViewLightMatrix;
  104051. private _projectionTextureProjectionLightMatrix;
  104052. private _projectionTextureScalingMatrix;
  104053. /**
  104054. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104055. * It can cast shadows.
  104056. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104057. * @param name The light friendly name
  104058. * @param position The position of the spot light in the scene
  104059. * @param direction The direction of the light in the scene
  104060. * @param angle The cone angle of the light in Radians
  104061. * @param exponent The light decay speed with the distance from the emission spot
  104062. * @param scene The scene the lights belongs to
  104063. */
  104064. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104065. /**
  104066. * Returns the string "SpotLight".
  104067. * @returns the class name
  104068. */
  104069. getClassName(): string;
  104070. /**
  104071. * Returns the integer 2.
  104072. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104073. */
  104074. getTypeID(): number;
  104075. /**
  104076. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104077. */
  104078. protected _setDirection(value: Vector3): void;
  104079. /**
  104080. * Overrides the position setter to recompute the projection texture view light Matrix.
  104081. */
  104082. protected _setPosition(value: Vector3): void;
  104083. /**
  104084. * 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.
  104085. * Returns the SpotLight.
  104086. */
  104087. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104088. protected _computeProjectionTextureViewLightMatrix(): void;
  104089. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104090. /**
  104091. * Main function for light texture projection matrix computing.
  104092. */
  104093. protected _computeProjectionTextureMatrix(): void;
  104094. protected _buildUniformLayout(): void;
  104095. private _computeAngleValues;
  104096. /**
  104097. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104098. * @param effect The effect to update
  104099. * @param lightIndex The index of the light in the effect to update
  104100. * @returns The spot light
  104101. */
  104102. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104103. /**
  104104. * Disposes the light and the associated resources.
  104105. */
  104106. dispose(): void;
  104107. /**
  104108. * Prepares the list of defines specific to the light type.
  104109. * @param defines the list of defines
  104110. * @param lightIndex defines the index of the light for the effect
  104111. */
  104112. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104113. }
  104114. }
  104115. declare module BABYLON {
  104116. /**
  104117. * Header information of HDR texture files.
  104118. */
  104119. export interface HDRInfo {
  104120. /**
  104121. * The height of the texture in pixels.
  104122. */
  104123. height: number;
  104124. /**
  104125. * The width of the texture in pixels.
  104126. */
  104127. width: number;
  104128. /**
  104129. * The index of the beginning of the data in the binary file.
  104130. */
  104131. dataPosition: number;
  104132. }
  104133. /**
  104134. * This groups tools to convert HDR texture to native colors array.
  104135. */
  104136. export class HDRTools {
  104137. private static Ldexp;
  104138. private static Rgbe2float;
  104139. private static readStringLine;
  104140. /**
  104141. * Reads header information from an RGBE texture stored in a native array.
  104142. * More information on this format are available here:
  104143. * https://en.wikipedia.org/wiki/RGBE_image_format
  104144. *
  104145. * @param uint8array The binary file stored in native array.
  104146. * @return The header information.
  104147. */
  104148. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104149. /**
  104150. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104151. * This RGBE texture needs to store the information as a panorama.
  104152. *
  104153. * More information on this format are available here:
  104154. * https://en.wikipedia.org/wiki/RGBE_image_format
  104155. *
  104156. * @param buffer The binary file stored in an array buffer.
  104157. * @param size The expected size of the extracted cubemap.
  104158. * @return The Cube Map information.
  104159. */
  104160. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104161. /**
  104162. * Returns the pixels data extracted from an RGBE texture.
  104163. * This pixels will be stored left to right up to down in the R G B order in one array.
  104164. *
  104165. * More information on this format are available here:
  104166. * https://en.wikipedia.org/wiki/RGBE_image_format
  104167. *
  104168. * @param uint8array The binary file stored in an array buffer.
  104169. * @param hdrInfo The header information of the file.
  104170. * @return The pixels data in RGB right to left up to down order.
  104171. */
  104172. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104173. private static RGBE_ReadPixels_RLE;
  104174. }
  104175. }
  104176. declare module BABYLON {
  104177. /**
  104178. * This represents a texture coming from an HDR input.
  104179. *
  104180. * The only supported format is currently panorama picture stored in RGBE format.
  104181. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104182. */
  104183. export class HDRCubeTexture extends BaseTexture {
  104184. private static _facesMapping;
  104185. private _generateHarmonics;
  104186. private _noMipmap;
  104187. private _textureMatrix;
  104188. private _size;
  104189. private _onLoad;
  104190. private _onError;
  104191. /**
  104192. * The texture URL.
  104193. */
  104194. url: string;
  104195. /**
  104196. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104197. */
  104198. coordinatesMode: number;
  104199. protected _isBlocking: boolean;
  104200. /**
  104201. * Sets wether or not the texture is blocking during loading.
  104202. */
  104203. /**
  104204. * Gets wether or not the texture is blocking during loading.
  104205. */
  104206. isBlocking: boolean;
  104207. protected _rotationY: number;
  104208. /**
  104209. * Sets texture matrix rotation angle around Y axis in radians.
  104210. */
  104211. /**
  104212. * Gets texture matrix rotation angle around Y axis radians.
  104213. */
  104214. rotationY: number;
  104215. /**
  104216. * Gets or sets the center of the bounding box associated with the cube texture
  104217. * It must define where the camera used to render the texture was set
  104218. */
  104219. boundingBoxPosition: Vector3;
  104220. private _boundingBoxSize;
  104221. /**
  104222. * Gets or sets the size of the bounding box associated with the cube texture
  104223. * When defined, the cubemap will switch to local mode
  104224. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104225. * @example https://www.babylonjs-playground.com/#RNASML
  104226. */
  104227. boundingBoxSize: Vector3;
  104228. /**
  104229. * Instantiates an HDRTexture from the following parameters.
  104230. *
  104231. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104232. * @param scene The scene the texture will be used in
  104233. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104234. * @param noMipmap Forces to not generate the mipmap if true
  104235. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104236. * @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)
  104237. * @param reserved Reserved flag for internal use.
  104238. */
  104239. 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>);
  104240. /**
  104241. * Get the current class name of the texture useful for serialization or dynamic coding.
  104242. * @returns "HDRCubeTexture"
  104243. */
  104244. getClassName(): string;
  104245. /**
  104246. * Occurs when the file is raw .hdr file.
  104247. */
  104248. private loadTexture;
  104249. clone(): HDRCubeTexture;
  104250. delayLoad(): void;
  104251. /**
  104252. * Get the texture reflection matrix used to rotate/transform the reflection.
  104253. * @returns the reflection matrix
  104254. */
  104255. getReflectionTextureMatrix(): Matrix;
  104256. /**
  104257. * Set the texture reflection matrix used to rotate/transform the reflection.
  104258. * @param value Define the reflection matrix to set
  104259. */
  104260. setReflectionTextureMatrix(value: Matrix): void;
  104261. /**
  104262. * Parses a JSON representation of an HDR Texture in order to create the texture
  104263. * @param parsedTexture Define the JSON representation
  104264. * @param scene Define the scene the texture should be created in
  104265. * @param rootUrl Define the root url in case we need to load relative dependencies
  104266. * @returns the newly created texture after parsing
  104267. */
  104268. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104269. serialize(): any;
  104270. }
  104271. }
  104272. declare module BABYLON {
  104273. /**
  104274. * Class used to control physics engine
  104275. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104276. */
  104277. export class PhysicsEngine implements IPhysicsEngine {
  104278. private _physicsPlugin;
  104279. /**
  104280. * Global value used to control the smallest number supported by the simulation
  104281. */
  104282. static Epsilon: number;
  104283. private _impostors;
  104284. private _joints;
  104285. /**
  104286. * Gets the gravity vector used by the simulation
  104287. */
  104288. gravity: Vector3;
  104289. /**
  104290. * Factory used to create the default physics plugin.
  104291. * @returns The default physics plugin
  104292. */
  104293. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104294. /**
  104295. * Creates a new Physics Engine
  104296. * @param gravity defines the gravity vector used by the simulation
  104297. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104298. */
  104299. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104300. /**
  104301. * Sets the gravity vector used by the simulation
  104302. * @param gravity defines the gravity vector to use
  104303. */
  104304. setGravity(gravity: Vector3): void;
  104305. /**
  104306. * Set the time step of the physics engine.
  104307. * Default is 1/60.
  104308. * To slow it down, enter 1/600 for example.
  104309. * To speed it up, 1/30
  104310. * @param newTimeStep defines the new timestep to apply to this world.
  104311. */
  104312. setTimeStep(newTimeStep?: number): void;
  104313. /**
  104314. * Get the time step of the physics engine.
  104315. * @returns the current time step
  104316. */
  104317. getTimeStep(): number;
  104318. /**
  104319. * Release all resources
  104320. */
  104321. dispose(): void;
  104322. /**
  104323. * Gets the name of the current physics plugin
  104324. * @returns the name of the plugin
  104325. */
  104326. getPhysicsPluginName(): string;
  104327. /**
  104328. * Adding a new impostor for the impostor tracking.
  104329. * This will be done by the impostor itself.
  104330. * @param impostor the impostor to add
  104331. */
  104332. addImpostor(impostor: PhysicsImpostor): void;
  104333. /**
  104334. * Remove an impostor from the engine.
  104335. * This impostor and its mesh will not longer be updated by the physics engine.
  104336. * @param impostor the impostor to remove
  104337. */
  104338. removeImpostor(impostor: PhysicsImpostor): void;
  104339. /**
  104340. * Add a joint to the physics engine
  104341. * @param mainImpostor defines the main impostor to which the joint is added.
  104342. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104343. * @param joint defines the joint that will connect both impostors.
  104344. */
  104345. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104346. /**
  104347. * Removes a joint from the simulation
  104348. * @param mainImpostor defines the impostor used with the joint
  104349. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104350. * @param joint defines the joint to remove
  104351. */
  104352. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104353. /**
  104354. * Called by the scene. No need to call it.
  104355. * @param delta defines the timespam between frames
  104356. */
  104357. _step(delta: number): void;
  104358. /**
  104359. * Gets the current plugin used to run the simulation
  104360. * @returns current plugin
  104361. */
  104362. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104363. /**
  104364. * Gets the list of physic impostors
  104365. * @returns an array of PhysicsImpostor
  104366. */
  104367. getImpostors(): Array<PhysicsImpostor>;
  104368. /**
  104369. * Gets the impostor for a physics enabled object
  104370. * @param object defines the object impersonated by the impostor
  104371. * @returns the PhysicsImpostor or null if not found
  104372. */
  104373. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104374. /**
  104375. * Gets the impostor for a physics body object
  104376. * @param body defines physics body used by the impostor
  104377. * @returns the PhysicsImpostor or null if not found
  104378. */
  104379. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104380. }
  104381. }
  104382. declare module BABYLON {
  104383. /** @hidden */
  104384. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104385. private _useDeltaForWorldStep;
  104386. world: any;
  104387. name: string;
  104388. private _physicsMaterials;
  104389. private _fixedTimeStep;
  104390. BJSCANNON: any;
  104391. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104392. setGravity(gravity: Vector3): void;
  104393. setTimeStep(timeStep: number): void;
  104394. getTimeStep(): number;
  104395. executeStep(delta: number): void;
  104396. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104397. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104398. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104399. private _processChildMeshes;
  104400. removePhysicsBody(impostor: PhysicsImpostor): void;
  104401. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104402. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104403. private _addMaterial;
  104404. private _checkWithEpsilon;
  104405. private _createShape;
  104406. private _createHeightmap;
  104407. private _minus90X;
  104408. private _plus90X;
  104409. private _tmpPosition;
  104410. private _tmpDeltaPosition;
  104411. private _tmpUnityRotation;
  104412. private _updatePhysicsBodyTransformation;
  104413. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104414. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104415. isSupported(): boolean;
  104416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104421. getBodyMass(impostor: PhysicsImpostor): number;
  104422. getBodyFriction(impostor: PhysicsImpostor): number;
  104423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104424. getBodyRestitution(impostor: PhysicsImpostor): number;
  104425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104426. sleepBody(impostor: PhysicsImpostor): void;
  104427. wakeUpBody(impostor: PhysicsImpostor): void;
  104428. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104429. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104431. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104432. getRadius(impostor: PhysicsImpostor): number;
  104433. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104434. dispose(): void;
  104435. private _extendNamespace;
  104436. }
  104437. }
  104438. declare module BABYLON {
  104439. /** @hidden */
  104440. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104441. world: any;
  104442. name: string;
  104443. BJSOIMO: any;
  104444. constructor(iterations?: number, oimoInjection?: any);
  104445. setGravity(gravity: Vector3): void;
  104446. setTimeStep(timeStep: number): void;
  104447. getTimeStep(): number;
  104448. private _tmpImpostorsArray;
  104449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104451. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104453. private _tmpPositionVector;
  104454. removePhysicsBody(impostor: PhysicsImpostor): void;
  104455. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104456. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104457. isSupported(): boolean;
  104458. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104459. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104461. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104462. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104463. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104464. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104465. getBodyMass(impostor: PhysicsImpostor): number;
  104466. getBodyFriction(impostor: PhysicsImpostor): number;
  104467. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104468. getBodyRestitution(impostor: PhysicsImpostor): number;
  104469. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104470. sleepBody(impostor: PhysicsImpostor): void;
  104471. wakeUpBody(impostor: PhysicsImpostor): void;
  104472. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104473. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104474. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104476. getRadius(impostor: PhysicsImpostor): number;
  104477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104478. dispose(): void;
  104479. }
  104480. }
  104481. declare module BABYLON {
  104482. interface AbstractScene {
  104483. /**
  104484. * The list of reflection probes added to the scene
  104485. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104486. */
  104487. reflectionProbes: Array<ReflectionProbe>;
  104488. /**
  104489. * Removes the given reflection probe from this scene.
  104490. * @param toRemove The reflection probe to remove
  104491. * @returns The index of the removed reflection probe
  104492. */
  104493. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104494. /**
  104495. * Adds the given reflection probe to this scene.
  104496. * @param newReflectionProbe The reflection probe to add
  104497. */
  104498. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104499. }
  104500. /**
  104501. * Class used to generate realtime reflection / refraction cube textures
  104502. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104503. */
  104504. export class ReflectionProbe {
  104505. /** defines the name of the probe */
  104506. name: string;
  104507. private _scene;
  104508. private _renderTargetTexture;
  104509. private _projectionMatrix;
  104510. private _viewMatrix;
  104511. private _target;
  104512. private _add;
  104513. private _attachedMesh;
  104514. private _invertYAxis;
  104515. /** Gets or sets probe position (center of the cube map) */
  104516. position: Vector3;
  104517. /**
  104518. * Creates a new reflection probe
  104519. * @param name defines the name of the probe
  104520. * @param size defines the texture resolution (for each face)
  104521. * @param scene defines the hosting scene
  104522. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104523. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104524. */
  104525. constructor(
  104526. /** defines the name of the probe */
  104527. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104528. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104529. samples: number;
  104530. /** Gets or sets the refresh rate to use (on every frame by default) */
  104531. refreshRate: number;
  104532. /**
  104533. * Gets the hosting scene
  104534. * @returns a Scene
  104535. */
  104536. getScene(): Scene;
  104537. /** Gets the internal CubeTexture used to render to */
  104538. readonly cubeTexture: RenderTargetTexture;
  104539. /** Gets the list of meshes to render */
  104540. readonly renderList: Nullable<AbstractMesh[]>;
  104541. /**
  104542. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104543. * @param mesh defines the mesh to attach to
  104544. */
  104545. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104546. /**
  104547. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104548. * @param renderingGroupId The rendering group id corresponding to its index
  104549. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104550. */
  104551. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104552. /**
  104553. * Clean all associated resources
  104554. */
  104555. dispose(): void;
  104556. /**
  104557. * Converts the reflection probe information to a readable string for debug purpose.
  104558. * @param fullDetails Supports for multiple levels of logging within scene loading
  104559. * @returns the human readable reflection probe info
  104560. */
  104561. toString(fullDetails?: boolean): string;
  104562. /**
  104563. * Get the class name of the relfection probe.
  104564. * @returns "ReflectionProbe"
  104565. */
  104566. getClassName(): string;
  104567. /**
  104568. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104569. * @returns The JSON representation of the texture
  104570. */
  104571. serialize(): any;
  104572. /**
  104573. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104574. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104575. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104576. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104577. * @returns The parsed reflection probe if successful
  104578. */
  104579. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104580. }
  104581. }
  104582. declare module BABYLON {
  104583. /** @hidden */
  104584. export var _BabylonLoaderRegistered: boolean;
  104585. }
  104586. declare module BABYLON {
  104587. /**
  104588. * The Physically based simple base material of BJS.
  104589. *
  104590. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104591. * It is used as the base class for both the specGloss and metalRough conventions.
  104592. */
  104593. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104594. /**
  104595. * Number of Simultaneous lights allowed on the material.
  104596. */
  104597. maxSimultaneousLights: number;
  104598. /**
  104599. * If sets to true, disables all the lights affecting the material.
  104600. */
  104601. disableLighting: boolean;
  104602. /**
  104603. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104604. */
  104605. environmentTexture: BaseTexture;
  104606. /**
  104607. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104608. */
  104609. invertNormalMapX: boolean;
  104610. /**
  104611. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104612. */
  104613. invertNormalMapY: boolean;
  104614. /**
  104615. * Normal map used in the model.
  104616. */
  104617. normalTexture: BaseTexture;
  104618. /**
  104619. * Emissivie color used to self-illuminate the model.
  104620. */
  104621. emissiveColor: Color3;
  104622. /**
  104623. * Emissivie texture used to self-illuminate the model.
  104624. */
  104625. emissiveTexture: BaseTexture;
  104626. /**
  104627. * Occlusion Channel Strenght.
  104628. */
  104629. occlusionStrength: number;
  104630. /**
  104631. * Occlusion Texture of the material (adding extra occlusion effects).
  104632. */
  104633. occlusionTexture: BaseTexture;
  104634. /**
  104635. * Defines the alpha limits in alpha test mode.
  104636. */
  104637. alphaCutOff: number;
  104638. /**
  104639. * Gets the current double sided mode.
  104640. */
  104641. /**
  104642. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104643. */
  104644. doubleSided: boolean;
  104645. /**
  104646. * Stores the pre-calculated light information of a mesh in a texture.
  104647. */
  104648. lightmapTexture: BaseTexture;
  104649. /**
  104650. * If true, the light map contains occlusion information instead of lighting info.
  104651. */
  104652. useLightmapAsShadowmap: boolean;
  104653. /**
  104654. * Instantiates a new PBRMaterial instance.
  104655. *
  104656. * @param name The material name
  104657. * @param scene The scene the material will be use in.
  104658. */
  104659. constructor(name: string, scene: Scene);
  104660. getClassName(): string;
  104661. }
  104662. }
  104663. declare module BABYLON {
  104664. /**
  104665. * The PBR material of BJS following the metal roughness convention.
  104666. *
  104667. * This fits to the PBR convention in the GLTF definition:
  104668. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104669. */
  104670. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104671. /**
  104672. * The base color has two different interpretations depending on the value of metalness.
  104673. * When the material is a metal, the base color is the specific measured reflectance value
  104674. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104675. * of the material.
  104676. */
  104677. baseColor: Color3;
  104678. /**
  104679. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104680. * well as opacity information in the alpha channel.
  104681. */
  104682. baseTexture: BaseTexture;
  104683. /**
  104684. * Specifies the metallic scalar value of the material.
  104685. * Can also be used to scale the metalness values of the metallic texture.
  104686. */
  104687. metallic: number;
  104688. /**
  104689. * Specifies the roughness scalar value of the material.
  104690. * Can also be used to scale the roughness values of the metallic texture.
  104691. */
  104692. roughness: number;
  104693. /**
  104694. * Texture containing both the metallic value in the B channel and the
  104695. * roughness value in the G channel to keep better precision.
  104696. */
  104697. metallicRoughnessTexture: BaseTexture;
  104698. /**
  104699. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104700. *
  104701. * @param name The material name
  104702. * @param scene The scene the material will be use in.
  104703. */
  104704. constructor(name: string, scene: Scene);
  104705. /**
  104706. * Return the currrent class name of the material.
  104707. */
  104708. getClassName(): string;
  104709. /**
  104710. * Makes a duplicate of the current material.
  104711. * @param name - name to use for the new material.
  104712. */
  104713. clone(name: string): PBRMetallicRoughnessMaterial;
  104714. /**
  104715. * Serialize the material to a parsable JSON object.
  104716. */
  104717. serialize(): any;
  104718. /**
  104719. * Parses a JSON object correponding to the serialize function.
  104720. */
  104721. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104722. }
  104723. }
  104724. declare module BABYLON {
  104725. /**
  104726. * The PBR material of BJS following the specular glossiness convention.
  104727. *
  104728. * This fits to the PBR convention in the GLTF definition:
  104729. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104730. */
  104731. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104732. /**
  104733. * Specifies the diffuse color of the material.
  104734. */
  104735. diffuseColor: Color3;
  104736. /**
  104737. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104738. * channel.
  104739. */
  104740. diffuseTexture: BaseTexture;
  104741. /**
  104742. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104743. */
  104744. specularColor: Color3;
  104745. /**
  104746. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104747. */
  104748. glossiness: number;
  104749. /**
  104750. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104751. */
  104752. specularGlossinessTexture: BaseTexture;
  104753. /**
  104754. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104755. *
  104756. * @param name The material name
  104757. * @param scene The scene the material will be use in.
  104758. */
  104759. constructor(name: string, scene: Scene);
  104760. /**
  104761. * Return the currrent class name of the material.
  104762. */
  104763. getClassName(): string;
  104764. /**
  104765. * Makes a duplicate of the current material.
  104766. * @param name - name to use for the new material.
  104767. */
  104768. clone(name: string): PBRSpecularGlossinessMaterial;
  104769. /**
  104770. * Serialize the material to a parsable JSON object.
  104771. */
  104772. serialize(): any;
  104773. /**
  104774. * Parses a JSON object correponding to the serialize function.
  104775. */
  104776. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104777. }
  104778. }
  104779. declare module BABYLON {
  104780. /**
  104781. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104782. * It can help converting any input color in a desired output one. This can then be used to create effects
  104783. * from sepia, black and white to sixties or futuristic rendering...
  104784. *
  104785. * The only supported format is currently 3dl.
  104786. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104787. */
  104788. export class ColorGradingTexture extends BaseTexture {
  104789. /**
  104790. * The current texture matrix. (will always be identity in color grading texture)
  104791. */
  104792. private _textureMatrix;
  104793. /**
  104794. * The texture URL.
  104795. */
  104796. url: string;
  104797. /**
  104798. * Empty line regex stored for GC.
  104799. */
  104800. private static _noneEmptyLineRegex;
  104801. private _engine;
  104802. /**
  104803. * Instantiates a ColorGradingTexture from the following parameters.
  104804. *
  104805. * @param url The location of the color gradind data (currently only supporting 3dl)
  104806. * @param scene The scene the texture will be used in
  104807. */
  104808. constructor(url: string, scene: Scene);
  104809. /**
  104810. * Returns the texture matrix used in most of the material.
  104811. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  104812. */
  104813. getTextureMatrix(): Matrix;
  104814. /**
  104815. * Occurs when the file being loaded is a .3dl LUT file.
  104816. */
  104817. private load3dlTexture;
  104818. /**
  104819. * Starts the loading process of the texture.
  104820. */
  104821. private loadTexture;
  104822. /**
  104823. * Clones the color gradind texture.
  104824. */
  104825. clone(): ColorGradingTexture;
  104826. /**
  104827. * Called during delayed load for textures.
  104828. */
  104829. delayLoad(): void;
  104830. /**
  104831. * Parses a color grading texture serialized by Babylon.
  104832. * @param parsedTexture The texture information being parsedTexture
  104833. * @param scene The scene to load the texture in
  104834. * @param rootUrl The root url of the data assets to load
  104835. * @return A color gradind texture
  104836. */
  104837. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  104838. /**
  104839. * Serializes the LUT texture to json format.
  104840. */
  104841. serialize(): any;
  104842. }
  104843. }
  104844. declare module BABYLON {
  104845. /**
  104846. * Based on jsTGALoader - Javascript loader for TGA file
  104847. * By Vincent Thibault
  104848. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104849. */
  104850. export class TGATools {
  104851. private static _TYPE_INDEXED;
  104852. private static _TYPE_RGB;
  104853. private static _TYPE_GREY;
  104854. private static _TYPE_RLE_INDEXED;
  104855. private static _TYPE_RLE_RGB;
  104856. private static _TYPE_RLE_GREY;
  104857. private static _ORIGIN_MASK;
  104858. private static _ORIGIN_SHIFT;
  104859. private static _ORIGIN_BL;
  104860. private static _ORIGIN_BR;
  104861. private static _ORIGIN_UL;
  104862. private static _ORIGIN_UR;
  104863. /**
  104864. * Gets the header of a TGA file
  104865. * @param data defines the TGA data
  104866. * @returns the header
  104867. */
  104868. static GetTGAHeader(data: Uint8Array): any;
  104869. /**
  104870. * Uploads TGA content to a Babylon Texture
  104871. * @hidden
  104872. */
  104873. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104874. /** @hidden */
  104875. 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;
  104876. /** @hidden */
  104877. 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;
  104878. /** @hidden */
  104879. 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;
  104880. /** @hidden */
  104881. 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;
  104882. /** @hidden */
  104883. 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;
  104884. /** @hidden */
  104885. 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;
  104886. }
  104887. }
  104888. declare module BABYLON {
  104889. /**
  104890. * Implementation of the TGA Texture Loader.
  104891. * @hidden
  104892. */
  104893. export class _TGATextureLoader implements IInternalTextureLoader {
  104894. /**
  104895. * Defines wether the loader supports cascade loading the different faces.
  104896. */
  104897. readonly supportCascades: boolean;
  104898. /**
  104899. * This returns if the loader support the current file information.
  104900. * @param extension defines the file extension of the file being loaded
  104901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104902. * @param fallback defines the fallback internal texture if any
  104903. * @param isBase64 defines whether the texture is encoded as a base64
  104904. * @param isBuffer defines whether the texture data are stored as a buffer
  104905. * @returns true if the loader can load the specified file
  104906. */
  104907. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104908. /**
  104909. * Transform the url before loading if required.
  104910. * @param rootUrl the url of the texture
  104911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104912. * @returns the transformed texture
  104913. */
  104914. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104915. /**
  104916. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104917. * @param rootUrl the url of the texture
  104918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104919. * @returns the fallback texture
  104920. */
  104921. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104922. /**
  104923. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104924. * @param data contains the texture data
  104925. * @param texture defines the BabylonJS internal texture
  104926. * @param createPolynomials will be true if polynomials have been requested
  104927. * @param onLoad defines the callback to trigger once the texture is ready
  104928. * @param onError defines the callback to trigger in case of error
  104929. */
  104930. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104931. /**
  104932. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104933. * @param data contains the texture data
  104934. * @param texture defines the BabylonJS internal texture
  104935. * @param callback defines the method to call once ready to upload
  104936. */
  104937. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104938. }
  104939. }
  104940. declare module BABYLON {
  104941. /**
  104942. * 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.
  104943. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104944. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104945. */
  104946. export class CustomProceduralTexture extends ProceduralTexture {
  104947. private _animate;
  104948. private _time;
  104949. private _config;
  104950. private _texturePath;
  104951. /**
  104952. * Instantiates a new Custom Procedural Texture.
  104953. * 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.
  104954. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104955. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104956. * @param name Define the name of the texture
  104957. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104958. * @param size Define the size of the texture to create
  104959. * @param scene Define the scene the texture belongs to
  104960. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104961. * @param generateMipMaps Define if the texture should creates mip maps or not
  104962. */
  104963. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104964. private _loadJson;
  104965. /**
  104966. * Is the texture ready to be used ? (rendered at least once)
  104967. * @returns true if ready, otherwise, false.
  104968. */
  104969. isReady(): boolean;
  104970. /**
  104971. * Render the texture to its associated render target.
  104972. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104973. */
  104974. render(useCameraPostProcess?: boolean): void;
  104975. /**
  104976. * Update the list of dependant textures samplers in the shader.
  104977. */
  104978. updateTextures(): void;
  104979. /**
  104980. * Update the uniform values of the procedural texture in the shader.
  104981. */
  104982. updateShaderUniforms(): void;
  104983. /**
  104984. * Define if the texture animates or not.
  104985. */
  104986. animate: boolean;
  104987. }
  104988. }
  104989. declare module BABYLON {
  104990. /** @hidden */
  104991. export var noisePixelShader: {
  104992. name: string;
  104993. shader: string;
  104994. };
  104995. }
  104996. declare module BABYLON {
  104997. /**
  104998. * Class used to generate noise procedural textures
  104999. */
  105000. export class NoiseProceduralTexture extends ProceduralTexture {
  105001. private _time;
  105002. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  105003. brightness: number;
  105004. /** Defines the number of octaves to process */
  105005. octaves: number;
  105006. /** Defines the level of persistence (0.8 by default) */
  105007. persistence: number;
  105008. /** Gets or sets animation speed factor (default is 1) */
  105009. animationSpeedFactor: number;
  105010. /**
  105011. * Creates a new NoiseProceduralTexture
  105012. * @param name defines the name fo the texture
  105013. * @param size defines the size of the texture (default is 256)
  105014. * @param scene defines the hosting scene
  105015. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  105016. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  105017. */
  105018. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  105019. private _updateShaderUniforms;
  105020. protected _getDefines(): string;
  105021. /** Generate the current state of the procedural texture */
  105022. render(useCameraPostProcess?: boolean): void;
  105023. /**
  105024. * Serializes this noise procedural texture
  105025. * @returns a serialized noise procedural texture object
  105026. */
  105027. serialize(): any;
  105028. /**
  105029. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105030. * @param parsedTexture defines parsed texture data
  105031. * @param scene defines the current scene
  105032. * @param rootUrl defines the root URL containing noise procedural texture information
  105033. * @returns a parsed NoiseProceduralTexture
  105034. */
  105035. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105036. }
  105037. }
  105038. declare module BABYLON {
  105039. /**
  105040. * Raw cube texture where the raw buffers are passed in
  105041. */
  105042. export class RawCubeTexture extends CubeTexture {
  105043. /**
  105044. * Creates a cube texture where the raw buffers are passed in.
  105045. * @param scene defines the scene the texture is attached to
  105046. * @param data defines the array of data to use to create each face
  105047. * @param size defines the size of the textures
  105048. * @param format defines the format of the data
  105049. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105050. * @param generateMipMaps defines if the engine should generate the mip levels
  105051. * @param invertY defines if data must be stored with Y axis inverted
  105052. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105053. * @param compression defines the compression used (null by default)
  105054. */
  105055. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105056. /**
  105057. * Updates the raw cube texture.
  105058. * @param data defines the data to store
  105059. * @param format defines the data format
  105060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105061. * @param invertY defines if data must be stored with Y axis inverted
  105062. * @param compression defines the compression used (null by default)
  105063. * @param level defines which level of the texture to update
  105064. */
  105065. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105066. /**
  105067. * Updates a raw cube texture with RGBD encoded data.
  105068. * @param data defines the array of data [mipmap][face] to use to create each face
  105069. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105070. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105071. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105072. * @returns a promsie that resolves when the operation is complete
  105073. */
  105074. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105075. /**
  105076. * Clones the raw cube texture.
  105077. * @return a new cube texture
  105078. */
  105079. clone(): CubeTexture;
  105080. /** @hidden */
  105081. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105082. }
  105083. }
  105084. declare module BABYLON {
  105085. /**
  105086. * Class used to store 3D textures containing user data
  105087. */
  105088. export class RawTexture3D extends Texture {
  105089. /** Gets or sets the texture format to use */
  105090. format: number;
  105091. private _engine;
  105092. /**
  105093. * Create a new RawTexture3D
  105094. * @param data defines the data of the texture
  105095. * @param width defines the width of the texture
  105096. * @param height defines the height of the texture
  105097. * @param depth defines the depth of the texture
  105098. * @param format defines the texture format to use
  105099. * @param scene defines the hosting scene
  105100. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105101. * @param invertY defines if texture must be stored with Y axis inverted
  105102. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105103. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105104. */
  105105. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105106. /** Gets or sets the texture format to use */
  105107. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105108. /**
  105109. * Update the texture with new data
  105110. * @param data defines the data to store in the texture
  105111. */
  105112. update(data: ArrayBufferView): void;
  105113. }
  105114. }
  105115. declare module BABYLON {
  105116. /**
  105117. * Creates a refraction texture used by refraction channel of the standard material.
  105118. * It is like a mirror but to see through a material.
  105119. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105120. */
  105121. export class RefractionTexture extends RenderTargetTexture {
  105122. /**
  105123. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105124. * 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.
  105125. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105126. */
  105127. refractionPlane: Plane;
  105128. /**
  105129. * Define how deep under the surface we should see.
  105130. */
  105131. depth: number;
  105132. /**
  105133. * Creates a refraction texture used by refraction channel of the standard material.
  105134. * It is like a mirror but to see through a material.
  105135. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105136. * @param name Define the texture name
  105137. * @param size Define the size of the underlying texture
  105138. * @param scene Define the scene the refraction belongs to
  105139. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105140. */
  105141. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105142. /**
  105143. * Clone the refraction texture.
  105144. * @returns the cloned texture
  105145. */
  105146. clone(): RefractionTexture;
  105147. /**
  105148. * Serialize the texture to a JSON representation you could use in Parse later on
  105149. * @returns the serialized JSON representation
  105150. */
  105151. serialize(): any;
  105152. }
  105153. }
  105154. declare module BABYLON {
  105155. /**
  105156. * Configuration for Draco compression
  105157. */
  105158. export interface IDracoCompressionConfiguration {
  105159. /**
  105160. * Configuration for the decoder.
  105161. */
  105162. decoder?: {
  105163. /**
  105164. * The url to the WebAssembly module.
  105165. */
  105166. wasmUrl?: string;
  105167. /**
  105168. * The url to the WebAssembly binary.
  105169. */
  105170. wasmBinaryUrl?: string;
  105171. /**
  105172. * The url to the fallback JavaScript module.
  105173. */
  105174. fallbackUrl?: string;
  105175. };
  105176. }
  105177. /**
  105178. * Draco compression (https://google.github.io/draco/)
  105179. *
  105180. * This class wraps the Draco module.
  105181. *
  105182. * **Encoder**
  105183. *
  105184. * The encoder is not currently implemented.
  105185. *
  105186. * **Decoder**
  105187. *
  105188. * 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.
  105189. *
  105190. * To update the configuration, use the following code:
  105191. * ```javascript
  105192. * DracoCompression.Configuration = {
  105193. * decoder: {
  105194. * wasmUrl: "<url to the WebAssembly library>",
  105195. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105196. * fallbackUrl: "<url to the fallback JavaScript library>",
  105197. * }
  105198. * };
  105199. * ```
  105200. *
  105201. * 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.
  105202. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105203. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105204. *
  105205. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105206. * ```javascript
  105207. * var dracoCompression = new DracoCompression();
  105208. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105209. * [VertexBuffer.PositionKind]: 0
  105210. * });
  105211. * ```
  105212. *
  105213. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105214. */
  105215. export class DracoCompression implements IDisposable {
  105216. private static _DecoderModulePromise;
  105217. /**
  105218. * The configuration. Defaults to the following urls:
  105219. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105220. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105221. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105222. */
  105223. static Configuration: IDracoCompressionConfiguration;
  105224. /**
  105225. * Returns true if the decoder is available.
  105226. */
  105227. static readonly DecoderAvailable: boolean;
  105228. /**
  105229. * Constructor
  105230. */
  105231. constructor();
  105232. /**
  105233. * Stop all async operations and release resources.
  105234. */
  105235. dispose(): void;
  105236. /**
  105237. * Decode Draco compressed mesh data to vertex data.
  105238. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105239. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105240. * @returns A promise that resolves with the decoded vertex data
  105241. */
  105242. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105243. [kind: string]: number;
  105244. }): Promise<VertexData>;
  105245. private static _GetDecoderModule;
  105246. private static _LoadScriptAsync;
  105247. private static _LoadFileAsync;
  105248. }
  105249. }
  105250. declare module BABYLON {
  105251. /**
  105252. * Class for building Constructive Solid Geometry
  105253. */
  105254. export class CSG {
  105255. private polygons;
  105256. /**
  105257. * The world matrix
  105258. */
  105259. matrix: Matrix;
  105260. /**
  105261. * Stores the position
  105262. */
  105263. position: Vector3;
  105264. /**
  105265. * Stores the rotation
  105266. */
  105267. rotation: Vector3;
  105268. /**
  105269. * Stores the rotation quaternion
  105270. */
  105271. rotationQuaternion: Nullable<Quaternion>;
  105272. /**
  105273. * Stores the scaling vector
  105274. */
  105275. scaling: Vector3;
  105276. /**
  105277. * Convert the Mesh to CSG
  105278. * @param mesh The Mesh to convert to CSG
  105279. * @returns A new CSG from the Mesh
  105280. */
  105281. static FromMesh(mesh: Mesh): CSG;
  105282. /**
  105283. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105284. * @param polygons Polygons used to construct a CSG solid
  105285. */
  105286. private static FromPolygons;
  105287. /**
  105288. * Clones, or makes a deep copy, of the CSG
  105289. * @returns A new CSG
  105290. */
  105291. clone(): CSG;
  105292. /**
  105293. * Unions this CSG with another CSG
  105294. * @param csg The CSG to union against this CSG
  105295. * @returns The unioned CSG
  105296. */
  105297. union(csg: CSG): CSG;
  105298. /**
  105299. * Unions this CSG with another CSG in place
  105300. * @param csg The CSG to union against this CSG
  105301. */
  105302. unionInPlace(csg: CSG): void;
  105303. /**
  105304. * Subtracts this CSG with another CSG
  105305. * @param csg The CSG to subtract against this CSG
  105306. * @returns A new CSG
  105307. */
  105308. subtract(csg: CSG): CSG;
  105309. /**
  105310. * Subtracts this CSG with another CSG in place
  105311. * @param csg The CSG to subtact against this CSG
  105312. */
  105313. subtractInPlace(csg: CSG): void;
  105314. /**
  105315. * Intersect this CSG with another CSG
  105316. * @param csg The CSG to intersect against this CSG
  105317. * @returns A new CSG
  105318. */
  105319. intersect(csg: CSG): CSG;
  105320. /**
  105321. * Intersects this CSG with another CSG in place
  105322. * @param csg The CSG to intersect against this CSG
  105323. */
  105324. intersectInPlace(csg: CSG): void;
  105325. /**
  105326. * Return a new CSG solid with solid and empty space switched. This solid is
  105327. * not modified.
  105328. * @returns A new CSG solid with solid and empty space switched
  105329. */
  105330. inverse(): CSG;
  105331. /**
  105332. * Inverses the CSG in place
  105333. */
  105334. inverseInPlace(): void;
  105335. /**
  105336. * This is used to keep meshes transformations so they can be restored
  105337. * when we build back a Babylon Mesh
  105338. * NB : All CSG operations are performed in world coordinates
  105339. * @param csg The CSG to copy the transform attributes from
  105340. * @returns This CSG
  105341. */
  105342. copyTransformAttributes(csg: CSG): CSG;
  105343. /**
  105344. * Build Raw mesh from CSG
  105345. * Coordinates here are in world space
  105346. * @param name The name of the mesh geometry
  105347. * @param scene The Scene
  105348. * @param keepSubMeshes Specifies if the submeshes should be kept
  105349. * @returns A new Mesh
  105350. */
  105351. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105352. /**
  105353. * Build Mesh from CSG taking material and transforms into account
  105354. * @param name The name of the Mesh
  105355. * @param material The material of the Mesh
  105356. * @param scene The Scene
  105357. * @param keepSubMeshes Specifies if submeshes should be kept
  105358. * @returns The new Mesh
  105359. */
  105360. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105361. }
  105362. }
  105363. declare module BABYLON {
  105364. /**
  105365. * Class used to create a trail following a mesh
  105366. */
  105367. export class TrailMesh extends Mesh {
  105368. private _generator;
  105369. private _autoStart;
  105370. private _running;
  105371. private _diameter;
  105372. private _length;
  105373. private _sectionPolygonPointsCount;
  105374. private _sectionVectors;
  105375. private _sectionNormalVectors;
  105376. private _beforeRenderObserver;
  105377. /**
  105378. * @constructor
  105379. * @param name The value used by scene.getMeshByName() to do a lookup.
  105380. * @param generator The mesh to generate a trail.
  105381. * @param scene The scene to add this mesh to.
  105382. * @param diameter Diameter of trailing mesh. Default is 1.
  105383. * @param length Length of trailing mesh. Default is 60.
  105384. * @param autoStart Automatically start trailing mesh. Default true.
  105385. */
  105386. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105387. /**
  105388. * "TrailMesh"
  105389. * @returns "TrailMesh"
  105390. */
  105391. getClassName(): string;
  105392. private _createMesh;
  105393. /**
  105394. * Start trailing mesh.
  105395. */
  105396. start(): void;
  105397. /**
  105398. * Stop trailing mesh.
  105399. */
  105400. stop(): void;
  105401. /**
  105402. * Update trailing mesh geometry.
  105403. */
  105404. update(): void;
  105405. /**
  105406. * Returns a new TrailMesh object.
  105407. * @param name is a string, the name given to the new mesh
  105408. * @param newGenerator use new generator object for cloned trail mesh
  105409. * @returns a new mesh
  105410. */
  105411. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105412. /**
  105413. * Serializes this trail mesh
  105414. * @param serializationObject object to write serialization to
  105415. */
  105416. serialize(serializationObject: any): void;
  105417. /**
  105418. * Parses a serialized trail mesh
  105419. * @param parsedMesh the serialized mesh
  105420. * @param scene the scene to create the trail mesh in
  105421. * @returns the created trail mesh
  105422. */
  105423. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105424. }
  105425. }
  105426. declare module BABYLON {
  105427. /**
  105428. * Class containing static functions to help procedurally build meshes
  105429. */
  105430. export class RibbonBuilder {
  105431. /**
  105432. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105433. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105434. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105435. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105436. * * 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
  105437. * * 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
  105438. * * 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
  105439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105440. * * If you create a double-sided mesh, you can choose what parts of 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
  105441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105442. * * 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
  105443. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105444. * * 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
  105445. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105447. * @param name defines the name of the mesh
  105448. * @param options defines the options used to create the mesh
  105449. * @param scene defines the hosting scene
  105450. * @returns the ribbon mesh
  105451. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105452. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105453. */
  105454. static CreateRibbon(name: string, options: {
  105455. pathArray: Vector3[][];
  105456. closeArray?: boolean;
  105457. closePath?: boolean;
  105458. offset?: number;
  105459. updatable?: boolean;
  105460. sideOrientation?: number;
  105461. frontUVs?: Vector4;
  105462. backUVs?: Vector4;
  105463. instance?: Mesh;
  105464. invertUV?: boolean;
  105465. uvs?: Vector2[];
  105466. colors?: Color4[];
  105467. }, scene?: Nullable<Scene>): Mesh;
  105468. }
  105469. }
  105470. declare module BABYLON {
  105471. /**
  105472. * Class containing static functions to help procedurally build meshes
  105473. */
  105474. export class TorusKnotBuilder {
  105475. /**
  105476. * Creates a torus knot mesh
  105477. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105478. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105479. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105480. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105482. * * If you create a double-sided mesh, you can choose what parts of 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
  105483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105484. * @param name defines the name of the mesh
  105485. * @param options defines the options used to create the mesh
  105486. * @param scene defines the hosting scene
  105487. * @returns the torus knot mesh
  105488. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105489. */
  105490. static CreateTorusKnot(name: string, options: {
  105491. radius?: number;
  105492. tube?: number;
  105493. radialSegments?: number;
  105494. tubularSegments?: number;
  105495. p?: number;
  105496. q?: number;
  105497. updatable?: boolean;
  105498. sideOrientation?: number;
  105499. frontUVs?: Vector4;
  105500. backUVs?: Vector4;
  105501. }, scene: any): Mesh;
  105502. }
  105503. }
  105504. declare module BABYLON {
  105505. /**
  105506. * Polygon
  105507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105508. */
  105509. export class Polygon {
  105510. /**
  105511. * Creates a rectangle
  105512. * @param xmin bottom X coord
  105513. * @param ymin bottom Y coord
  105514. * @param xmax top X coord
  105515. * @param ymax top Y coord
  105516. * @returns points that make the resulting rectation
  105517. */
  105518. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105519. /**
  105520. * Creates a circle
  105521. * @param radius radius of circle
  105522. * @param cx scale in x
  105523. * @param cy scale in y
  105524. * @param numberOfSides number of sides that make up the circle
  105525. * @returns points that make the resulting circle
  105526. */
  105527. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105528. /**
  105529. * Creates a polygon from input string
  105530. * @param input Input polygon data
  105531. * @returns the parsed points
  105532. */
  105533. static Parse(input: string): Vector2[];
  105534. /**
  105535. * Starts building a polygon from x and y coordinates
  105536. * @param x x coordinate
  105537. * @param y y coordinate
  105538. * @returns the started path2
  105539. */
  105540. static StartingAt(x: number, y: number): Path2;
  105541. }
  105542. /**
  105543. * Builds a polygon
  105544. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105545. */
  105546. export class PolygonMeshBuilder {
  105547. private _points;
  105548. private _outlinepoints;
  105549. private _holes;
  105550. private _name;
  105551. private _scene;
  105552. private _epoints;
  105553. private _eholes;
  105554. private _addToepoint;
  105555. /**
  105556. * Babylon reference to the earcut plugin.
  105557. */
  105558. bjsEarcut: any;
  105559. /**
  105560. * Creates a PolygonMeshBuilder
  105561. * @param name name of the builder
  105562. * @param contours Path of the polygon
  105563. * @param scene scene to add to
  105564. * @param earcutInjection can be used to inject your own earcut reference
  105565. */
  105566. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105567. /**
  105568. * Adds a whole within the polygon
  105569. * @param hole Array of points defining the hole
  105570. * @returns this
  105571. */
  105572. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105573. /**
  105574. * Creates the polygon
  105575. * @param updatable If the mesh should be updatable
  105576. * @param depth The depth of the mesh created
  105577. * @returns the created mesh
  105578. */
  105579. build(updatable?: boolean, depth?: number): Mesh;
  105580. /**
  105581. * Adds a side to the polygon
  105582. * @param positions points that make the polygon
  105583. * @param normals normals of the polygon
  105584. * @param uvs uvs of the polygon
  105585. * @param indices indices of the polygon
  105586. * @param bounds bounds of the polygon
  105587. * @param points points of the polygon
  105588. * @param depth depth of the polygon
  105589. * @param flip flip of the polygon
  105590. */
  105591. private addSide;
  105592. }
  105593. }
  105594. declare module BABYLON {
  105595. /**
  105596. * Class containing static functions to help procedurally build meshes
  105597. */
  105598. export class PolygonBuilder {
  105599. /**
  105600. * Creates a polygon mesh
  105601. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105602. * * 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
  105603. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105606. * * Remember you can only change the shape positions, not their number when updating a polygon
  105607. * @param name defines the name of the mesh
  105608. * @param options defines the options used to create the mesh
  105609. * @param scene defines the hosting scene
  105610. * @param earcutInjection can be used to inject your own earcut reference
  105611. * @returns the polygon mesh
  105612. */
  105613. static CreatePolygon(name: string, options: {
  105614. shape: Vector3[];
  105615. holes?: Vector3[][];
  105616. depth?: number;
  105617. faceUV?: Vector4[];
  105618. faceColors?: Color4[];
  105619. updatable?: boolean;
  105620. sideOrientation?: number;
  105621. frontUVs?: Vector4;
  105622. backUVs?: Vector4;
  105623. }, scene: Scene, earcutInjection?: any): Mesh;
  105624. /**
  105625. * Creates an extruded polygon mesh, with depth in the Y direction.
  105626. * * 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)
  105627. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105628. * @param name defines the name of the mesh
  105629. * @param options defines the options used to create the mesh
  105630. * @param scene defines the hosting scene
  105631. * @param earcutInjection can be used to inject your own earcut reference
  105632. * @returns the polygon mesh
  105633. */
  105634. static ExtrudePolygon(name: string, options: {
  105635. shape: Vector3[];
  105636. holes?: Vector3[][];
  105637. depth?: number;
  105638. faceUV?: Vector4[];
  105639. faceColors?: Color4[];
  105640. updatable?: boolean;
  105641. sideOrientation?: number;
  105642. frontUVs?: Vector4;
  105643. backUVs?: Vector4;
  105644. }, scene: Scene, earcutInjection?: any): Mesh;
  105645. }
  105646. }
  105647. declare module BABYLON {
  105648. /**
  105649. * Class containing static functions to help procedurally build meshes
  105650. */
  105651. export class ShapeBuilder {
  105652. /**
  105653. * 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.
  105654. * * 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.
  105655. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105656. * * 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.
  105657. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105658. * * 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
  105659. * * 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
  105660. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105665. * @param name defines the name of the mesh
  105666. * @param options defines the options used to create the mesh
  105667. * @param scene defines the hosting scene
  105668. * @returns the extruded shape mesh
  105669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105671. */
  105672. static ExtrudeShape(name: string, options: {
  105673. shape: Vector3[];
  105674. path: Vector3[];
  105675. scale?: number;
  105676. rotation?: number;
  105677. cap?: number;
  105678. updatable?: boolean;
  105679. sideOrientation?: number;
  105680. frontUVs?: Vector4;
  105681. backUVs?: Vector4;
  105682. instance?: Mesh;
  105683. invertUV?: boolean;
  105684. }, scene?: Nullable<Scene>): Mesh;
  105685. /**
  105686. * Creates an custom extruded shape mesh.
  105687. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105688. * * 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.
  105689. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105690. * * 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
  105691. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105692. * * 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
  105693. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105694. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105695. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105696. * * 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
  105697. * * 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
  105698. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105700. * * If you create a double-sided mesh, you can choose what parts of 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
  105701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105703. * @param name defines the name of the mesh
  105704. * @param options defines the options used to create the mesh
  105705. * @param scene defines the hosting scene
  105706. * @returns the custom extruded shape mesh
  105707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105708. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105710. */
  105711. static ExtrudeShapeCustom(name: string, options: {
  105712. shape: Vector3[];
  105713. path: Vector3[];
  105714. scaleFunction?: any;
  105715. rotationFunction?: any;
  105716. ribbonCloseArray?: boolean;
  105717. ribbonClosePath?: boolean;
  105718. cap?: number;
  105719. updatable?: boolean;
  105720. sideOrientation?: number;
  105721. frontUVs?: Vector4;
  105722. backUVs?: Vector4;
  105723. instance?: Mesh;
  105724. invertUV?: boolean;
  105725. }, scene: Scene): Mesh;
  105726. private static _ExtrudeShapeGeneric;
  105727. }
  105728. }
  105729. declare module BABYLON {
  105730. /**
  105731. * Class containing static functions to help procedurally build meshes
  105732. */
  105733. export class LatheBuilder {
  105734. /**
  105735. * Creates lathe mesh.
  105736. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105737. * * 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
  105738. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105739. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105740. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105741. * * 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
  105742. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105743. * * 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
  105744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105748. * @param name defines the name of the mesh
  105749. * @param options defines the options used to create the mesh
  105750. * @param scene defines the hosting scene
  105751. * @returns the lathe mesh
  105752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105753. */
  105754. static CreateLathe(name: string, options: {
  105755. shape: Vector3[];
  105756. radius?: number;
  105757. tessellation?: number;
  105758. clip?: number;
  105759. arc?: number;
  105760. closed?: boolean;
  105761. updatable?: boolean;
  105762. sideOrientation?: number;
  105763. frontUVs?: Vector4;
  105764. backUVs?: Vector4;
  105765. cap?: number;
  105766. invertUV?: boolean;
  105767. }, scene: Scene): Mesh;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /**
  105772. * Class containing static functions to help procedurally build meshes
  105773. */
  105774. export class TubeBuilder {
  105775. /**
  105776. * Creates a tube mesh.
  105777. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105778. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105779. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105780. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105781. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105782. * * 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)
  105783. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105784. * * 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
  105785. * * 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
  105786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105787. * * If you create a double-sided mesh, you can choose what parts of 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
  105788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105790. * @param name defines the name of the mesh
  105791. * @param options defines the options used to create the mesh
  105792. * @param scene defines the hosting scene
  105793. * @returns the tube mesh
  105794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105795. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105796. */
  105797. static CreateTube(name: string, options: {
  105798. path: Vector3[];
  105799. radius?: number;
  105800. tessellation?: number;
  105801. radiusFunction?: {
  105802. (i: number, distance: number): number;
  105803. };
  105804. cap?: number;
  105805. arc?: number;
  105806. updatable?: boolean;
  105807. sideOrientation?: number;
  105808. frontUVs?: Vector4;
  105809. backUVs?: Vector4;
  105810. instance?: Mesh;
  105811. invertUV?: boolean;
  105812. }, scene: Scene): Mesh;
  105813. }
  105814. }
  105815. declare module BABYLON {
  105816. /**
  105817. * Class containing static functions to help procedurally build meshes
  105818. */
  105819. export class IcoSphereBuilder {
  105820. /**
  105821. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105822. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105823. * * 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`)
  105824. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105825. * * 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
  105826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105827. * * If you create a double-sided mesh, you can choose what parts of 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
  105828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105829. * @param name defines the name of the mesh
  105830. * @param options defines the options used to create the mesh
  105831. * @param scene defines the hosting scene
  105832. * @returns the icosahedron mesh
  105833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105834. */
  105835. static CreateIcoSphere(name: string, options: {
  105836. radius?: number;
  105837. radiusX?: number;
  105838. radiusY?: number;
  105839. radiusZ?: number;
  105840. flat?: boolean;
  105841. subdivisions?: number;
  105842. sideOrientation?: number;
  105843. frontUVs?: Vector4;
  105844. backUVs?: Vector4;
  105845. updatable?: boolean;
  105846. }, scene: Scene): Mesh;
  105847. }
  105848. }
  105849. declare module BABYLON {
  105850. /**
  105851. * Class containing static functions to help procedurally build meshes
  105852. */
  105853. export class DecalBuilder {
  105854. /**
  105855. * Creates a decal mesh.
  105856. * 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
  105857. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105858. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105859. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105860. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105861. * @param name defines the name of the mesh
  105862. * @param sourceMesh defines the mesh where the decal must be applied
  105863. * @param options defines the options used to create the mesh
  105864. * @param scene defines the hosting scene
  105865. * @returns the decal mesh
  105866. * @see https://doc.babylonjs.com/how_to/decals
  105867. */
  105868. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105869. position?: Vector3;
  105870. normal?: Vector3;
  105871. size?: Vector3;
  105872. angle?: number;
  105873. }): Mesh;
  105874. }
  105875. }
  105876. declare module BABYLON {
  105877. /**
  105878. * Class containing static functions to help procedurally build meshes
  105879. */
  105880. export class MeshBuilder {
  105881. /**
  105882. * Creates a box mesh
  105883. * * The parameter `size` sets the size (float) of each box side (default 1)
  105884. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105885. * * 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)
  105886. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105888. * * If you create a double-sided mesh, you can choose what parts of 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
  105889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105891. * @param name defines the name of the mesh
  105892. * @param options defines the options used to create the mesh
  105893. * @param scene defines the hosting scene
  105894. * @returns the box mesh
  105895. */
  105896. static CreateBox(name: string, options: {
  105897. size?: number;
  105898. width?: number;
  105899. height?: number;
  105900. depth?: number;
  105901. faceUV?: Vector4[];
  105902. faceColors?: Color4[];
  105903. sideOrientation?: number;
  105904. frontUVs?: Vector4;
  105905. backUVs?: Vector4;
  105906. updatable?: boolean;
  105907. }, scene?: Nullable<Scene>): Mesh;
  105908. /**
  105909. * Creates a sphere mesh
  105910. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105911. * * 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`)
  105912. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105913. * * 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
  105914. * * 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)
  105915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105916. * * If you create a double-sided mesh, you can choose what parts of 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
  105917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105918. * @param name defines the name of the mesh
  105919. * @param options defines the options used to create the mesh
  105920. * @param scene defines the hosting scene
  105921. * @returns the sphere mesh
  105922. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105923. */
  105924. static CreateSphere(name: string, options: {
  105925. segments?: number;
  105926. diameter?: number;
  105927. diameterX?: number;
  105928. diameterY?: number;
  105929. diameterZ?: number;
  105930. arc?: number;
  105931. slice?: number;
  105932. sideOrientation?: number;
  105933. frontUVs?: Vector4;
  105934. backUVs?: Vector4;
  105935. updatable?: boolean;
  105936. }, scene: any): Mesh;
  105937. /**
  105938. * Creates a plane polygonal mesh. By default, this is a disc
  105939. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105940. * * 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
  105941. * * 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
  105942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105943. * * If you create a double-sided mesh, you can choose what parts of 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
  105944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105945. * @param name defines the name of the mesh
  105946. * @param options defines the options used to create the mesh
  105947. * @param scene defines the hosting scene
  105948. * @returns the plane polygonal mesh
  105949. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105950. */
  105951. static CreateDisc(name: string, options: {
  105952. radius?: number;
  105953. tessellation?: number;
  105954. arc?: number;
  105955. updatable?: boolean;
  105956. sideOrientation?: number;
  105957. frontUVs?: Vector4;
  105958. backUVs?: Vector4;
  105959. }, scene?: Nullable<Scene>): Mesh;
  105960. /**
  105961. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105962. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105963. * * 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`)
  105964. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105965. * * 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
  105966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105967. * * If you create a double-sided mesh, you can choose what parts of 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
  105968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105969. * @param name defines the name of the mesh
  105970. * @param options defines the options used to create the mesh
  105971. * @param scene defines the hosting scene
  105972. * @returns the icosahedron mesh
  105973. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105974. */
  105975. static CreateIcoSphere(name: string, options: {
  105976. radius?: number;
  105977. radiusX?: number;
  105978. radiusY?: number;
  105979. radiusZ?: number;
  105980. flat?: boolean;
  105981. subdivisions?: number;
  105982. sideOrientation?: number;
  105983. frontUVs?: Vector4;
  105984. backUVs?: Vector4;
  105985. updatable?: boolean;
  105986. }, scene: Scene): Mesh;
  105987. /**
  105988. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105989. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105990. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105991. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105992. * * 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
  105993. * * 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
  105994. * * 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
  105995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105996. * * If you create a double-sided mesh, you can choose what parts of 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
  105997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105998. * * 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
  105999. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106000. * * 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
  106001. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106003. * @param name defines the name of the mesh
  106004. * @param options defines the options used to create the mesh
  106005. * @param scene defines the hosting scene
  106006. * @returns the ribbon mesh
  106007. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106009. */
  106010. static CreateRibbon(name: string, options: {
  106011. pathArray: Vector3[][];
  106012. closeArray?: boolean;
  106013. closePath?: boolean;
  106014. offset?: number;
  106015. updatable?: boolean;
  106016. sideOrientation?: number;
  106017. frontUVs?: Vector4;
  106018. backUVs?: Vector4;
  106019. instance?: Mesh;
  106020. invertUV?: boolean;
  106021. uvs?: Vector2[];
  106022. colors?: Color4[];
  106023. }, scene?: Nullable<Scene>): Mesh;
  106024. /**
  106025. * Creates a cylinder or a cone mesh
  106026. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106027. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106028. * * 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.
  106029. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106030. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106031. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106032. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106033. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106034. * * 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).
  106035. * * 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
  106036. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106037. * * 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
  106038. * * 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.
  106039. * * If `enclose` is false, a ring surface is one element.
  106040. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106041. * * 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
  106042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106043. * * If you create a double-sided mesh, you can choose what parts of 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
  106044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106045. * @param name defines the name of the mesh
  106046. * @param options defines the options used to create the mesh
  106047. * @param scene defines the hosting scene
  106048. * @returns the cylinder mesh
  106049. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106050. */
  106051. static CreateCylinder(name: string, options: {
  106052. height?: number;
  106053. diameterTop?: number;
  106054. diameterBottom?: number;
  106055. diameter?: number;
  106056. tessellation?: number;
  106057. subdivisions?: number;
  106058. arc?: number;
  106059. faceColors?: Color4[];
  106060. faceUV?: Vector4[];
  106061. updatable?: boolean;
  106062. hasRings?: boolean;
  106063. enclose?: boolean;
  106064. sideOrientation?: number;
  106065. frontUVs?: Vector4;
  106066. backUVs?: Vector4;
  106067. }, scene: any): Mesh;
  106068. /**
  106069. * Creates a torus mesh
  106070. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106071. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106072. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106074. * * If you create a double-sided mesh, you can choose what parts of 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
  106075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106076. * @param name defines the name of the mesh
  106077. * @param options defines the options used to create the mesh
  106078. * @param scene defines the hosting scene
  106079. * @returns the torus mesh
  106080. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106081. */
  106082. static CreateTorus(name: string, options: {
  106083. diameter?: number;
  106084. thickness?: number;
  106085. tessellation?: number;
  106086. updatable?: boolean;
  106087. sideOrientation?: number;
  106088. frontUVs?: Vector4;
  106089. backUVs?: Vector4;
  106090. }, scene: any): Mesh;
  106091. /**
  106092. * Creates a torus knot mesh
  106093. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106094. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106095. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106096. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106098. * * If you create a double-sided mesh, you can choose what parts of 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
  106099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106100. * @param name defines the name of the mesh
  106101. * @param options defines the options used to create the mesh
  106102. * @param scene defines the hosting scene
  106103. * @returns the torus knot mesh
  106104. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106105. */
  106106. static CreateTorusKnot(name: string, options: {
  106107. radius?: number;
  106108. tube?: number;
  106109. radialSegments?: number;
  106110. tubularSegments?: number;
  106111. p?: number;
  106112. q?: number;
  106113. updatable?: boolean;
  106114. sideOrientation?: number;
  106115. frontUVs?: Vector4;
  106116. backUVs?: Vector4;
  106117. }, scene: any): Mesh;
  106118. /**
  106119. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106120. * * 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
  106121. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106122. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106123. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106124. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106125. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106126. * * 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
  106127. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106130. * @param name defines the name of the new line system
  106131. * @param options defines the options used to create the line system
  106132. * @param scene defines the hosting scene
  106133. * @returns a new line system mesh
  106134. */
  106135. static CreateLineSystem(name: string, options: {
  106136. lines: Vector3[][];
  106137. updatable?: boolean;
  106138. instance?: Nullable<LinesMesh>;
  106139. colors?: Nullable<Color4[][]>;
  106140. useVertexAlpha?: boolean;
  106141. }, scene: Nullable<Scene>): LinesMesh;
  106142. /**
  106143. * Creates a line mesh
  106144. * 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
  106145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106146. * * The parameter `points` is an array successive Vector3
  106147. * * 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
  106148. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106149. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106150. * * When updating an instance, remember that only point positions can change, not the number of points
  106151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106153. * @param name defines the name of the new line system
  106154. * @param options defines the options used to create the line system
  106155. * @param scene defines the hosting scene
  106156. * @returns a new line mesh
  106157. */
  106158. static CreateLines(name: string, options: {
  106159. points: Vector3[];
  106160. updatable?: boolean;
  106161. instance?: Nullable<LinesMesh>;
  106162. colors?: Color4[];
  106163. useVertexAlpha?: boolean;
  106164. }, scene?: Nullable<Scene>): LinesMesh;
  106165. /**
  106166. * Creates a dashed line mesh
  106167. * * 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
  106168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106169. * * The parameter `points` is an array successive Vector3
  106170. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106171. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106172. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106173. * * 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
  106174. * * When updating an instance, remember that only point positions can change, not the number of points
  106175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106176. * @param name defines the name of the mesh
  106177. * @param options defines the options used to create the mesh
  106178. * @param scene defines the hosting scene
  106179. * @returns the dashed line mesh
  106180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106181. */
  106182. static CreateDashedLines(name: string, options: {
  106183. points: Vector3[];
  106184. dashSize?: number;
  106185. gapSize?: number;
  106186. dashNb?: number;
  106187. updatable?: boolean;
  106188. instance?: LinesMesh;
  106189. }, scene?: Nullable<Scene>): LinesMesh;
  106190. /**
  106191. * 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.
  106192. * * 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.
  106193. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106194. * * 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.
  106195. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106196. * * 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
  106197. * * 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
  106198. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106200. * * If you create a double-sided mesh, you can choose what parts of 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
  106201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106203. * @param name defines the name of the mesh
  106204. * @param options defines the options used to create the mesh
  106205. * @param scene defines the hosting scene
  106206. * @returns the extruded shape mesh
  106207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106209. */
  106210. static ExtrudeShape(name: string, options: {
  106211. shape: Vector3[];
  106212. path: Vector3[];
  106213. scale?: number;
  106214. rotation?: number;
  106215. cap?: number;
  106216. updatable?: boolean;
  106217. sideOrientation?: number;
  106218. frontUVs?: Vector4;
  106219. backUVs?: Vector4;
  106220. instance?: Mesh;
  106221. invertUV?: boolean;
  106222. }, scene?: Nullable<Scene>): Mesh;
  106223. /**
  106224. * Creates an custom extruded shape mesh.
  106225. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106226. * * 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.
  106227. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106228. * * 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
  106229. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106230. * * 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
  106231. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106232. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106233. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106234. * * 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
  106235. * * 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
  106236. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106238. * * If you create a double-sided mesh, you can choose what parts of 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
  106239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106241. * @param name defines the name of the mesh
  106242. * @param options defines the options used to create the mesh
  106243. * @param scene defines the hosting scene
  106244. * @returns the custom extruded shape mesh
  106245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106248. */
  106249. static ExtrudeShapeCustom(name: string, options: {
  106250. shape: Vector3[];
  106251. path: Vector3[];
  106252. scaleFunction?: any;
  106253. rotationFunction?: any;
  106254. ribbonCloseArray?: boolean;
  106255. ribbonClosePath?: boolean;
  106256. cap?: number;
  106257. updatable?: boolean;
  106258. sideOrientation?: number;
  106259. frontUVs?: Vector4;
  106260. backUVs?: Vector4;
  106261. instance?: Mesh;
  106262. invertUV?: boolean;
  106263. }, scene: Scene): Mesh;
  106264. /**
  106265. * Creates lathe mesh.
  106266. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106267. * * 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
  106268. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106269. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106270. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106271. * * 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
  106272. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106273. * * 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
  106274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106275. * * If you create a double-sided mesh, you can choose what parts of 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
  106276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106278. * @param name defines the name of the mesh
  106279. * @param options defines the options used to create the mesh
  106280. * @param scene defines the hosting scene
  106281. * @returns the lathe mesh
  106282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106283. */
  106284. static CreateLathe(name: string, options: {
  106285. shape: Vector3[];
  106286. radius?: number;
  106287. tessellation?: number;
  106288. clip?: number;
  106289. arc?: number;
  106290. closed?: boolean;
  106291. updatable?: boolean;
  106292. sideOrientation?: number;
  106293. frontUVs?: Vector4;
  106294. backUVs?: Vector4;
  106295. cap?: number;
  106296. invertUV?: boolean;
  106297. }, scene: Scene): Mesh;
  106298. /**
  106299. * Creates a plane mesh
  106300. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106301. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106302. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106304. * * If you create a double-sided mesh, you can choose what parts of 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
  106305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106306. * @param name defines the name of the mesh
  106307. * @param options defines the options used to create the mesh
  106308. * @param scene defines the hosting scene
  106309. * @returns the plane mesh
  106310. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106311. */
  106312. static CreatePlane(name: string, options: {
  106313. size?: number;
  106314. width?: number;
  106315. height?: number;
  106316. sideOrientation?: number;
  106317. frontUVs?: Vector4;
  106318. backUVs?: Vector4;
  106319. updatable?: boolean;
  106320. sourcePlane?: Plane;
  106321. }, scene: Scene): Mesh;
  106322. /**
  106323. * Creates a ground mesh
  106324. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106325. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106327. * @param name defines the name of the mesh
  106328. * @param options defines the options used to create the mesh
  106329. * @param scene defines the hosting scene
  106330. * @returns the ground mesh
  106331. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106332. */
  106333. static CreateGround(name: string, options: {
  106334. width?: number;
  106335. height?: number;
  106336. subdivisions?: number;
  106337. subdivisionsX?: number;
  106338. subdivisionsY?: number;
  106339. updatable?: boolean;
  106340. }, scene: any): Mesh;
  106341. /**
  106342. * Creates a tiled ground mesh
  106343. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106344. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106345. * * 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
  106346. * * 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
  106347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106348. * @param name defines the name of the mesh
  106349. * @param options defines the options used to create the mesh
  106350. * @param scene defines the hosting scene
  106351. * @returns the tiled ground mesh
  106352. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106353. */
  106354. static CreateTiledGround(name: string, options: {
  106355. xmin: number;
  106356. zmin: number;
  106357. xmax: number;
  106358. zmax: number;
  106359. subdivisions?: {
  106360. w: number;
  106361. h: number;
  106362. };
  106363. precision?: {
  106364. w: number;
  106365. h: number;
  106366. };
  106367. updatable?: boolean;
  106368. }, scene: Scene): Mesh;
  106369. /**
  106370. * Creates a ground mesh from a height map
  106371. * * The parameter `url` sets the URL of the height map image resource.
  106372. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106373. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106374. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106375. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106376. * * 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.
  106377. * * 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).
  106378. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106380. * @param name defines the name of the mesh
  106381. * @param url defines the url to the height map
  106382. * @param options defines the options used to create the mesh
  106383. * @param scene defines the hosting scene
  106384. * @returns the ground mesh
  106385. * @see https://doc.babylonjs.com/babylon101/height_map
  106386. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106387. */
  106388. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106389. width?: number;
  106390. height?: number;
  106391. subdivisions?: number;
  106392. minHeight?: number;
  106393. maxHeight?: number;
  106394. colorFilter?: Color3;
  106395. alphaFilter?: number;
  106396. updatable?: boolean;
  106397. onReady?: (mesh: GroundMesh) => void;
  106398. }, scene: Scene): GroundMesh;
  106399. /**
  106400. * Creates a polygon mesh
  106401. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106402. * * 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
  106403. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106406. * * Remember you can only change the shape positions, not their number when updating a polygon
  106407. * @param name defines the name of the mesh
  106408. * @param options defines the options used to create the mesh
  106409. * @param scene defines the hosting scene
  106410. * @param earcutInjection can be used to inject your own earcut reference
  106411. * @returns the polygon mesh
  106412. */
  106413. static CreatePolygon(name: string, options: {
  106414. shape: Vector3[];
  106415. holes?: Vector3[][];
  106416. depth?: number;
  106417. faceUV?: Vector4[];
  106418. faceColors?: Color4[];
  106419. updatable?: boolean;
  106420. sideOrientation?: number;
  106421. frontUVs?: Vector4;
  106422. backUVs?: Vector4;
  106423. }, scene: Scene, earcutInjection?: any): Mesh;
  106424. /**
  106425. * Creates an extruded polygon mesh, with depth in the Y direction.
  106426. * * 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)
  106427. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106428. * @param name defines the name of the mesh
  106429. * @param options defines the options used to create the mesh
  106430. * @param scene defines the hosting scene
  106431. * @param earcutInjection can be used to inject your own earcut reference
  106432. * @returns the polygon mesh
  106433. */
  106434. static ExtrudePolygon(name: string, options: {
  106435. shape: Vector3[];
  106436. holes?: Vector3[][];
  106437. depth?: number;
  106438. faceUV?: Vector4[];
  106439. faceColors?: Color4[];
  106440. updatable?: boolean;
  106441. sideOrientation?: number;
  106442. frontUVs?: Vector4;
  106443. backUVs?: Vector4;
  106444. }, scene: Scene, earcutInjection?: any): Mesh;
  106445. /**
  106446. * Creates a tube mesh.
  106447. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106448. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106449. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106450. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106451. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106452. * * 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)
  106453. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106454. * * 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
  106455. * * 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
  106456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106457. * * If you create a double-sided mesh, you can choose what parts of 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
  106458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106460. * @param name defines the name of the mesh
  106461. * @param options defines the options used to create the mesh
  106462. * @param scene defines the hosting scene
  106463. * @returns the tube mesh
  106464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106465. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106466. */
  106467. static CreateTube(name: string, options: {
  106468. path: Vector3[];
  106469. radius?: number;
  106470. tessellation?: number;
  106471. radiusFunction?: {
  106472. (i: number, distance: number): number;
  106473. };
  106474. cap?: number;
  106475. arc?: number;
  106476. updatable?: boolean;
  106477. sideOrientation?: number;
  106478. frontUVs?: Vector4;
  106479. backUVs?: Vector4;
  106480. instance?: Mesh;
  106481. invertUV?: boolean;
  106482. }, scene: Scene): Mesh;
  106483. /**
  106484. * Creates a polyhedron mesh
  106485. * * 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
  106486. * * The parameter `size` (positive float, default 1) sets the polygon size
  106487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106488. * * 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`
  106489. * * 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
  106490. * * 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)`)
  106491. * * 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
  106492. * * 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
  106493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106494. * * If you create a double-sided mesh, you can choose what parts of 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
  106495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106496. * @param name defines the name of the mesh
  106497. * @param options defines the options used to create the mesh
  106498. * @param scene defines the hosting scene
  106499. * @returns the polyhedron mesh
  106500. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106501. */
  106502. static CreatePolyhedron(name: string, options: {
  106503. type?: number;
  106504. size?: number;
  106505. sizeX?: number;
  106506. sizeY?: number;
  106507. sizeZ?: number;
  106508. custom?: any;
  106509. faceUV?: Vector4[];
  106510. faceColors?: Color4[];
  106511. flat?: boolean;
  106512. updatable?: boolean;
  106513. sideOrientation?: number;
  106514. frontUVs?: Vector4;
  106515. backUVs?: Vector4;
  106516. }, scene: Scene): Mesh;
  106517. /**
  106518. * Creates a decal mesh.
  106519. * 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
  106520. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106521. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106522. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106523. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106524. * @param name defines the name of the mesh
  106525. * @param sourceMesh defines the mesh where the decal must be applied
  106526. * @param options defines the options used to create the mesh
  106527. * @param scene defines the hosting scene
  106528. * @returns the decal mesh
  106529. * @see https://doc.babylonjs.com/how_to/decals
  106530. */
  106531. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106532. position?: Vector3;
  106533. normal?: Vector3;
  106534. size?: Vector3;
  106535. angle?: number;
  106536. }): Mesh;
  106537. }
  106538. }
  106539. declare module BABYLON {
  106540. /**
  106541. * A simplifier interface for future simplification implementations
  106542. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106543. */
  106544. export interface ISimplifier {
  106545. /**
  106546. * Simplification of a given mesh according to the given settings.
  106547. * Since this requires computation, it is assumed that the function runs async.
  106548. * @param settings The settings of the simplification, including quality and distance
  106549. * @param successCallback A callback that will be called after the mesh was simplified.
  106550. * @param errorCallback in case of an error, this callback will be called. optional.
  106551. */
  106552. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106553. }
  106554. /**
  106555. * Expected simplification settings.
  106556. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106557. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106558. */
  106559. export interface ISimplificationSettings {
  106560. /**
  106561. * Gets or sets the expected quality
  106562. */
  106563. quality: number;
  106564. /**
  106565. * Gets or sets the distance when this optimized version should be used
  106566. */
  106567. distance: number;
  106568. /**
  106569. * Gets an already optimized mesh
  106570. */
  106571. optimizeMesh?: boolean;
  106572. }
  106573. /**
  106574. * Class used to specify simplification options
  106575. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106576. */
  106577. export class SimplificationSettings implements ISimplificationSettings {
  106578. /** expected quality */
  106579. quality: number;
  106580. /** distance when this optimized version should be used */
  106581. distance: number;
  106582. /** already optimized mesh */
  106583. optimizeMesh?: boolean | undefined;
  106584. /**
  106585. * Creates a SimplificationSettings
  106586. * @param quality expected quality
  106587. * @param distance distance when this optimized version should be used
  106588. * @param optimizeMesh already optimized mesh
  106589. */
  106590. constructor(
  106591. /** expected quality */
  106592. quality: number,
  106593. /** distance when this optimized version should be used */
  106594. distance: number,
  106595. /** already optimized mesh */
  106596. optimizeMesh?: boolean | undefined);
  106597. }
  106598. /**
  106599. * Interface used to define a simplification task
  106600. */
  106601. export interface ISimplificationTask {
  106602. /**
  106603. * Array of settings
  106604. */
  106605. settings: Array<ISimplificationSettings>;
  106606. /**
  106607. * Simplification type
  106608. */
  106609. simplificationType: SimplificationType;
  106610. /**
  106611. * Mesh to simplify
  106612. */
  106613. mesh: Mesh;
  106614. /**
  106615. * Callback called on success
  106616. */
  106617. successCallback?: () => void;
  106618. /**
  106619. * Defines if parallel processing can be used
  106620. */
  106621. parallelProcessing: boolean;
  106622. }
  106623. /**
  106624. * Queue used to order the simplification tasks
  106625. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106626. */
  106627. export class SimplificationQueue {
  106628. private _simplificationArray;
  106629. /**
  106630. * Gets a boolean indicating that the process is still running
  106631. */
  106632. running: boolean;
  106633. /**
  106634. * Creates a new queue
  106635. */
  106636. constructor();
  106637. /**
  106638. * Adds a new simplification task
  106639. * @param task defines a task to add
  106640. */
  106641. addTask(task: ISimplificationTask): void;
  106642. /**
  106643. * Execute next task
  106644. */
  106645. executeNext(): void;
  106646. /**
  106647. * Execute a simplification task
  106648. * @param task defines the task to run
  106649. */
  106650. runSimplification(task: ISimplificationTask): void;
  106651. private getSimplifier;
  106652. }
  106653. /**
  106654. * The implemented types of simplification
  106655. * At the moment only Quadratic Error Decimation is implemented
  106656. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106657. */
  106658. export enum SimplificationType {
  106659. /** Quadratic error decimation */
  106660. QUADRATIC = 0
  106661. }
  106662. }
  106663. declare module BABYLON {
  106664. interface Scene {
  106665. /** @hidden (Backing field) */
  106666. _simplificationQueue: SimplificationQueue;
  106667. /**
  106668. * Gets or sets the simplification queue attached to the scene
  106669. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106670. */
  106671. simplificationQueue: SimplificationQueue;
  106672. }
  106673. interface Mesh {
  106674. /**
  106675. * Simplify the mesh according to the given array of settings.
  106676. * Function will return immediately and will simplify async
  106677. * @param settings a collection of simplification settings
  106678. * @param parallelProcessing should all levels calculate parallel or one after the other
  106679. * @param simplificationType the type of simplification to run
  106680. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106681. * @returns the current mesh
  106682. */
  106683. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106684. }
  106685. /**
  106686. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106687. * created in a scene
  106688. */
  106689. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106690. /**
  106691. * The component name helpfull to identify the component in the list of scene components.
  106692. */
  106693. readonly name: string;
  106694. /**
  106695. * The scene the component belongs to.
  106696. */
  106697. scene: Scene;
  106698. /**
  106699. * Creates a new instance of the component for the given scene
  106700. * @param scene Defines the scene to register the component in
  106701. */
  106702. constructor(scene: Scene);
  106703. /**
  106704. * Registers the component in a given scene
  106705. */
  106706. register(): void;
  106707. /**
  106708. * Rebuilds the elements related to this component in case of
  106709. * context lost for instance.
  106710. */
  106711. rebuild(): void;
  106712. /**
  106713. * Disposes the component and the associated ressources
  106714. */
  106715. dispose(): void;
  106716. private _beforeCameraUpdate;
  106717. }
  106718. }
  106719. declare module BABYLON {
  106720. /**
  106721. * Class used to enable access to IndexedDB
  106722. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106723. */
  106724. export class Database implements IOfflineProvider {
  106725. private _callbackManifestChecked;
  106726. private _currentSceneUrl;
  106727. private _db;
  106728. private _enableSceneOffline;
  106729. private _enableTexturesOffline;
  106730. private _manifestVersionFound;
  106731. private _mustUpdateRessources;
  106732. private _hasReachedQuota;
  106733. private _isSupported;
  106734. private _idbFactory;
  106735. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106736. private static IsUASupportingBlobStorage;
  106737. /**
  106738. * Gets a boolean indicating if Database storate is enabled (off by default)
  106739. */
  106740. static IDBStorageEnabled: boolean;
  106741. /**
  106742. * Gets a boolean indicating if scene must be saved in the database
  106743. */
  106744. readonly enableSceneOffline: boolean;
  106745. /**
  106746. * Gets a boolean indicating if textures must be saved in the database
  106747. */
  106748. readonly enableTexturesOffline: boolean;
  106749. /**
  106750. * Creates a new Database
  106751. * @param urlToScene defines the url to load the scene
  106752. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106753. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106754. */
  106755. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106756. private static _ParseURL;
  106757. private static _ReturnFullUrlLocation;
  106758. private _checkManifestFile;
  106759. /**
  106760. * Open the database and make it available
  106761. * @param successCallback defines the callback to call on success
  106762. * @param errorCallback defines the callback to call on error
  106763. */
  106764. open(successCallback: () => void, errorCallback: () => void): void;
  106765. /**
  106766. * Loads an image from the database
  106767. * @param url defines the url to load from
  106768. * @param image defines the target DOM image
  106769. */
  106770. loadImage(url: string, image: HTMLImageElement): void;
  106771. private _loadImageFromDBAsync;
  106772. private _saveImageIntoDBAsync;
  106773. private _checkVersionFromDB;
  106774. private _loadVersionFromDBAsync;
  106775. private _saveVersionIntoDBAsync;
  106776. /**
  106777. * Loads a file from database
  106778. * @param url defines the URL to load from
  106779. * @param sceneLoaded defines a callback to call on success
  106780. * @param progressCallBack defines a callback to call when progress changed
  106781. * @param errorCallback defines a callback to call on error
  106782. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106783. */
  106784. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106785. private _loadFileAsync;
  106786. private _saveFileAsync;
  106787. /**
  106788. * Validates if xhr data is correct
  106789. * @param xhr defines the request to validate
  106790. * @param dataType defines the expected data type
  106791. * @returns true if data is correct
  106792. */
  106793. private static _ValidateXHRData;
  106794. }
  106795. }
  106796. declare module BABYLON {
  106797. /** @hidden */
  106798. export var gpuUpdateParticlesPixelShader: {
  106799. name: string;
  106800. shader: string;
  106801. };
  106802. }
  106803. declare module BABYLON {
  106804. /** @hidden */
  106805. export var gpuUpdateParticlesVertexShader: {
  106806. name: string;
  106807. shader: string;
  106808. };
  106809. }
  106810. declare module BABYLON {
  106811. /** @hidden */
  106812. export var clipPlaneFragmentDeclaration2: {
  106813. name: string;
  106814. shader: string;
  106815. };
  106816. }
  106817. declare module BABYLON {
  106818. /** @hidden */
  106819. export var gpuRenderParticlesPixelShader: {
  106820. name: string;
  106821. shader: string;
  106822. };
  106823. }
  106824. declare module BABYLON {
  106825. /** @hidden */
  106826. export var clipPlaneVertexDeclaration2: {
  106827. name: string;
  106828. shader: string;
  106829. };
  106830. }
  106831. declare module BABYLON {
  106832. /** @hidden */
  106833. export var gpuRenderParticlesVertexShader: {
  106834. name: string;
  106835. shader: string;
  106836. };
  106837. }
  106838. declare module BABYLON {
  106839. /**
  106840. * This represents a GPU particle system in Babylon
  106841. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106842. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106843. */
  106844. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106845. /**
  106846. * The layer mask we are rendering the particles through.
  106847. */
  106848. layerMask: number;
  106849. private _capacity;
  106850. private _activeCount;
  106851. private _currentActiveCount;
  106852. private _accumulatedCount;
  106853. private _renderEffect;
  106854. private _updateEffect;
  106855. private _buffer0;
  106856. private _buffer1;
  106857. private _spriteBuffer;
  106858. private _updateVAO;
  106859. private _renderVAO;
  106860. private _targetIndex;
  106861. private _sourceBuffer;
  106862. private _targetBuffer;
  106863. private _engine;
  106864. private _currentRenderId;
  106865. private _started;
  106866. private _stopped;
  106867. private _timeDelta;
  106868. private _randomTexture;
  106869. private _randomTexture2;
  106870. private _attributesStrideSize;
  106871. private _updateEffectOptions;
  106872. private _randomTextureSize;
  106873. private _actualFrame;
  106874. private readonly _rawTextureWidth;
  106875. /**
  106876. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106877. */
  106878. static readonly IsSupported: boolean;
  106879. /**
  106880. * An event triggered when the system is disposed.
  106881. */
  106882. onDisposeObservable: Observable<GPUParticleSystem>;
  106883. /**
  106884. * Gets the maximum number of particles active at the same time.
  106885. * @returns The max number of active particles.
  106886. */
  106887. getCapacity(): number;
  106888. /**
  106889. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106890. * to override the particles.
  106891. */
  106892. forceDepthWrite: boolean;
  106893. /**
  106894. * Gets or set the number of active particles
  106895. */
  106896. activeParticleCount: number;
  106897. private _preWarmDone;
  106898. /**
  106899. * Is this system ready to be used/rendered
  106900. * @return true if the system is ready
  106901. */
  106902. isReady(): boolean;
  106903. /**
  106904. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106905. * @returns True if it has been started, otherwise false.
  106906. */
  106907. isStarted(): boolean;
  106908. /**
  106909. * Starts the particle system and begins to emit
  106910. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106911. */
  106912. start(delay?: number): void;
  106913. /**
  106914. * Stops the particle system.
  106915. */
  106916. stop(): void;
  106917. /**
  106918. * Remove all active particles
  106919. */
  106920. reset(): void;
  106921. /**
  106922. * Returns the string "GPUParticleSystem"
  106923. * @returns a string containing the class name
  106924. */
  106925. getClassName(): string;
  106926. private _colorGradientsTexture;
  106927. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106928. /**
  106929. * Adds a new color gradient
  106930. * @param gradient defines the gradient to use (between 0 and 1)
  106931. * @param color1 defines the color to affect to the specified gradient
  106932. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106933. * @returns the current particle system
  106934. */
  106935. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106936. /**
  106937. * Remove a specific color gradient
  106938. * @param gradient defines the gradient to remove
  106939. * @returns the current particle system
  106940. */
  106941. removeColorGradient(gradient: number): GPUParticleSystem;
  106942. private _angularSpeedGradientsTexture;
  106943. private _sizeGradientsTexture;
  106944. private _velocityGradientsTexture;
  106945. private _limitVelocityGradientsTexture;
  106946. private _dragGradientsTexture;
  106947. private _addFactorGradient;
  106948. /**
  106949. * Adds a new size gradient
  106950. * @param gradient defines the gradient to use (between 0 and 1)
  106951. * @param factor defines the size factor to affect to the specified gradient
  106952. * @returns the current particle system
  106953. */
  106954. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106955. /**
  106956. * Remove a specific size gradient
  106957. * @param gradient defines the gradient to remove
  106958. * @returns the current particle system
  106959. */
  106960. removeSizeGradient(gradient: number): GPUParticleSystem;
  106961. /**
  106962. * Adds a new angular speed gradient
  106963. * @param gradient defines the gradient to use (between 0 and 1)
  106964. * @param factor defines the angular speed to affect to the specified gradient
  106965. * @returns the current particle system
  106966. */
  106967. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106968. /**
  106969. * Remove a specific angular speed gradient
  106970. * @param gradient defines the gradient to remove
  106971. * @returns the current particle system
  106972. */
  106973. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106974. /**
  106975. * Adds a new velocity gradient
  106976. * @param gradient defines the gradient to use (between 0 and 1)
  106977. * @param factor defines the velocity to affect to the specified gradient
  106978. * @returns the current particle system
  106979. */
  106980. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106981. /**
  106982. * Remove a specific velocity gradient
  106983. * @param gradient defines the gradient to remove
  106984. * @returns the current particle system
  106985. */
  106986. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106987. /**
  106988. * Adds a new limit velocity gradient
  106989. * @param gradient defines the gradient to use (between 0 and 1)
  106990. * @param factor defines the limit velocity value to affect to the specified gradient
  106991. * @returns the current particle system
  106992. */
  106993. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106994. /**
  106995. * Remove a specific limit velocity gradient
  106996. * @param gradient defines the gradient to remove
  106997. * @returns the current particle system
  106998. */
  106999. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  107000. /**
  107001. * Adds a new drag gradient
  107002. * @param gradient defines the gradient to use (between 0 and 1)
  107003. * @param factor defines the drag value to affect to the specified gradient
  107004. * @returns the current particle system
  107005. */
  107006. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  107007. /**
  107008. * Remove a specific drag gradient
  107009. * @param gradient defines the gradient to remove
  107010. * @returns the current particle system
  107011. */
  107012. removeDragGradient(gradient: number): GPUParticleSystem;
  107013. /**
  107014. * Not supported by GPUParticleSystem
  107015. * @param gradient defines the gradient to use (between 0 and 1)
  107016. * @param factor defines the emit rate value to affect to the specified gradient
  107017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107018. * @returns the current particle system
  107019. */
  107020. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107021. /**
  107022. * Not supported by GPUParticleSystem
  107023. * @param gradient defines the gradient to remove
  107024. * @returns the current particle system
  107025. */
  107026. removeEmitRateGradient(gradient: number): IParticleSystem;
  107027. /**
  107028. * Not supported by GPUParticleSystem
  107029. * @param gradient defines the gradient to use (between 0 and 1)
  107030. * @param factor defines the start size value to affect to the specified gradient
  107031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107032. * @returns the current particle system
  107033. */
  107034. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107035. /**
  107036. * Not supported by GPUParticleSystem
  107037. * @param gradient defines the gradient to remove
  107038. * @returns the current particle system
  107039. */
  107040. removeStartSizeGradient(gradient: number): IParticleSystem;
  107041. /**
  107042. * Not supported by GPUParticleSystem
  107043. * @param gradient defines the gradient to use (between 0 and 1)
  107044. * @param min defines the color remap minimal range
  107045. * @param max defines the color remap maximal range
  107046. * @returns the current particle system
  107047. */
  107048. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107049. /**
  107050. * Not supported by GPUParticleSystem
  107051. * @param gradient defines the gradient to remove
  107052. * @returns the current particle system
  107053. */
  107054. removeColorRemapGradient(): IParticleSystem;
  107055. /**
  107056. * Not supported by GPUParticleSystem
  107057. * @param gradient defines the gradient to use (between 0 and 1)
  107058. * @param min defines the alpha remap minimal range
  107059. * @param max defines the alpha remap maximal range
  107060. * @returns the current particle system
  107061. */
  107062. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107063. /**
  107064. * Not supported by GPUParticleSystem
  107065. * @param gradient defines the gradient to remove
  107066. * @returns the current particle system
  107067. */
  107068. removeAlphaRemapGradient(): IParticleSystem;
  107069. /**
  107070. * Not supported by GPUParticleSystem
  107071. * @param gradient defines the gradient to use (between 0 and 1)
  107072. * @param color defines the color to affect to the specified gradient
  107073. * @returns the current particle system
  107074. */
  107075. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107076. /**
  107077. * Not supported by GPUParticleSystem
  107078. * @param gradient defines the gradient to remove
  107079. * @returns the current particle system
  107080. */
  107081. removeRampGradient(): IParticleSystem;
  107082. /**
  107083. * Not supported by GPUParticleSystem
  107084. * @returns the list of ramp gradients
  107085. */
  107086. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107087. /**
  107088. * Not supported by GPUParticleSystem
  107089. * Gets or sets a boolean indicating that ramp gradients must be used
  107090. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107091. */
  107092. useRampGradients: boolean;
  107093. /**
  107094. * Not supported by GPUParticleSystem
  107095. * @param gradient defines the gradient to use (between 0 and 1)
  107096. * @param factor defines the life time factor to affect to the specified gradient
  107097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107098. * @returns the current particle system
  107099. */
  107100. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107101. /**
  107102. * Not supported by GPUParticleSystem
  107103. * @param gradient defines the gradient to remove
  107104. * @returns the current particle system
  107105. */
  107106. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107107. /**
  107108. * Instantiates a GPU particle system.
  107109. * 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.
  107110. * @param name The name of the particle system
  107111. * @param options The options used to create the system
  107112. * @param scene The scene the particle system belongs to
  107113. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107114. */
  107115. constructor(name: string, options: Partial<{
  107116. capacity: number;
  107117. randomTextureSize: number;
  107118. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107119. protected _reset(): void;
  107120. private _createUpdateVAO;
  107121. private _createRenderVAO;
  107122. private _initialize;
  107123. /** @hidden */
  107124. _recreateUpdateEffect(): void;
  107125. /** @hidden */
  107126. _recreateRenderEffect(): void;
  107127. /**
  107128. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107129. * @param preWarm defines if we are in the pre-warmimg phase
  107130. */
  107131. animate(preWarm?: boolean): void;
  107132. private _createFactorGradientTexture;
  107133. private _createSizeGradientTexture;
  107134. private _createAngularSpeedGradientTexture;
  107135. private _createVelocityGradientTexture;
  107136. private _createLimitVelocityGradientTexture;
  107137. private _createDragGradientTexture;
  107138. private _createColorGradientTexture;
  107139. /**
  107140. * Renders the particle system in its current state
  107141. * @param preWarm defines if the system should only update the particles but not render them
  107142. * @returns the current number of particles
  107143. */
  107144. render(preWarm?: boolean): number;
  107145. /**
  107146. * Rebuilds the particle system
  107147. */
  107148. rebuild(): void;
  107149. private _releaseBuffers;
  107150. private _releaseVAOs;
  107151. /**
  107152. * Disposes the particle system and free the associated resources
  107153. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107154. */
  107155. dispose(disposeTexture?: boolean): void;
  107156. /**
  107157. * Clones the particle system.
  107158. * @param name The name of the cloned object
  107159. * @param newEmitter The new emitter to use
  107160. * @returns the cloned particle system
  107161. */
  107162. clone(name: string, newEmitter: any): GPUParticleSystem;
  107163. /**
  107164. * Serializes the particle system to a JSON object.
  107165. * @returns the JSON object
  107166. */
  107167. serialize(): any;
  107168. /**
  107169. * Parses a JSON object to create a GPU particle system.
  107170. * @param parsedParticleSystem The JSON object to parse
  107171. * @param scene The scene to create the particle system in
  107172. * @param rootUrl The root url to use to load external dependencies like texture
  107173. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107174. * @returns the parsed GPU particle system
  107175. */
  107176. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107177. }
  107178. }
  107179. declare module BABYLON {
  107180. /**
  107181. * Represents a set of particle systems working together to create a specific effect
  107182. */
  107183. export class ParticleSystemSet implements IDisposable {
  107184. private _emitterCreationOptions;
  107185. private _emitterNode;
  107186. /**
  107187. * Gets the particle system list
  107188. */
  107189. systems: IParticleSystem[];
  107190. /**
  107191. * Gets the emitter node used with this set
  107192. */
  107193. readonly emitterNode: Nullable<TransformNode>;
  107194. /**
  107195. * Creates a new emitter mesh as a sphere
  107196. * @param options defines the options used to create the sphere
  107197. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107198. * @param scene defines the hosting scene
  107199. */
  107200. setEmitterAsSphere(options: {
  107201. diameter: number;
  107202. segments: number;
  107203. color: Color3;
  107204. }, renderingGroupId: number, scene: Scene): void;
  107205. /**
  107206. * Starts all particle systems of the set
  107207. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107208. */
  107209. start(emitter?: AbstractMesh): void;
  107210. /**
  107211. * Release all associated resources
  107212. */
  107213. dispose(): void;
  107214. /**
  107215. * Serialize the set into a JSON compatible object
  107216. * @returns a JSON compatible representation of the set
  107217. */
  107218. serialize(): any;
  107219. /**
  107220. * Parse a new ParticleSystemSet from a serialized source
  107221. * @param data defines a JSON compatible representation of the set
  107222. * @param scene defines the hosting scene
  107223. * @param gpu defines if we want GPU particles or CPU particles
  107224. * @returns a new ParticleSystemSet
  107225. */
  107226. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * This class is made for on one-liner static method to help creating particle system set.
  107232. */
  107233. export class ParticleHelper {
  107234. /**
  107235. * Gets or sets base Assets URL
  107236. */
  107237. static BaseAssetsUrl: string;
  107238. /**
  107239. * Create a default particle system that you can tweak
  107240. * @param emitter defines the emitter to use
  107241. * @param capacity defines the system capacity (default is 500 particles)
  107242. * @param scene defines the hosting scene
  107243. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107244. * @returns the new Particle system
  107245. */
  107246. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107247. /**
  107248. * This is the main static method (one-liner) of this helper to create different particle systems
  107249. * @param type This string represents the type to the particle system to create
  107250. * @param scene The scene where the particle system should live
  107251. * @param gpu If the system will use gpu
  107252. * @returns the ParticleSystemSet created
  107253. */
  107254. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107255. /**
  107256. * Static function used to export a particle system to a ParticleSystemSet variable.
  107257. * Please note that the emitter shape is not exported
  107258. * @param systems defines the particle systems to export
  107259. * @returns the created particle system set
  107260. */
  107261. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107262. }
  107263. }
  107264. declare module BABYLON {
  107265. interface Engine {
  107266. /**
  107267. * Create an effect to use with particle systems.
  107268. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107269. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107270. * @param uniformsNames defines a list of attribute names
  107271. * @param samplers defines an array of string used to represent textures
  107272. * @param defines defines the string containing the defines to use to compile the shaders
  107273. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107274. * @param onCompiled defines a function to call when the effect creation is successful
  107275. * @param onError defines a function to call when the effect creation has failed
  107276. * @returns the new Effect
  107277. */
  107278. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107279. }
  107280. interface Mesh {
  107281. /**
  107282. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107283. * @returns an array of IParticleSystem
  107284. */
  107285. getEmittedParticleSystems(): IParticleSystem[];
  107286. /**
  107287. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107288. * @returns an array of IParticleSystem
  107289. */
  107290. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107291. }
  107292. /**
  107293. * @hidden
  107294. */
  107295. export var _IDoNeedToBeInTheBuild: number;
  107296. }
  107297. declare module BABYLON {
  107298. interface Scene {
  107299. /** @hidden (Backing field) */
  107300. _physicsEngine: Nullable<IPhysicsEngine>;
  107301. /**
  107302. * Gets the current physics engine
  107303. * @returns a IPhysicsEngine or null if none attached
  107304. */
  107305. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107306. /**
  107307. * Enables physics to the current scene
  107308. * @param gravity defines the scene's gravity for the physics engine
  107309. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107310. * @return a boolean indicating if the physics engine was initialized
  107311. */
  107312. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107313. /**
  107314. * Disables and disposes the physics engine associated with the scene
  107315. */
  107316. disablePhysicsEngine(): void;
  107317. /**
  107318. * Gets a boolean indicating if there is an active physics engine
  107319. * @returns a boolean indicating if there is an active physics engine
  107320. */
  107321. isPhysicsEnabled(): boolean;
  107322. /**
  107323. * Deletes a physics compound impostor
  107324. * @param compound defines the compound to delete
  107325. */
  107326. deleteCompoundImpostor(compound: any): void;
  107327. /**
  107328. * An event triggered when physic simulation is about to be run
  107329. */
  107330. onBeforePhysicsObservable: Observable<Scene>;
  107331. /**
  107332. * An event triggered when physic simulation has been done
  107333. */
  107334. onAfterPhysicsObservable: Observable<Scene>;
  107335. }
  107336. interface AbstractMesh {
  107337. /** @hidden */
  107338. _physicsImpostor: Nullable<PhysicsImpostor>;
  107339. /**
  107340. * Gets or sets impostor used for physic simulation
  107341. * @see http://doc.babylonjs.com/features/physics_engine
  107342. */
  107343. physicsImpostor: Nullable<PhysicsImpostor>;
  107344. /**
  107345. * Gets the current physics impostor
  107346. * @see http://doc.babylonjs.com/features/physics_engine
  107347. * @returns a physics impostor or null
  107348. */
  107349. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107350. /** Apply a physic impulse to the mesh
  107351. * @param force defines the force to apply
  107352. * @param contactPoint defines where to apply the force
  107353. * @returns the current mesh
  107354. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107355. */
  107356. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107357. /**
  107358. * Creates a physic joint between two meshes
  107359. * @param otherMesh defines the other mesh to use
  107360. * @param pivot1 defines the pivot to use on this mesh
  107361. * @param pivot2 defines the pivot to use on the other mesh
  107362. * @param options defines additional options (can be plugin dependent)
  107363. * @returns the current mesh
  107364. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107365. */
  107366. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107367. /** @hidden */
  107368. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107369. }
  107370. /**
  107371. * Defines the physics engine scene component responsible to manage a physics engine
  107372. */
  107373. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107374. /**
  107375. * The component name helpful to identify the component in the list of scene components.
  107376. */
  107377. readonly name: string;
  107378. /**
  107379. * The scene the component belongs to.
  107380. */
  107381. scene: Scene;
  107382. /**
  107383. * Creates a new instance of the component for the given scene
  107384. * @param scene Defines the scene to register the component in
  107385. */
  107386. constructor(scene: Scene);
  107387. /**
  107388. * Registers the component in a given scene
  107389. */
  107390. register(): void;
  107391. /**
  107392. * Rebuilds the elements related to this component in case of
  107393. * context lost for instance.
  107394. */
  107395. rebuild(): void;
  107396. /**
  107397. * Disposes the component and the associated ressources
  107398. */
  107399. dispose(): void;
  107400. }
  107401. }
  107402. declare module BABYLON {
  107403. /**
  107404. * A helper for physics simulations
  107405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107406. */
  107407. export class PhysicsHelper {
  107408. private _scene;
  107409. private _physicsEngine;
  107410. /**
  107411. * Initializes the Physics helper
  107412. * @param scene Babylon.js scene
  107413. */
  107414. constructor(scene: Scene);
  107415. /**
  107416. * Applies a radial explosion impulse
  107417. * @param origin the origin of the explosion
  107418. * @param radius the explosion radius
  107419. * @param strength the explosion strength
  107420. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107421. * @returns A physics radial explosion event, or null
  107422. */
  107423. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107424. /**
  107425. * Applies a radial explosion force
  107426. * @param origin the origin of the explosion
  107427. * @param radius the explosion radius
  107428. * @param strength the explosion strength
  107429. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107430. * @returns A physics radial explosion event, or null
  107431. */
  107432. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107433. /**
  107434. * Creates a gravitational field
  107435. * @param origin the origin of the explosion
  107436. * @param radius the explosion radius
  107437. * @param strength the explosion strength
  107438. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107439. * @returns A physics gravitational field event, or null
  107440. */
  107441. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107442. /**
  107443. * Creates a physics updraft event
  107444. * @param origin the origin of the updraft
  107445. * @param radius the radius of the updraft
  107446. * @param strength the strength of the updraft
  107447. * @param height the height of the updraft
  107448. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107449. * @returns A physics updraft event, or null
  107450. */
  107451. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107452. /**
  107453. * Creates a physics vortex event
  107454. * @param origin the of the vortex
  107455. * @param radius the radius of the vortex
  107456. * @param strength the strength of the vortex
  107457. * @param height the height of the vortex
  107458. * @returns a Physics vortex event, or null
  107459. * A physics vortex event or null
  107460. */
  107461. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107462. }
  107463. /**
  107464. * Represents a physics radial explosion event
  107465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107466. */
  107467. export class PhysicsRadialExplosionEvent {
  107468. private _scene;
  107469. private _sphere;
  107470. private _sphereOptions;
  107471. private _rays;
  107472. private _dataFetched;
  107473. /**
  107474. * Initializes a radial explosioin event
  107475. * @param scene BabylonJS scene
  107476. */
  107477. constructor(scene: Scene);
  107478. /**
  107479. * Returns the data related to the radial explosion event (sphere & rays).
  107480. * @returns The radial explosion event data
  107481. */
  107482. getData(): PhysicsRadialExplosionEventData;
  107483. /**
  107484. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107485. * @param impostor A physics imposter
  107486. * @param origin the origin of the explosion
  107487. * @param radius the explosion radius
  107488. * @param strength the explosion strength
  107489. * @param falloff possible options: Constant & Linear
  107490. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107491. */
  107492. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107493. /**
  107494. * Disposes the sphere.
  107495. * @param force Specifies if the sphere should be disposed by force
  107496. */
  107497. dispose(force?: boolean): void;
  107498. /*** Helpers ***/
  107499. private _prepareSphere;
  107500. private _intersectsWithSphere;
  107501. }
  107502. /**
  107503. * Represents a gravitational field event
  107504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107505. */
  107506. export class PhysicsGravitationalFieldEvent {
  107507. private _physicsHelper;
  107508. private _scene;
  107509. private _origin;
  107510. private _radius;
  107511. private _strength;
  107512. private _falloff;
  107513. private _tickCallback;
  107514. private _sphere;
  107515. private _dataFetched;
  107516. /**
  107517. * Initializes the physics gravitational field event
  107518. * @param physicsHelper A physics helper
  107519. * @param scene BabylonJS scene
  107520. * @param origin The origin position of the gravitational field event
  107521. * @param radius The radius of the gravitational field event
  107522. * @param strength The strength of the gravitational field event
  107523. * @param falloff The falloff for the gravitational field event
  107524. */
  107525. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107526. /**
  107527. * Returns the data related to the gravitational field event (sphere).
  107528. * @returns A gravitational field event
  107529. */
  107530. getData(): PhysicsGravitationalFieldEventData;
  107531. /**
  107532. * Enables the gravitational field.
  107533. */
  107534. enable(): void;
  107535. /**
  107536. * Disables the gravitational field.
  107537. */
  107538. disable(): void;
  107539. /**
  107540. * Disposes the sphere.
  107541. * @param force The force to dispose from the gravitational field event
  107542. */
  107543. dispose(force?: boolean): void;
  107544. private _tick;
  107545. }
  107546. /**
  107547. * Represents a physics updraft event
  107548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107549. */
  107550. export class PhysicsUpdraftEvent {
  107551. private _scene;
  107552. private _origin;
  107553. private _radius;
  107554. private _strength;
  107555. private _height;
  107556. private _updraftMode;
  107557. private _physicsEngine;
  107558. private _originTop;
  107559. private _originDirection;
  107560. private _tickCallback;
  107561. private _cylinder;
  107562. private _cylinderPosition;
  107563. private _dataFetched;
  107564. /**
  107565. * Initializes the physics updraft event
  107566. * @param _scene BabylonJS scene
  107567. * @param _origin The origin position of the updraft
  107568. * @param _radius The radius of the updraft
  107569. * @param _strength The strength of the updraft
  107570. * @param _height The height of the updraft
  107571. * @param _updraftMode The mode of the updraft
  107572. */
  107573. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107574. /**
  107575. * Returns the data related to the updraft event (cylinder).
  107576. * @returns A physics updraft event
  107577. */
  107578. getData(): PhysicsUpdraftEventData;
  107579. /**
  107580. * Enables the updraft.
  107581. */
  107582. enable(): void;
  107583. /**
  107584. * Disables the cortex.
  107585. */
  107586. disable(): void;
  107587. /**
  107588. * Disposes the sphere.
  107589. * @param force Specifies if the updraft should be disposed by force
  107590. */
  107591. dispose(force?: boolean): void;
  107592. private getImpostorForceAndContactPoint;
  107593. private _tick;
  107594. /*** Helpers ***/
  107595. private _prepareCylinder;
  107596. private _intersectsWithCylinder;
  107597. }
  107598. /**
  107599. * Represents a physics vortex event
  107600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107601. */
  107602. export class PhysicsVortexEvent {
  107603. private _scene;
  107604. private _origin;
  107605. private _radius;
  107606. private _strength;
  107607. private _height;
  107608. private _physicsEngine;
  107609. private _originTop;
  107610. private _centripetalForceThreshold;
  107611. private _updraftMultiplier;
  107612. private _tickCallback;
  107613. private _cylinder;
  107614. private _cylinderPosition;
  107615. private _dataFetched;
  107616. /**
  107617. * Initializes the physics vortex event
  107618. * @param _scene The BabylonJS scene
  107619. * @param _origin The origin position of the vortex
  107620. * @param _radius The radius of the vortex
  107621. * @param _strength The strength of the vortex
  107622. * @param _height The height of the vortex
  107623. */
  107624. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107625. /**
  107626. * Returns the data related to the vortex event (cylinder).
  107627. * @returns The physics vortex event data
  107628. */
  107629. getData(): PhysicsVortexEventData;
  107630. /**
  107631. * Enables the vortex.
  107632. */
  107633. enable(): void;
  107634. /**
  107635. * Disables the cortex.
  107636. */
  107637. disable(): void;
  107638. /**
  107639. * Disposes the sphere.
  107640. * @param force
  107641. */
  107642. dispose(force?: boolean): void;
  107643. private getImpostorForceAndContactPoint;
  107644. private _tick;
  107645. /*** Helpers ***/
  107646. private _prepareCylinder;
  107647. private _intersectsWithCylinder;
  107648. }
  107649. /**
  107650. * The strenght of the force in correspondence to the distance of the affected object
  107651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107652. */
  107653. export enum PhysicsRadialImpulseFalloff {
  107654. /** Defines that impulse is constant in strength across it's whole radius */
  107655. Constant = 0,
  107656. /** DEfines that impulse gets weaker if it's further from the origin */
  107657. Linear = 1
  107658. }
  107659. /**
  107660. * The strength of the force in correspondence to the distance of the affected object
  107661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107662. */
  107663. export enum PhysicsUpdraftMode {
  107664. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107665. Center = 0,
  107666. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107667. Perpendicular = 1
  107668. }
  107669. /**
  107670. * Interface for a physics force and contact point
  107671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107672. */
  107673. export interface PhysicsForceAndContactPoint {
  107674. /**
  107675. * The force applied at the contact point
  107676. */
  107677. force: Vector3;
  107678. /**
  107679. * The contact point
  107680. */
  107681. contactPoint: Vector3;
  107682. }
  107683. /**
  107684. * Interface for radial explosion event data
  107685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107686. */
  107687. export interface PhysicsRadialExplosionEventData {
  107688. /**
  107689. * A sphere used for the radial explosion event
  107690. */
  107691. sphere: Mesh;
  107692. /**
  107693. * An array of rays for the radial explosion event
  107694. */
  107695. rays: Array<Ray>;
  107696. }
  107697. /**
  107698. * Interface for gravitational field event data
  107699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107700. */
  107701. export interface PhysicsGravitationalFieldEventData {
  107702. /**
  107703. * A sphere mesh used for the gravitational field event
  107704. */
  107705. sphere: Mesh;
  107706. }
  107707. /**
  107708. * Interface for updraft event data
  107709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107710. */
  107711. export interface PhysicsUpdraftEventData {
  107712. /**
  107713. * A cylinder used for the updraft event
  107714. */
  107715. cylinder: Mesh;
  107716. }
  107717. /**
  107718. * Interface for vortex event data
  107719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107720. */
  107721. export interface PhysicsVortexEventData {
  107722. /**
  107723. * A cylinder used for the vortex event
  107724. */
  107725. cylinder: Mesh;
  107726. }
  107727. }
  107728. declare module BABYLON {
  107729. /**
  107730. * AmmoJS Physics plugin
  107731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107732. * @see https://github.com/kripken/ammo.js/
  107733. */
  107734. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107735. private _useDeltaForWorldStep;
  107736. /**
  107737. * Reference to the Ammo library
  107738. */
  107739. bjsAMMO: any;
  107740. /**
  107741. * Created ammoJS world which physics bodies are added to
  107742. */
  107743. world: any;
  107744. /**
  107745. * Name of the plugin
  107746. */
  107747. name: string;
  107748. private _timeStep;
  107749. private _fixedTimeStep;
  107750. private _maxSteps;
  107751. private _tmpQuaternion;
  107752. private _tmpAmmoTransform;
  107753. private _tmpAmmoQuaternion;
  107754. private _tmpAmmoConcreteContactResultCallback;
  107755. private _collisionConfiguration;
  107756. private _dispatcher;
  107757. private _overlappingPairCache;
  107758. private _solver;
  107759. private _tmpAmmoVectorA;
  107760. private _tmpAmmoVectorB;
  107761. private _tmpAmmoVectorC;
  107762. private _tmpContactCallbackResult;
  107763. private static readonly DISABLE_COLLISION_FLAG;
  107764. private static readonly KINEMATIC_FLAG;
  107765. private static readonly DISABLE_DEACTIVATION_FLAG;
  107766. /**
  107767. * Initializes the ammoJS plugin
  107768. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107769. * @param ammoInjection can be used to inject your own ammo reference
  107770. */
  107771. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107772. /**
  107773. * Sets the gravity of the physics world (m/(s^2))
  107774. * @param gravity Gravity to set
  107775. */
  107776. setGravity(gravity: Vector3): void;
  107777. /**
  107778. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107779. * @param timeStep timestep to use in seconds
  107780. */
  107781. setTimeStep(timeStep: number): void;
  107782. /**
  107783. * 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)
  107784. * @param fixedTimeStep fixedTimeStep to use in seconds
  107785. */
  107786. setFixedTimeStep(fixedTimeStep: number): void;
  107787. /**
  107788. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107789. * @param maxSteps the maximum number of steps by the physics engine per frame
  107790. */
  107791. setMaxSteps(maxSteps: number): void;
  107792. /**
  107793. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107794. * @returns the current timestep in seconds
  107795. */
  107796. getTimeStep(): number;
  107797. private _isImpostorInContact;
  107798. private _isImpostorPairInContact;
  107799. private _stepSimulation;
  107800. /**
  107801. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107802. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107803. * After the step the babylon meshes are set to the position of the physics imposters
  107804. * @param delta amount of time to step forward
  107805. * @param impostors array of imposters to update before/after the step
  107806. */
  107807. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107808. private _tmpVector;
  107809. private _tmpMatrix;
  107810. /**
  107811. * Applies an implulse on the imposter
  107812. * @param impostor imposter to apply impulse
  107813. * @param force amount of force to be applied to the imposter
  107814. * @param contactPoint the location to apply the impulse on the imposter
  107815. */
  107816. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107817. /**
  107818. * Applies a force on the imposter
  107819. * @param impostor imposter to apply force
  107820. * @param force amount of force to be applied to the imposter
  107821. * @param contactPoint the location to apply the force on the imposter
  107822. */
  107823. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107824. /**
  107825. * Creates a physics body using the plugin
  107826. * @param impostor the imposter to create the physics body on
  107827. */
  107828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107829. /**
  107830. * Removes the physics body from the imposter and disposes of the body's memory
  107831. * @param impostor imposter to remove the physics body from
  107832. */
  107833. removePhysicsBody(impostor: PhysicsImpostor): void;
  107834. /**
  107835. * Generates a joint
  107836. * @param impostorJoint the imposter joint to create the joint with
  107837. */
  107838. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107839. /**
  107840. * Removes a joint
  107841. * @param impostorJoint the imposter joint to remove the joint from
  107842. */
  107843. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107844. private _addMeshVerts;
  107845. private _createShape;
  107846. /**
  107847. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107848. * @param impostor imposter containing the physics body and babylon object
  107849. */
  107850. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107851. /**
  107852. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107853. * @param impostor imposter containing the physics body and babylon object
  107854. * @param newPosition new position
  107855. * @param newRotation new rotation
  107856. */
  107857. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107858. /**
  107859. * If this plugin is supported
  107860. * @returns true if its supported
  107861. */
  107862. isSupported(): boolean;
  107863. /**
  107864. * Sets the linear velocity of the physics body
  107865. * @param impostor imposter to set the velocity on
  107866. * @param velocity velocity to set
  107867. */
  107868. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107869. /**
  107870. * Sets the angular velocity of the physics body
  107871. * @param impostor imposter to set the velocity on
  107872. * @param velocity velocity to set
  107873. */
  107874. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107875. /**
  107876. * gets the linear velocity
  107877. * @param impostor imposter to get linear velocity from
  107878. * @returns linear velocity
  107879. */
  107880. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107881. /**
  107882. * gets the angular velocity
  107883. * @param impostor imposter to get angular velocity from
  107884. * @returns angular velocity
  107885. */
  107886. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107887. /**
  107888. * Sets the mass of physics body
  107889. * @param impostor imposter to set the mass on
  107890. * @param mass mass to set
  107891. */
  107892. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107893. /**
  107894. * Gets the mass of the physics body
  107895. * @param impostor imposter to get the mass from
  107896. * @returns mass
  107897. */
  107898. getBodyMass(impostor: PhysicsImpostor): number;
  107899. /**
  107900. * Gets friction of the impostor
  107901. * @param impostor impostor to get friction from
  107902. * @returns friction value
  107903. */
  107904. getBodyFriction(impostor: PhysicsImpostor): number;
  107905. /**
  107906. * Sets friction of the impostor
  107907. * @param impostor impostor to set friction on
  107908. * @param friction friction value
  107909. */
  107910. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107911. /**
  107912. * Gets restitution of the impostor
  107913. * @param impostor impostor to get restitution from
  107914. * @returns restitution value
  107915. */
  107916. getBodyRestitution(impostor: PhysicsImpostor): number;
  107917. /**
  107918. * Sets resitution of the impostor
  107919. * @param impostor impostor to set resitution on
  107920. * @param restitution resitution value
  107921. */
  107922. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107923. /**
  107924. * Sleeps the physics body and stops it from being active
  107925. * @param impostor impostor to sleep
  107926. */
  107927. sleepBody(impostor: PhysicsImpostor): void;
  107928. /**
  107929. * Activates the physics body
  107930. * @param impostor impostor to activate
  107931. */
  107932. wakeUpBody(impostor: PhysicsImpostor): void;
  107933. /**
  107934. * Updates the distance parameters of the joint
  107935. * @param joint joint to update
  107936. * @param maxDistance maximum distance of the joint
  107937. * @param minDistance minimum distance of the joint
  107938. */
  107939. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107940. /**
  107941. * Sets a motor on the joint
  107942. * @param joint joint to set motor on
  107943. * @param speed speed of the motor
  107944. * @param maxForce maximum force of the motor
  107945. * @param motorIndex index of the motor
  107946. */
  107947. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107948. /**
  107949. * Sets the motors limit
  107950. * @param joint joint to set limit on
  107951. * @param upperLimit upper limit
  107952. * @param lowerLimit lower limit
  107953. */
  107954. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107955. /**
  107956. * Syncs the position and rotation of a mesh with the impostor
  107957. * @param mesh mesh to sync
  107958. * @param impostor impostor to update the mesh with
  107959. */
  107960. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107961. /**
  107962. * Gets the radius of the impostor
  107963. * @param impostor impostor to get radius from
  107964. * @returns the radius
  107965. */
  107966. getRadius(impostor: PhysicsImpostor): number;
  107967. /**
  107968. * Gets the box size of the impostor
  107969. * @param impostor impostor to get box size from
  107970. * @param result the resulting box size
  107971. */
  107972. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107973. /**
  107974. * Disposes of the impostor
  107975. */
  107976. dispose(): void;
  107977. }
  107978. }
  107979. declare module BABYLON {
  107980. /** @hidden */
  107981. export var blackAndWhitePixelShader: {
  107982. name: string;
  107983. shader: string;
  107984. };
  107985. }
  107986. declare module BABYLON {
  107987. /**
  107988. * Post process used to render in black and white
  107989. */
  107990. export class BlackAndWhitePostProcess extends PostProcess {
  107991. /**
  107992. * Linear about to convert he result to black and white (default: 1)
  107993. */
  107994. degree: number;
  107995. /**
  107996. * Creates a black and white post process
  107997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107998. * @param name The name of the effect.
  107999. * @param options The required width/height ratio to downsize to before computing the render pass.
  108000. * @param camera The camera to apply the render pass to.
  108001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108002. * @param engine The engine which the post process will be applied. (default: current engine)
  108003. * @param reusable If the post process can be reused on the same frame. (default: false)
  108004. */
  108005. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108006. }
  108007. }
  108008. declare module BABYLON {
  108009. /**
  108010. * This represents a set of one or more post processes in Babylon.
  108011. * A post process can be used to apply a shader to a texture after it is rendered.
  108012. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108013. */
  108014. export class PostProcessRenderEffect {
  108015. private _postProcesses;
  108016. private _getPostProcesses;
  108017. private _singleInstance;
  108018. private _cameras;
  108019. private _indicesForCamera;
  108020. /**
  108021. * Name of the effect
  108022. * @hidden
  108023. */
  108024. _name: string;
  108025. /**
  108026. * Instantiates a post process render effect.
  108027. * A post process can be used to apply a shader to a texture after it is rendered.
  108028. * @param engine The engine the effect is tied to
  108029. * @param name The name of the effect
  108030. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108031. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108032. */
  108033. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108034. /**
  108035. * Checks if all the post processes in the effect are supported.
  108036. */
  108037. readonly isSupported: boolean;
  108038. /**
  108039. * Updates the current state of the effect
  108040. * @hidden
  108041. */
  108042. _update(): void;
  108043. /**
  108044. * Attaches the effect on cameras
  108045. * @param cameras The camera to attach to.
  108046. * @hidden
  108047. */
  108048. _attachCameras(cameras: Camera): void;
  108049. /**
  108050. * Attaches the effect on cameras
  108051. * @param cameras The camera to attach to.
  108052. * @hidden
  108053. */
  108054. _attachCameras(cameras: Camera[]): void;
  108055. /**
  108056. * Detatches the effect on cameras
  108057. * @param cameras The camera to detatch from.
  108058. * @hidden
  108059. */
  108060. _detachCameras(cameras: Camera): void;
  108061. /**
  108062. * Detatches the effect on cameras
  108063. * @param cameras The camera to detatch from.
  108064. * @hidden
  108065. */
  108066. _detachCameras(cameras: Camera[]): void;
  108067. /**
  108068. * Enables the effect on given cameras
  108069. * @param cameras The camera to enable.
  108070. * @hidden
  108071. */
  108072. _enable(cameras: Camera): void;
  108073. /**
  108074. * Enables the effect on given cameras
  108075. * @param cameras The camera to enable.
  108076. * @hidden
  108077. */
  108078. _enable(cameras: Nullable<Camera[]>): void;
  108079. /**
  108080. * Disables the effect on the given cameras
  108081. * @param cameras The camera to disable.
  108082. * @hidden
  108083. */
  108084. _disable(cameras: Camera): void;
  108085. /**
  108086. * Disables the effect on the given cameras
  108087. * @param cameras The camera to disable.
  108088. * @hidden
  108089. */
  108090. _disable(cameras: Nullable<Camera[]>): void;
  108091. /**
  108092. * Gets a list of the post processes contained in the effect.
  108093. * @param camera The camera to get the post processes on.
  108094. * @returns The list of the post processes in the effect.
  108095. */
  108096. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108097. }
  108098. }
  108099. declare module BABYLON {
  108100. /** @hidden */
  108101. export var extractHighlightsPixelShader: {
  108102. name: string;
  108103. shader: string;
  108104. };
  108105. }
  108106. declare module BABYLON {
  108107. /**
  108108. * 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.
  108109. */
  108110. export class ExtractHighlightsPostProcess extends PostProcess {
  108111. /**
  108112. * The luminance threshold, pixels below this value will be set to black.
  108113. */
  108114. threshold: number;
  108115. /** @hidden */
  108116. _exposure: number;
  108117. /**
  108118. * Post process which has the input texture to be used when performing highlight extraction
  108119. * @hidden
  108120. */
  108121. _inputPostProcess: Nullable<PostProcess>;
  108122. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108123. }
  108124. }
  108125. declare module BABYLON {
  108126. /** @hidden */
  108127. export var bloomMergePixelShader: {
  108128. name: string;
  108129. shader: string;
  108130. };
  108131. }
  108132. declare module BABYLON {
  108133. /**
  108134. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108135. */
  108136. export class BloomMergePostProcess extends PostProcess {
  108137. /** Weight of the bloom to be added to the original input. */
  108138. weight: number;
  108139. /**
  108140. * Creates a new instance of @see BloomMergePostProcess
  108141. * @param name The name of the effect.
  108142. * @param originalFromInput Post process which's input will be used for the merge.
  108143. * @param blurred Blurred highlights post process which's output will be used.
  108144. * @param weight Weight of the bloom to be added to the original input.
  108145. * @param options The required width/height ratio to downsize to before computing the render pass.
  108146. * @param camera The camera to apply the render pass to.
  108147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108148. * @param engine The engine which the post process will be applied. (default: current engine)
  108149. * @param reusable If the post process can be reused on the same frame. (default: false)
  108150. * @param textureType Type of textures used when performing the post process. (default: 0)
  108151. * @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)
  108152. */
  108153. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108154. /** Weight of the bloom to be added to the original input. */
  108155. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108156. }
  108157. }
  108158. declare module BABYLON {
  108159. /**
  108160. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108161. */
  108162. export class BloomEffect extends PostProcessRenderEffect {
  108163. private bloomScale;
  108164. /**
  108165. * @hidden Internal
  108166. */
  108167. _effects: Array<PostProcess>;
  108168. /**
  108169. * @hidden Internal
  108170. */
  108171. _downscale: ExtractHighlightsPostProcess;
  108172. private _blurX;
  108173. private _blurY;
  108174. private _merge;
  108175. /**
  108176. * The luminance threshold to find bright areas of the image to bloom.
  108177. */
  108178. threshold: number;
  108179. /**
  108180. * The strength of the bloom.
  108181. */
  108182. weight: number;
  108183. /**
  108184. * Specifies the size of the bloom blur kernel, relative to the final output size
  108185. */
  108186. kernel: number;
  108187. /**
  108188. * Creates a new instance of @see BloomEffect
  108189. * @param scene The scene the effect belongs to.
  108190. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108191. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108192. * @param bloomWeight The the strength of bloom.
  108193. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108194. * @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)
  108195. */
  108196. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108197. /**
  108198. * Disposes each of the internal effects for a given camera.
  108199. * @param camera The camera to dispose the effect on.
  108200. */
  108201. disposeEffects(camera: Camera): void;
  108202. /**
  108203. * @hidden Internal
  108204. */
  108205. _updateEffects(): void;
  108206. /**
  108207. * Internal
  108208. * @returns if all the contained post processes are ready.
  108209. * @hidden
  108210. */
  108211. _isReady(): boolean;
  108212. }
  108213. }
  108214. declare module BABYLON {
  108215. /** @hidden */
  108216. export var chromaticAberrationPixelShader: {
  108217. name: string;
  108218. shader: string;
  108219. };
  108220. }
  108221. declare module BABYLON {
  108222. /**
  108223. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108224. */
  108225. export class ChromaticAberrationPostProcess extends PostProcess {
  108226. /**
  108227. * The amount of seperation of rgb channels (default: 30)
  108228. */
  108229. aberrationAmount: number;
  108230. /**
  108231. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108232. */
  108233. radialIntensity: number;
  108234. /**
  108235. * 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))
  108236. */
  108237. direction: Vector2;
  108238. /**
  108239. * 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))
  108240. */
  108241. centerPosition: Vector2;
  108242. /**
  108243. * Creates a new instance ChromaticAberrationPostProcess
  108244. * @param name The name of the effect.
  108245. * @param screenWidth The width of the screen to apply the effect on.
  108246. * @param screenHeight The height of the screen to apply the effect on.
  108247. * @param options The required width/height ratio to downsize to before computing the render pass.
  108248. * @param camera The camera to apply the render pass to.
  108249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108250. * @param engine The engine which the post process will be applied. (default: current engine)
  108251. * @param reusable If the post process can be reused on the same frame. (default: false)
  108252. * @param textureType Type of textures used when performing the post process. (default: 0)
  108253. * @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)
  108254. */
  108255. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108256. }
  108257. }
  108258. declare module BABYLON {
  108259. /** @hidden */
  108260. export var circleOfConfusionPixelShader: {
  108261. name: string;
  108262. shader: string;
  108263. };
  108264. }
  108265. declare module BABYLON {
  108266. /**
  108267. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108268. */
  108269. export class CircleOfConfusionPostProcess extends PostProcess {
  108270. /**
  108271. * 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.
  108272. */
  108273. lensSize: number;
  108274. /**
  108275. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108276. */
  108277. fStop: number;
  108278. /**
  108279. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108280. */
  108281. focusDistance: number;
  108282. /**
  108283. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108284. */
  108285. focalLength: number;
  108286. private _depthTexture;
  108287. /**
  108288. * Creates a new instance CircleOfConfusionPostProcess
  108289. * @param name The name of the effect.
  108290. * @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.
  108291. * @param options The required width/height ratio to downsize to before computing the render pass.
  108292. * @param camera The camera to apply the render pass to.
  108293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108294. * @param engine The engine which the post process will be applied. (default: current engine)
  108295. * @param reusable If the post process can be reused on the same frame. (default: false)
  108296. * @param textureType Type of textures used when performing the post process. (default: 0)
  108297. * @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)
  108298. */
  108299. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108300. /**
  108301. * 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.
  108302. */
  108303. depthTexture: RenderTargetTexture;
  108304. }
  108305. }
  108306. declare module BABYLON {
  108307. /** @hidden */
  108308. export var colorCorrectionPixelShader: {
  108309. name: string;
  108310. shader: string;
  108311. };
  108312. }
  108313. declare module BABYLON {
  108314. /**
  108315. *
  108316. * This post-process allows the modification of rendered colors by using
  108317. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108318. *
  108319. * The object needs to be provided an url to a texture containing the color
  108320. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108321. * Use an image editing software to tweak the LUT to match your needs.
  108322. *
  108323. * For an example of a color LUT, see here:
  108324. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108325. * For explanations on color grading, see here:
  108326. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108327. *
  108328. */
  108329. export class ColorCorrectionPostProcess extends PostProcess {
  108330. private _colorTableTexture;
  108331. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108332. }
  108333. }
  108334. declare module BABYLON {
  108335. /** @hidden */
  108336. export var convolutionPixelShader: {
  108337. name: string;
  108338. shader: string;
  108339. };
  108340. }
  108341. declare module BABYLON {
  108342. /**
  108343. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108344. * input texture to perform effects such as edge detection or sharpening
  108345. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108346. */
  108347. export class ConvolutionPostProcess extends PostProcess {
  108348. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108349. kernel: number[];
  108350. /**
  108351. * Creates a new instance ConvolutionPostProcess
  108352. * @param name The name of the effect.
  108353. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108354. * @param options The required width/height ratio to downsize to before computing the render pass.
  108355. * @param camera The camera to apply the render pass to.
  108356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108357. * @param engine The engine which the post process will be applied. (default: current engine)
  108358. * @param reusable If the post process can be reused on the same frame. (default: false)
  108359. * @param textureType Type of textures used when performing the post process. (default: 0)
  108360. */
  108361. constructor(name: string,
  108362. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108363. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108364. /**
  108365. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108366. */
  108367. static EdgeDetect0Kernel: number[];
  108368. /**
  108369. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108370. */
  108371. static EdgeDetect1Kernel: number[];
  108372. /**
  108373. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108374. */
  108375. static EdgeDetect2Kernel: number[];
  108376. /**
  108377. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108378. */
  108379. static SharpenKernel: number[];
  108380. /**
  108381. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108382. */
  108383. static EmbossKernel: number[];
  108384. /**
  108385. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108386. */
  108387. static GaussianKernel: number[];
  108388. }
  108389. }
  108390. declare module BABYLON {
  108391. /**
  108392. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108393. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108394. * based on samples that have a large difference in distance than the center pixel.
  108395. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108396. */
  108397. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108398. direction: Vector2;
  108399. /**
  108400. * Creates a new instance CircleOfConfusionPostProcess
  108401. * @param name The name of the effect.
  108402. * @param scene The scene the effect belongs to.
  108403. * @param direction The direction the blur should be applied.
  108404. * @param kernel The size of the kernel used to blur.
  108405. * @param options The required width/height ratio to downsize to before computing the render pass.
  108406. * @param camera The camera to apply the render pass to.
  108407. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108408. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108410. * @param engine The engine which the post process will be applied. (default: current engine)
  108411. * @param reusable If the post process can be reused on the same frame. (default: false)
  108412. * @param textureType Type of textures used when performing the post process. (default: 0)
  108413. * @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)
  108414. */
  108415. 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);
  108416. }
  108417. }
  108418. declare module BABYLON {
  108419. /** @hidden */
  108420. export var depthOfFieldMergePixelShader: {
  108421. name: string;
  108422. shader: string;
  108423. };
  108424. }
  108425. declare module BABYLON {
  108426. /**
  108427. * Options to be set when merging outputs from the default pipeline.
  108428. */
  108429. export class DepthOfFieldMergePostProcessOptions {
  108430. /**
  108431. * The original image to merge on top of
  108432. */
  108433. originalFromInput: PostProcess;
  108434. /**
  108435. * Parameters to perform the merge of the depth of field effect
  108436. */
  108437. depthOfField?: {
  108438. circleOfConfusion: PostProcess;
  108439. blurSteps: Array<PostProcess>;
  108440. };
  108441. /**
  108442. * Parameters to perform the merge of bloom effect
  108443. */
  108444. bloom?: {
  108445. blurred: PostProcess;
  108446. weight: number;
  108447. };
  108448. }
  108449. /**
  108450. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108451. */
  108452. export class DepthOfFieldMergePostProcess extends PostProcess {
  108453. private blurSteps;
  108454. /**
  108455. * Creates a new instance of DepthOfFieldMergePostProcess
  108456. * @param name The name of the effect.
  108457. * @param originalFromInput Post process which's input will be used for the merge.
  108458. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108459. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108460. * @param options The required width/height ratio to downsize to before computing the render pass.
  108461. * @param camera The camera to apply the render pass to.
  108462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108463. * @param engine The engine which the post process will be applied. (default: current engine)
  108464. * @param reusable If the post process can be reused on the same frame. (default: false)
  108465. * @param textureType Type of textures used when performing the post process. (default: 0)
  108466. * @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)
  108467. */
  108468. 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);
  108469. /**
  108470. * Updates the effect with the current post process compile time values and recompiles the shader.
  108471. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108472. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108473. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108474. * @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
  108475. * @param onCompiled Called when the shader has been compiled.
  108476. * @param onError Called if there is an error when compiling a shader.
  108477. */
  108478. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108479. }
  108480. }
  108481. declare module BABYLON {
  108482. /**
  108483. * Specifies the level of max blur that should be applied when using the depth of field effect
  108484. */
  108485. export enum DepthOfFieldEffectBlurLevel {
  108486. /**
  108487. * Subtle blur
  108488. */
  108489. Low = 0,
  108490. /**
  108491. * Medium blur
  108492. */
  108493. Medium = 1,
  108494. /**
  108495. * Large blur
  108496. */
  108497. High = 2
  108498. }
  108499. /**
  108500. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108501. */
  108502. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108503. private _circleOfConfusion;
  108504. /**
  108505. * @hidden Internal, blurs from high to low
  108506. */
  108507. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108508. private _depthOfFieldBlurY;
  108509. private _dofMerge;
  108510. /**
  108511. * @hidden Internal post processes in depth of field effect
  108512. */
  108513. _effects: Array<PostProcess>;
  108514. /**
  108515. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108516. */
  108517. focalLength: number;
  108518. /**
  108519. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108520. */
  108521. fStop: number;
  108522. /**
  108523. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108524. */
  108525. focusDistance: number;
  108526. /**
  108527. * 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.
  108528. */
  108529. lensSize: number;
  108530. /**
  108531. * Creates a new instance DepthOfFieldEffect
  108532. * @param scene The scene the effect belongs to.
  108533. * @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.
  108534. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108535. * @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)
  108536. */
  108537. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108538. /**
  108539. * 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.
  108540. */
  108541. depthTexture: RenderTargetTexture;
  108542. /**
  108543. * Disposes each of the internal effects for a given camera.
  108544. * @param camera The camera to dispose the effect on.
  108545. */
  108546. disposeEffects(camera: Camera): void;
  108547. /**
  108548. * @hidden Internal
  108549. */
  108550. _updateEffects(): void;
  108551. /**
  108552. * Internal
  108553. * @returns if all the contained post processes are ready.
  108554. * @hidden
  108555. */
  108556. _isReady(): boolean;
  108557. }
  108558. }
  108559. declare module BABYLON {
  108560. /** @hidden */
  108561. export var displayPassPixelShader: {
  108562. name: string;
  108563. shader: string;
  108564. };
  108565. }
  108566. declare module BABYLON {
  108567. /**
  108568. * DisplayPassPostProcess which produces an output the same as it's input
  108569. */
  108570. export class DisplayPassPostProcess extends PostProcess {
  108571. /**
  108572. * Creates the DisplayPassPostProcess
  108573. * @param name The name of the effect.
  108574. * @param options The required width/height ratio to downsize to before computing the render pass.
  108575. * @param camera The camera to apply the render pass to.
  108576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108577. * @param engine The engine which the post process will be applied. (default: current engine)
  108578. * @param reusable If the post process can be reused on the same frame. (default: false)
  108579. */
  108580. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108581. }
  108582. }
  108583. declare module BABYLON {
  108584. /** @hidden */
  108585. export var filterPixelShader: {
  108586. name: string;
  108587. shader: string;
  108588. };
  108589. }
  108590. declare module BABYLON {
  108591. /**
  108592. * Applies a kernel filter to the image
  108593. */
  108594. export class FilterPostProcess extends PostProcess {
  108595. /** The matrix to be applied to the image */
  108596. kernelMatrix: Matrix;
  108597. /**
  108598. *
  108599. * @param name The name of the effect.
  108600. * @param kernelMatrix The matrix to be applied to the image
  108601. * @param options The required width/height ratio to downsize to before computing the render pass.
  108602. * @param camera The camera to apply the render pass to.
  108603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108604. * @param engine The engine which the post process will be applied. (default: current engine)
  108605. * @param reusable If the post process can be reused on the same frame. (default: false)
  108606. */
  108607. constructor(name: string,
  108608. /** The matrix to be applied to the image */
  108609. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /** @hidden */
  108614. export var fxaaPixelShader: {
  108615. name: string;
  108616. shader: string;
  108617. };
  108618. }
  108619. declare module BABYLON {
  108620. /** @hidden */
  108621. export var fxaaVertexShader: {
  108622. name: string;
  108623. shader: string;
  108624. };
  108625. }
  108626. declare module BABYLON {
  108627. /**
  108628. * Fxaa post process
  108629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108630. */
  108631. export class FxaaPostProcess extends PostProcess {
  108632. /** @hidden */
  108633. texelWidth: number;
  108634. /** @hidden */
  108635. texelHeight: number;
  108636. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108637. private _getDefines;
  108638. }
  108639. }
  108640. declare module BABYLON {
  108641. /** @hidden */
  108642. export var grainPixelShader: {
  108643. name: string;
  108644. shader: string;
  108645. };
  108646. }
  108647. declare module BABYLON {
  108648. /**
  108649. * The GrainPostProcess adds noise to the image at mid luminance levels
  108650. */
  108651. export class GrainPostProcess extends PostProcess {
  108652. /**
  108653. * The intensity of the grain added (default: 30)
  108654. */
  108655. intensity: number;
  108656. /**
  108657. * If the grain should be randomized on every frame
  108658. */
  108659. animated: boolean;
  108660. /**
  108661. * Creates a new instance of @see GrainPostProcess
  108662. * @param name The name of the effect.
  108663. * @param options The required width/height ratio to downsize to before computing the render pass.
  108664. * @param camera The camera to apply the render pass to.
  108665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108666. * @param engine The engine which the post process will be applied. (default: current engine)
  108667. * @param reusable If the post process can be reused on the same frame. (default: false)
  108668. * @param textureType Type of textures used when performing the post process. (default: 0)
  108669. * @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)
  108670. */
  108671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108672. }
  108673. }
  108674. declare module BABYLON {
  108675. /** @hidden */
  108676. export var highlightsPixelShader: {
  108677. name: string;
  108678. shader: string;
  108679. };
  108680. }
  108681. declare module BABYLON {
  108682. /**
  108683. * Extracts highlights from the image
  108684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108685. */
  108686. export class HighlightsPostProcess extends PostProcess {
  108687. /**
  108688. * Extracts highlights from the image
  108689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108690. * @param name The name of the effect.
  108691. * @param options The required width/height ratio to downsize to before computing the render pass.
  108692. * @param camera The camera to apply the render pass to.
  108693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108694. * @param engine The engine which the post process will be applied. (default: current engine)
  108695. * @param reusable If the post process can be reused on the same frame. (default: false)
  108696. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108697. */
  108698. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108699. }
  108700. }
  108701. declare module BABYLON {
  108702. /** @hidden */
  108703. export var mrtFragmentDeclaration: {
  108704. name: string;
  108705. shader: string;
  108706. };
  108707. }
  108708. declare module BABYLON {
  108709. /** @hidden */
  108710. export var geometryPixelShader: {
  108711. name: string;
  108712. shader: string;
  108713. };
  108714. }
  108715. declare module BABYLON {
  108716. /** @hidden */
  108717. export var geometryVertexShader: {
  108718. name: string;
  108719. shader: string;
  108720. };
  108721. }
  108722. declare module BABYLON {
  108723. /**
  108724. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108725. */
  108726. export class GeometryBufferRenderer {
  108727. /**
  108728. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108729. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108730. */
  108731. static readonly POSITION_TEXTURE_TYPE: number;
  108732. /**
  108733. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108734. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108735. */
  108736. static readonly VELOCITY_TEXTURE_TYPE: number;
  108737. /**
  108738. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108739. * in order to compute objects velocities when enableVelocity is set to "true"
  108740. * @hidden
  108741. */
  108742. _previousTransformationMatrices: {
  108743. [index: number]: Matrix;
  108744. };
  108745. private _scene;
  108746. private _multiRenderTarget;
  108747. private _ratio;
  108748. private _enablePosition;
  108749. private _enableVelocity;
  108750. private _positionIndex;
  108751. private _velocityIndex;
  108752. protected _effect: Effect;
  108753. protected _cachedDefines: string;
  108754. /**
  108755. * Set the render list (meshes to be rendered) used in the G buffer.
  108756. */
  108757. renderList: Mesh[];
  108758. /**
  108759. * Gets wether or not G buffer are supported by the running hardware.
  108760. * This requires draw buffer supports
  108761. */
  108762. readonly isSupported: boolean;
  108763. /**
  108764. * Returns the index of the given texture type in the G-Buffer textures array
  108765. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108766. * @returns the index of the given texture type in the G-Buffer textures array
  108767. */
  108768. getTextureIndex(textureType: number): number;
  108769. /**
  108770. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108771. */
  108772. /**
  108773. * Sets whether or not objects positions are enabled for the G buffer.
  108774. */
  108775. enablePosition: boolean;
  108776. /**
  108777. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108778. */
  108779. /**
  108780. * Sets wether or not objects velocities are enabled for the G buffer.
  108781. */
  108782. enableVelocity: boolean;
  108783. /**
  108784. * Gets the scene associated with the buffer.
  108785. */
  108786. readonly scene: Scene;
  108787. /**
  108788. * Gets the ratio used by the buffer during its creation.
  108789. * How big is the buffer related to the main canvas.
  108790. */
  108791. readonly ratio: number;
  108792. /** @hidden */
  108793. static _SceneComponentInitialization: (scene: Scene) => void;
  108794. /**
  108795. * Creates a new G Buffer for the scene
  108796. * @param scene The scene the buffer belongs to
  108797. * @param ratio How big is the buffer related to the main canvas.
  108798. */
  108799. constructor(scene: Scene, ratio?: number);
  108800. /**
  108801. * Checks wether everything is ready to render a submesh to the G buffer.
  108802. * @param subMesh the submesh to check readiness for
  108803. * @param useInstances is the mesh drawn using instance or not
  108804. * @returns true if ready otherwise false
  108805. */
  108806. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108807. /**
  108808. * Gets the current underlying G Buffer.
  108809. * @returns the buffer
  108810. */
  108811. getGBuffer(): MultiRenderTarget;
  108812. /**
  108813. * Gets the number of samples used to render the buffer (anti aliasing).
  108814. */
  108815. /**
  108816. * Sets the number of samples used to render the buffer (anti aliasing).
  108817. */
  108818. samples: number;
  108819. /**
  108820. * Disposes the renderer and frees up associated resources.
  108821. */
  108822. dispose(): void;
  108823. protected _createRenderTargets(): void;
  108824. }
  108825. }
  108826. declare module BABYLON {
  108827. interface Scene {
  108828. /** @hidden (Backing field) */
  108829. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108830. /**
  108831. * Gets or Sets the current geometry buffer associated to the scene.
  108832. */
  108833. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108834. /**
  108835. * Enables a GeometryBufferRender and associates it with the scene
  108836. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108837. * @returns the GeometryBufferRenderer
  108838. */
  108839. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108840. /**
  108841. * Disables the GeometryBufferRender associated with the scene
  108842. */
  108843. disableGeometryBufferRenderer(): void;
  108844. }
  108845. /**
  108846. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108847. * in several rendering techniques.
  108848. */
  108849. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108850. /**
  108851. * The component name helpful to identify the component in the list of scene components.
  108852. */
  108853. readonly name: string;
  108854. /**
  108855. * The scene the component belongs to.
  108856. */
  108857. scene: Scene;
  108858. /**
  108859. * Creates a new instance of the component for the given scene
  108860. * @param scene Defines the scene to register the component in
  108861. */
  108862. constructor(scene: Scene);
  108863. /**
  108864. * Registers the component in a given scene
  108865. */
  108866. register(): void;
  108867. /**
  108868. * Rebuilds the elements related to this component in case of
  108869. * context lost for instance.
  108870. */
  108871. rebuild(): void;
  108872. /**
  108873. * Disposes the component and the associated ressources
  108874. */
  108875. dispose(): void;
  108876. private _gatherRenderTargets;
  108877. }
  108878. }
  108879. declare module BABYLON {
  108880. /** @hidden */
  108881. export var motionBlurPixelShader: {
  108882. name: string;
  108883. shader: string;
  108884. };
  108885. }
  108886. declare module BABYLON {
  108887. /**
  108888. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108889. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108890. * As an example, all you have to do is to create the post-process:
  108891. * var mb = new BABYLON.MotionBlurPostProcess(
  108892. * 'mb', // The name of the effect.
  108893. * scene, // The scene containing the objects to blur according to their velocity.
  108894. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108895. * camera // The camera to apply the render pass to.
  108896. * );
  108897. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108898. */
  108899. export class MotionBlurPostProcess extends PostProcess {
  108900. /**
  108901. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108902. */
  108903. motionStrength: number;
  108904. /**
  108905. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108906. */
  108907. /**
  108908. * Sets the number of iterations to be used for motion blur quality
  108909. */
  108910. motionBlurSamples: number;
  108911. private _motionBlurSamples;
  108912. private _geometryBufferRenderer;
  108913. /**
  108914. * Creates a new instance MotionBlurPostProcess
  108915. * @param name The name of the effect.
  108916. * @param scene The scene containing the objects to blur according to their velocity.
  108917. * @param options The required width/height ratio to downsize to before computing the render pass.
  108918. * @param camera The camera to apply the render pass to.
  108919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108920. * @param engine The engine which the post process will be applied. (default: current engine)
  108921. * @param reusable If the post process can be reused on the same frame. (default: false)
  108922. * @param textureType Type of textures used when performing the post process. (default: 0)
  108923. * @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)
  108924. */
  108925. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108926. /**
  108927. * Disposes the post process.
  108928. * @param camera The camera to dispose the post process on.
  108929. */
  108930. dispose(camera?: Camera): void;
  108931. }
  108932. }
  108933. declare module BABYLON {
  108934. /** @hidden */
  108935. export var refractionPixelShader: {
  108936. name: string;
  108937. shader: string;
  108938. };
  108939. }
  108940. declare module BABYLON {
  108941. /**
  108942. * Post process which applies a refractin texture
  108943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108944. */
  108945. export class RefractionPostProcess extends PostProcess {
  108946. /** the base color of the refraction (used to taint the rendering) */
  108947. color: Color3;
  108948. /** simulated refraction depth */
  108949. depth: number;
  108950. /** the coefficient of the base color (0 to remove base color tainting) */
  108951. colorLevel: number;
  108952. private _refTexture;
  108953. private _ownRefractionTexture;
  108954. /**
  108955. * Gets or sets the refraction texture
  108956. * Please note that you are responsible for disposing the texture if you set it manually
  108957. */
  108958. refractionTexture: Texture;
  108959. /**
  108960. * Initializes the RefractionPostProcess
  108961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108962. * @param name The name of the effect.
  108963. * @param refractionTextureUrl Url of the refraction texture to use
  108964. * @param color the base color of the refraction (used to taint the rendering)
  108965. * @param depth simulated refraction depth
  108966. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108967. * @param camera The camera to apply the render pass to.
  108968. * @param options The required width/height ratio to downsize to before computing the render pass.
  108969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108970. * @param engine The engine which the post process will be applied. (default: current engine)
  108971. * @param reusable If the post process can be reused on the same frame. (default: false)
  108972. */
  108973. constructor(name: string, refractionTextureUrl: string,
  108974. /** the base color of the refraction (used to taint the rendering) */
  108975. color: Color3,
  108976. /** simulated refraction depth */
  108977. depth: number,
  108978. /** the coefficient of the base color (0 to remove base color tainting) */
  108979. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108980. /**
  108981. * Disposes of the post process
  108982. * @param camera Camera to dispose post process on
  108983. */
  108984. dispose(camera: Camera): void;
  108985. }
  108986. }
  108987. declare module BABYLON {
  108988. /** @hidden */
  108989. export var sharpenPixelShader: {
  108990. name: string;
  108991. shader: string;
  108992. };
  108993. }
  108994. declare module BABYLON {
  108995. /**
  108996. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108997. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108998. */
  108999. export class SharpenPostProcess extends PostProcess {
  109000. /**
  109001. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  109002. */
  109003. colorAmount: number;
  109004. /**
  109005. * How much sharpness should be applied (default: 0.3)
  109006. */
  109007. edgeAmount: number;
  109008. /**
  109009. * Creates a new instance ConvolutionPostProcess
  109010. * @param name The name of the effect.
  109011. * @param options The required width/height ratio to downsize to before computing the render pass.
  109012. * @param camera The camera to apply the render pass to.
  109013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109014. * @param engine The engine which the post process will be applied. (default: current engine)
  109015. * @param reusable If the post process can be reused on the same frame. (default: false)
  109016. * @param textureType Type of textures used when performing the post process. (default: 0)
  109017. * @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)
  109018. */
  109019. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109020. }
  109021. }
  109022. declare module BABYLON {
  109023. /**
  109024. * PostProcessRenderPipeline
  109025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109026. */
  109027. export class PostProcessRenderPipeline {
  109028. private engine;
  109029. private _renderEffects;
  109030. private _renderEffectsForIsolatedPass;
  109031. /**
  109032. * @hidden
  109033. */
  109034. protected _cameras: Camera[];
  109035. /** @hidden */
  109036. _name: string;
  109037. /**
  109038. * Gets pipeline name
  109039. */
  109040. readonly name: string;
  109041. /**
  109042. * Initializes a PostProcessRenderPipeline
  109043. * @param engine engine to add the pipeline to
  109044. * @param name name of the pipeline
  109045. */
  109046. constructor(engine: Engine, name: string);
  109047. /**
  109048. * Gets the class name
  109049. * @returns "PostProcessRenderPipeline"
  109050. */
  109051. getClassName(): string;
  109052. /**
  109053. * If all the render effects in the pipeline are supported
  109054. */
  109055. readonly isSupported: boolean;
  109056. /**
  109057. * Adds an effect to the pipeline
  109058. * @param renderEffect the effect to add
  109059. */
  109060. addEffect(renderEffect: PostProcessRenderEffect): void;
  109061. /** @hidden */
  109062. _rebuild(): void;
  109063. /** @hidden */
  109064. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109065. /** @hidden */
  109066. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109067. /** @hidden */
  109068. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109069. /** @hidden */
  109070. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109071. /** @hidden */
  109072. _attachCameras(cameras: Camera, unique: boolean): void;
  109073. /** @hidden */
  109074. _attachCameras(cameras: Camera[], unique: boolean): void;
  109075. /** @hidden */
  109076. _detachCameras(cameras: Camera): void;
  109077. /** @hidden */
  109078. _detachCameras(cameras: Nullable<Camera[]>): void;
  109079. /** @hidden */
  109080. _update(): void;
  109081. /** @hidden */
  109082. _reset(): void;
  109083. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109084. /**
  109085. * Disposes of the pipeline
  109086. */
  109087. dispose(): void;
  109088. }
  109089. }
  109090. declare module BABYLON {
  109091. /**
  109092. * PostProcessRenderPipelineManager class
  109093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109094. */
  109095. export class PostProcessRenderPipelineManager {
  109096. private _renderPipelines;
  109097. /**
  109098. * Initializes a PostProcessRenderPipelineManager
  109099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109100. */
  109101. constructor();
  109102. /**
  109103. * Gets the list of supported render pipelines
  109104. */
  109105. readonly supportedPipelines: PostProcessRenderPipeline[];
  109106. /**
  109107. * Adds a pipeline to the manager
  109108. * @param renderPipeline The pipeline to add
  109109. */
  109110. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109111. /**
  109112. * Attaches a camera to the pipeline
  109113. * @param renderPipelineName The name of the pipeline to attach to
  109114. * @param cameras the camera to attach
  109115. * @param unique if the camera can be attached multiple times to the pipeline
  109116. */
  109117. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109118. /**
  109119. * Detaches a camera from the pipeline
  109120. * @param renderPipelineName The name of the pipeline to detach from
  109121. * @param cameras the camera to detach
  109122. */
  109123. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109124. /**
  109125. * Enables an effect by name on a pipeline
  109126. * @param renderPipelineName the name of the pipeline to enable the effect in
  109127. * @param renderEffectName the name of the effect to enable
  109128. * @param cameras the cameras that the effect should be enabled on
  109129. */
  109130. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109131. /**
  109132. * Disables an effect by name on a pipeline
  109133. * @param renderPipelineName the name of the pipeline to disable the effect in
  109134. * @param renderEffectName the name of the effect to disable
  109135. * @param cameras the cameras that the effect should be disabled on
  109136. */
  109137. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109138. /**
  109139. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109140. */
  109141. update(): void;
  109142. /** @hidden */
  109143. _rebuild(): void;
  109144. /**
  109145. * Disposes of the manager and pipelines
  109146. */
  109147. dispose(): void;
  109148. }
  109149. }
  109150. declare module BABYLON {
  109151. interface Scene {
  109152. /** @hidden (Backing field) */
  109153. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109154. /**
  109155. * Gets the postprocess render pipeline manager
  109156. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109157. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109158. */
  109159. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109160. }
  109161. /**
  109162. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109163. */
  109164. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109165. /**
  109166. * The component name helpfull to identify the component in the list of scene components.
  109167. */
  109168. readonly name: string;
  109169. /**
  109170. * The scene the component belongs to.
  109171. */
  109172. scene: Scene;
  109173. /**
  109174. * Creates a new instance of the component for the given scene
  109175. * @param scene Defines the scene to register the component in
  109176. */
  109177. constructor(scene: Scene);
  109178. /**
  109179. * Registers the component in a given scene
  109180. */
  109181. register(): void;
  109182. /**
  109183. * Rebuilds the elements related to this component in case of
  109184. * context lost for instance.
  109185. */
  109186. rebuild(): void;
  109187. /**
  109188. * Disposes the component and the associated ressources
  109189. */
  109190. dispose(): void;
  109191. private _gatherRenderTargets;
  109192. }
  109193. }
  109194. declare module BABYLON {
  109195. /**
  109196. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109197. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109198. */
  109199. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109200. private _scene;
  109201. private _camerasToBeAttached;
  109202. /**
  109203. * ID of the sharpen post process,
  109204. */
  109205. private readonly SharpenPostProcessId;
  109206. /**
  109207. * @ignore
  109208. * ID of the image processing post process;
  109209. */
  109210. readonly ImageProcessingPostProcessId: string;
  109211. /**
  109212. * @ignore
  109213. * ID of the Fast Approximate Anti-Aliasing post process;
  109214. */
  109215. readonly FxaaPostProcessId: string;
  109216. /**
  109217. * ID of the chromatic aberration post process,
  109218. */
  109219. private readonly ChromaticAberrationPostProcessId;
  109220. /**
  109221. * ID of the grain post process
  109222. */
  109223. private readonly GrainPostProcessId;
  109224. /**
  109225. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109226. */
  109227. sharpen: SharpenPostProcess;
  109228. private _sharpenEffect;
  109229. private bloom;
  109230. /**
  109231. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109232. */
  109233. depthOfField: DepthOfFieldEffect;
  109234. /**
  109235. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109236. */
  109237. fxaa: FxaaPostProcess;
  109238. /**
  109239. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109240. */
  109241. imageProcessing: ImageProcessingPostProcess;
  109242. /**
  109243. * Chromatic aberration post process which will shift rgb colors in the image
  109244. */
  109245. chromaticAberration: ChromaticAberrationPostProcess;
  109246. private _chromaticAberrationEffect;
  109247. /**
  109248. * Grain post process which add noise to the image
  109249. */
  109250. grain: GrainPostProcess;
  109251. private _grainEffect;
  109252. /**
  109253. * Glow post process which adds a glow to emissive areas of the image
  109254. */
  109255. private _glowLayer;
  109256. /**
  109257. * Animations which can be used to tweak settings over a period of time
  109258. */
  109259. animations: Animation[];
  109260. private _imageProcessingConfigurationObserver;
  109261. private _sharpenEnabled;
  109262. private _bloomEnabled;
  109263. private _depthOfFieldEnabled;
  109264. private _depthOfFieldBlurLevel;
  109265. private _fxaaEnabled;
  109266. private _imageProcessingEnabled;
  109267. private _defaultPipelineTextureType;
  109268. private _bloomScale;
  109269. private _chromaticAberrationEnabled;
  109270. private _grainEnabled;
  109271. private _buildAllowed;
  109272. /**
  109273. * Gets active scene
  109274. */
  109275. readonly scene: Scene;
  109276. /**
  109277. * Enable or disable the sharpen process from the pipeline
  109278. */
  109279. sharpenEnabled: boolean;
  109280. private _resizeObserver;
  109281. private _hardwareScaleLevel;
  109282. private _bloomKernel;
  109283. /**
  109284. * Specifies the size of the bloom blur kernel, relative to the final output size
  109285. */
  109286. bloomKernel: number;
  109287. /**
  109288. * Specifies the weight of the bloom in the final rendering
  109289. */
  109290. private _bloomWeight;
  109291. /**
  109292. * Specifies the luma threshold for the area that will be blurred by the bloom
  109293. */
  109294. private _bloomThreshold;
  109295. private _hdr;
  109296. /**
  109297. * The strength of the bloom.
  109298. */
  109299. bloomWeight: number;
  109300. /**
  109301. * The strength of the bloom.
  109302. */
  109303. bloomThreshold: number;
  109304. /**
  109305. * The scale of the bloom, lower value will provide better performance.
  109306. */
  109307. bloomScale: number;
  109308. /**
  109309. * Enable or disable the bloom from the pipeline
  109310. */
  109311. bloomEnabled: boolean;
  109312. private _rebuildBloom;
  109313. /**
  109314. * If the depth of field is enabled.
  109315. */
  109316. depthOfFieldEnabled: boolean;
  109317. /**
  109318. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109319. */
  109320. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109321. /**
  109322. * If the anti aliasing is enabled.
  109323. */
  109324. fxaaEnabled: boolean;
  109325. private _samples;
  109326. /**
  109327. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109328. */
  109329. samples: number;
  109330. /**
  109331. * If image processing is enabled.
  109332. */
  109333. imageProcessingEnabled: boolean;
  109334. /**
  109335. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109336. */
  109337. glowLayerEnabled: boolean;
  109338. /**
  109339. * Enable or disable the chromaticAberration process from the pipeline
  109340. */
  109341. chromaticAberrationEnabled: boolean;
  109342. /**
  109343. * Enable or disable the grain process from the pipeline
  109344. */
  109345. grainEnabled: boolean;
  109346. /**
  109347. * @constructor
  109348. * @param name - The rendering pipeline name (default: "")
  109349. * @param hdr - If high dynamic range textures should be used (default: true)
  109350. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109351. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109352. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109353. */
  109354. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109355. /**
  109356. * Get the class name
  109357. * @returns "DefaultRenderingPipeline"
  109358. */
  109359. getClassName(): string;
  109360. /**
  109361. * Force the compilation of the entire pipeline.
  109362. */
  109363. prepare(): void;
  109364. private _hasCleared;
  109365. private _prevPostProcess;
  109366. private _prevPrevPostProcess;
  109367. private _setAutoClearAndTextureSharing;
  109368. private _depthOfFieldSceneObserver;
  109369. private _buildPipeline;
  109370. private _disposePostProcesses;
  109371. /**
  109372. * Adds a camera to the pipeline
  109373. * @param camera the camera to be added
  109374. */
  109375. addCamera(camera: Camera): void;
  109376. /**
  109377. * Removes a camera from the pipeline
  109378. * @param camera the camera to remove
  109379. */
  109380. removeCamera(camera: Camera): void;
  109381. /**
  109382. * Dispose of the pipeline and stop all post processes
  109383. */
  109384. dispose(): void;
  109385. /**
  109386. * Serialize the rendering pipeline (Used when exporting)
  109387. * @returns the serialized object
  109388. */
  109389. serialize(): any;
  109390. /**
  109391. * Parse the serialized pipeline
  109392. * @param source Source pipeline.
  109393. * @param scene The scene to load the pipeline to.
  109394. * @param rootUrl The URL of the serialized pipeline.
  109395. * @returns An instantiated pipeline from the serialized object.
  109396. */
  109397. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109398. }
  109399. }
  109400. declare module BABYLON {
  109401. /** @hidden */
  109402. export var lensHighlightsPixelShader: {
  109403. name: string;
  109404. shader: string;
  109405. };
  109406. }
  109407. declare module BABYLON {
  109408. /** @hidden */
  109409. export var depthOfFieldPixelShader: {
  109410. name: string;
  109411. shader: string;
  109412. };
  109413. }
  109414. declare module BABYLON {
  109415. /**
  109416. * BABYLON.JS Chromatic Aberration GLSL Shader
  109417. * Author: Olivier Guyot
  109418. * Separates very slightly R, G and B colors on the edges of the screen
  109419. * Inspired by Francois Tarlier & Martins Upitis
  109420. */
  109421. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109422. /**
  109423. * @ignore
  109424. * The chromatic aberration PostProcess id in the pipeline
  109425. */
  109426. LensChromaticAberrationEffect: string;
  109427. /**
  109428. * @ignore
  109429. * The highlights enhancing PostProcess id in the pipeline
  109430. */
  109431. HighlightsEnhancingEffect: string;
  109432. /**
  109433. * @ignore
  109434. * The depth-of-field PostProcess id in the pipeline
  109435. */
  109436. LensDepthOfFieldEffect: string;
  109437. private _scene;
  109438. private _depthTexture;
  109439. private _grainTexture;
  109440. private _chromaticAberrationPostProcess;
  109441. private _highlightsPostProcess;
  109442. private _depthOfFieldPostProcess;
  109443. private _edgeBlur;
  109444. private _grainAmount;
  109445. private _chromaticAberration;
  109446. private _distortion;
  109447. private _highlightsGain;
  109448. private _highlightsThreshold;
  109449. private _dofDistance;
  109450. private _dofAperture;
  109451. private _dofDarken;
  109452. private _dofPentagon;
  109453. private _blurNoise;
  109454. /**
  109455. * @constructor
  109456. *
  109457. * Effect parameters are as follow:
  109458. * {
  109459. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109460. * edge_blur: number; // from 0 to x (1 for realism)
  109461. * distortion: number; // from 0 to x (1 for realism)
  109462. * grain_amount: number; // from 0 to 1
  109463. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109464. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109465. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109466. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109467. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109468. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109469. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109470. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109471. * }
  109472. * Note: if an effect parameter is unset, effect is disabled
  109473. *
  109474. * @param name The rendering pipeline name
  109475. * @param parameters - An object containing all parameters (see above)
  109476. * @param scene The scene linked to this pipeline
  109477. * @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)
  109478. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109479. */
  109480. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109481. /**
  109482. * Sets the amount of blur at the edges
  109483. * @param amount blur amount
  109484. */
  109485. setEdgeBlur(amount: number): void;
  109486. /**
  109487. * Sets edge blur to 0
  109488. */
  109489. disableEdgeBlur(): void;
  109490. /**
  109491. * Sets the amout of grain
  109492. * @param amount Amount of grain
  109493. */
  109494. setGrainAmount(amount: number): void;
  109495. /**
  109496. * Set grain amount to 0
  109497. */
  109498. disableGrain(): void;
  109499. /**
  109500. * Sets the chromatic aberration amount
  109501. * @param amount amount of chromatic aberration
  109502. */
  109503. setChromaticAberration(amount: number): void;
  109504. /**
  109505. * Sets chromatic aberration amount to 0
  109506. */
  109507. disableChromaticAberration(): void;
  109508. /**
  109509. * Sets the EdgeDistortion amount
  109510. * @param amount amount of EdgeDistortion
  109511. */
  109512. setEdgeDistortion(amount: number): void;
  109513. /**
  109514. * Sets edge distortion to 0
  109515. */
  109516. disableEdgeDistortion(): void;
  109517. /**
  109518. * Sets the FocusDistance amount
  109519. * @param amount amount of FocusDistance
  109520. */
  109521. setFocusDistance(amount: number): void;
  109522. /**
  109523. * Disables depth of field
  109524. */
  109525. disableDepthOfField(): void;
  109526. /**
  109527. * Sets the Aperture amount
  109528. * @param amount amount of Aperture
  109529. */
  109530. setAperture(amount: number): void;
  109531. /**
  109532. * Sets the DarkenOutOfFocus amount
  109533. * @param amount amount of DarkenOutOfFocus
  109534. */
  109535. setDarkenOutOfFocus(amount: number): void;
  109536. /**
  109537. * Creates a pentagon bokeh effect
  109538. */
  109539. enablePentagonBokeh(): void;
  109540. /**
  109541. * Disables the pentagon bokeh effect
  109542. */
  109543. disablePentagonBokeh(): void;
  109544. /**
  109545. * Enables noise blur
  109546. */
  109547. enableNoiseBlur(): void;
  109548. /**
  109549. * Disables noise blur
  109550. */
  109551. disableNoiseBlur(): void;
  109552. /**
  109553. * Sets the HighlightsGain amount
  109554. * @param amount amount of HighlightsGain
  109555. */
  109556. setHighlightsGain(amount: number): void;
  109557. /**
  109558. * Sets the HighlightsThreshold amount
  109559. * @param amount amount of HighlightsThreshold
  109560. */
  109561. setHighlightsThreshold(amount: number): void;
  109562. /**
  109563. * Disables highlights
  109564. */
  109565. disableHighlights(): void;
  109566. /**
  109567. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109568. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109569. */
  109570. dispose(disableDepthRender?: boolean): void;
  109571. private _createChromaticAberrationPostProcess;
  109572. private _createHighlightsPostProcess;
  109573. private _createDepthOfFieldPostProcess;
  109574. private _createGrainTexture;
  109575. }
  109576. }
  109577. declare module BABYLON {
  109578. /** @hidden */
  109579. export var ssao2PixelShader: {
  109580. name: string;
  109581. shader: string;
  109582. };
  109583. }
  109584. declare module BABYLON {
  109585. /** @hidden */
  109586. export var ssaoCombinePixelShader: {
  109587. name: string;
  109588. shader: string;
  109589. };
  109590. }
  109591. declare module BABYLON {
  109592. /**
  109593. * Render pipeline to produce ssao effect
  109594. */
  109595. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109596. /**
  109597. * @ignore
  109598. * The PassPostProcess id in the pipeline that contains the original scene color
  109599. */
  109600. SSAOOriginalSceneColorEffect: string;
  109601. /**
  109602. * @ignore
  109603. * The SSAO PostProcess id in the pipeline
  109604. */
  109605. SSAORenderEffect: string;
  109606. /**
  109607. * @ignore
  109608. * The horizontal blur PostProcess id in the pipeline
  109609. */
  109610. SSAOBlurHRenderEffect: string;
  109611. /**
  109612. * @ignore
  109613. * The vertical blur PostProcess id in the pipeline
  109614. */
  109615. SSAOBlurVRenderEffect: string;
  109616. /**
  109617. * @ignore
  109618. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109619. */
  109620. SSAOCombineRenderEffect: string;
  109621. /**
  109622. * The output strength of the SSAO post-process. Default value is 1.0.
  109623. */
  109624. totalStrength: number;
  109625. /**
  109626. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109627. */
  109628. maxZ: number;
  109629. /**
  109630. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109631. */
  109632. minZAspect: number;
  109633. private _samples;
  109634. /**
  109635. * Number of samples used for the SSAO calculations. Default value is 8
  109636. */
  109637. samples: number;
  109638. private _textureSamples;
  109639. /**
  109640. * Number of samples to use for antialiasing
  109641. */
  109642. textureSamples: number;
  109643. /**
  109644. * Ratio object used for SSAO ratio and blur ratio
  109645. */
  109646. private _ratio;
  109647. /**
  109648. * Dynamically generated sphere sampler.
  109649. */
  109650. private _sampleSphere;
  109651. /**
  109652. * Blur filter offsets
  109653. */
  109654. private _samplerOffsets;
  109655. private _expensiveBlur;
  109656. /**
  109657. * If bilateral blur should be used
  109658. */
  109659. expensiveBlur: boolean;
  109660. /**
  109661. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109662. */
  109663. radius: number;
  109664. /**
  109665. * The base color of the SSAO post-process
  109666. * The final result is "base + ssao" between [0, 1]
  109667. */
  109668. base: number;
  109669. /**
  109670. * Support test.
  109671. */
  109672. static readonly IsSupported: boolean;
  109673. private _scene;
  109674. private _depthTexture;
  109675. private _normalTexture;
  109676. private _randomTexture;
  109677. private _originalColorPostProcess;
  109678. private _ssaoPostProcess;
  109679. private _blurHPostProcess;
  109680. private _blurVPostProcess;
  109681. private _ssaoCombinePostProcess;
  109682. private _firstUpdate;
  109683. /**
  109684. * Gets active scene
  109685. */
  109686. readonly scene: Scene;
  109687. /**
  109688. * @constructor
  109689. * @param name The rendering pipeline name
  109690. * @param scene The scene linked to this pipeline
  109691. * @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 }
  109692. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109693. */
  109694. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109695. /**
  109696. * Get the class name
  109697. * @returns "SSAO2RenderingPipeline"
  109698. */
  109699. getClassName(): string;
  109700. /**
  109701. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109702. */
  109703. dispose(disableGeometryBufferRenderer?: boolean): void;
  109704. private _createBlurPostProcess;
  109705. /** @hidden */
  109706. _rebuild(): void;
  109707. private _bits;
  109708. private _radicalInverse_VdC;
  109709. private _hammersley;
  109710. private _hemisphereSample_uniform;
  109711. private _generateHemisphere;
  109712. private _createSSAOPostProcess;
  109713. private _createSSAOCombinePostProcess;
  109714. private _createRandomTexture;
  109715. /**
  109716. * Serialize the rendering pipeline (Used when exporting)
  109717. * @returns the serialized object
  109718. */
  109719. serialize(): any;
  109720. /**
  109721. * Parse the serialized pipeline
  109722. * @param source Source pipeline.
  109723. * @param scene The scene to load the pipeline to.
  109724. * @param rootUrl The URL of the serialized pipeline.
  109725. * @returns An instantiated pipeline from the serialized object.
  109726. */
  109727. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109728. }
  109729. }
  109730. declare module BABYLON {
  109731. /** @hidden */
  109732. export var ssaoPixelShader: {
  109733. name: string;
  109734. shader: string;
  109735. };
  109736. }
  109737. declare module BABYLON {
  109738. /**
  109739. * Render pipeline to produce ssao effect
  109740. */
  109741. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109742. /**
  109743. * @ignore
  109744. * The PassPostProcess id in the pipeline that contains the original scene color
  109745. */
  109746. SSAOOriginalSceneColorEffect: string;
  109747. /**
  109748. * @ignore
  109749. * The SSAO PostProcess id in the pipeline
  109750. */
  109751. SSAORenderEffect: string;
  109752. /**
  109753. * @ignore
  109754. * The horizontal blur PostProcess id in the pipeline
  109755. */
  109756. SSAOBlurHRenderEffect: string;
  109757. /**
  109758. * @ignore
  109759. * The vertical blur PostProcess id in the pipeline
  109760. */
  109761. SSAOBlurVRenderEffect: string;
  109762. /**
  109763. * @ignore
  109764. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109765. */
  109766. SSAOCombineRenderEffect: string;
  109767. /**
  109768. * The output strength of the SSAO post-process. Default value is 1.0.
  109769. */
  109770. totalStrength: number;
  109771. /**
  109772. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109773. */
  109774. radius: number;
  109775. /**
  109776. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109777. * Must not be equal to fallOff and superior to fallOff.
  109778. * Default value is 0.0075
  109779. */
  109780. area: number;
  109781. /**
  109782. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109783. * Must not be equal to area and inferior to area.
  109784. * Default value is 0.000001
  109785. */
  109786. fallOff: number;
  109787. /**
  109788. * The base color of the SSAO post-process
  109789. * The final result is "base + ssao" between [0, 1]
  109790. */
  109791. base: number;
  109792. private _scene;
  109793. private _depthTexture;
  109794. private _randomTexture;
  109795. private _originalColorPostProcess;
  109796. private _ssaoPostProcess;
  109797. private _blurHPostProcess;
  109798. private _blurVPostProcess;
  109799. private _ssaoCombinePostProcess;
  109800. private _firstUpdate;
  109801. /**
  109802. * Gets active scene
  109803. */
  109804. readonly scene: Scene;
  109805. /**
  109806. * @constructor
  109807. * @param name - The rendering pipeline name
  109808. * @param scene - The scene linked to this pipeline
  109809. * @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 }
  109810. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109811. */
  109812. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109813. /**
  109814. * Get the class name
  109815. * @returns "SSAORenderingPipeline"
  109816. */
  109817. getClassName(): string;
  109818. /**
  109819. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109820. */
  109821. dispose(disableDepthRender?: boolean): void;
  109822. private _createBlurPostProcess;
  109823. /** @hidden */
  109824. _rebuild(): void;
  109825. private _createSSAOPostProcess;
  109826. private _createSSAOCombinePostProcess;
  109827. private _createRandomTexture;
  109828. }
  109829. }
  109830. declare module BABYLON {
  109831. /** @hidden */
  109832. export var standardPixelShader: {
  109833. name: string;
  109834. shader: string;
  109835. };
  109836. }
  109837. declare module BABYLON {
  109838. /**
  109839. * Standard rendering pipeline
  109840. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109841. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109842. */
  109843. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109844. /**
  109845. * Public members
  109846. */
  109847. /**
  109848. * Post-process which contains the original scene color before the pipeline applies all the effects
  109849. */
  109850. originalPostProcess: Nullable<PostProcess>;
  109851. /**
  109852. * Post-process used to down scale an image x4
  109853. */
  109854. downSampleX4PostProcess: Nullable<PostProcess>;
  109855. /**
  109856. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109857. */
  109858. brightPassPostProcess: Nullable<PostProcess>;
  109859. /**
  109860. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109861. */
  109862. blurHPostProcesses: PostProcess[];
  109863. /**
  109864. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109865. */
  109866. blurVPostProcesses: PostProcess[];
  109867. /**
  109868. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109869. */
  109870. textureAdderPostProcess: Nullable<PostProcess>;
  109871. /**
  109872. * Post-process used to create volumetric lighting effect
  109873. */
  109874. volumetricLightPostProcess: Nullable<PostProcess>;
  109875. /**
  109876. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109877. */
  109878. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109879. /**
  109880. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109881. */
  109882. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109883. /**
  109884. * Post-process used to merge the volumetric light effect and the real scene color
  109885. */
  109886. volumetricLightMergePostProces: Nullable<PostProcess>;
  109887. /**
  109888. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109889. */
  109890. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109891. /**
  109892. * Base post-process used to calculate the average luminance of the final image for HDR
  109893. */
  109894. luminancePostProcess: Nullable<PostProcess>;
  109895. /**
  109896. * Post-processes used to create down sample post-processes in order to get
  109897. * the average luminance of the final image for HDR
  109898. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109899. */
  109900. luminanceDownSamplePostProcesses: PostProcess[];
  109901. /**
  109902. * Post-process used to create a HDR effect (light adaptation)
  109903. */
  109904. hdrPostProcess: Nullable<PostProcess>;
  109905. /**
  109906. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109907. */
  109908. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109909. /**
  109910. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109911. */
  109912. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109913. /**
  109914. * Post-process used to merge the final HDR post-process and the real scene color
  109915. */
  109916. hdrFinalPostProcess: Nullable<PostProcess>;
  109917. /**
  109918. * Post-process used to create a lens flare effect
  109919. */
  109920. lensFlarePostProcess: Nullable<PostProcess>;
  109921. /**
  109922. * Post-process that merges the result of the lens flare post-process and the real scene color
  109923. */
  109924. lensFlareComposePostProcess: Nullable<PostProcess>;
  109925. /**
  109926. * Post-process used to create a motion blur effect
  109927. */
  109928. motionBlurPostProcess: Nullable<PostProcess>;
  109929. /**
  109930. * Post-process used to create a depth of field effect
  109931. */
  109932. depthOfFieldPostProcess: Nullable<PostProcess>;
  109933. /**
  109934. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109935. */
  109936. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109937. /**
  109938. * Represents the brightness threshold in order to configure the illuminated surfaces
  109939. */
  109940. brightThreshold: number;
  109941. /**
  109942. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109943. */
  109944. blurWidth: number;
  109945. /**
  109946. * Sets if the blur for highlighted surfaces must be only horizontal
  109947. */
  109948. horizontalBlur: boolean;
  109949. /**
  109950. * Sets the overall exposure used by the pipeline
  109951. */
  109952. exposure: number;
  109953. /**
  109954. * Texture used typically to simulate "dirty" on camera lens
  109955. */
  109956. lensTexture: Nullable<Texture>;
  109957. /**
  109958. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109959. */
  109960. volumetricLightCoefficient: number;
  109961. /**
  109962. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109963. */
  109964. volumetricLightPower: number;
  109965. /**
  109966. * Used the set the blur intensity to smooth the volumetric lights
  109967. */
  109968. volumetricLightBlurScale: number;
  109969. /**
  109970. * Light (spot or directional) used to generate the volumetric lights rays
  109971. * The source light must have a shadow generate so the pipeline can get its
  109972. * depth map
  109973. */
  109974. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109975. /**
  109976. * For eye adaptation, represents the minimum luminance the eye can see
  109977. */
  109978. hdrMinimumLuminance: number;
  109979. /**
  109980. * For eye adaptation, represents the decrease luminance speed
  109981. */
  109982. hdrDecreaseRate: number;
  109983. /**
  109984. * For eye adaptation, represents the increase luminance speed
  109985. */
  109986. hdrIncreaseRate: number;
  109987. /**
  109988. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109989. */
  109990. lensColorTexture: Nullable<Texture>;
  109991. /**
  109992. * The overall strengh for the lens flare effect
  109993. */
  109994. lensFlareStrength: number;
  109995. /**
  109996. * Dispersion coefficient for lens flare ghosts
  109997. */
  109998. lensFlareGhostDispersal: number;
  109999. /**
  110000. * Main lens flare halo width
  110001. */
  110002. lensFlareHaloWidth: number;
  110003. /**
  110004. * Based on the lens distortion effect, defines how much the lens flare result
  110005. * is distorted
  110006. */
  110007. lensFlareDistortionStrength: number;
  110008. /**
  110009. * Lens star texture must be used to simulate rays on the flares and is available
  110010. * in the documentation
  110011. */
  110012. lensStarTexture: Nullable<Texture>;
  110013. /**
  110014. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  110015. * flare effect by taking account of the dirt texture
  110016. */
  110017. lensFlareDirtTexture: Nullable<Texture>;
  110018. /**
  110019. * Represents the focal length for the depth of field effect
  110020. */
  110021. depthOfFieldDistance: number;
  110022. /**
  110023. * Represents the blur intensity for the blurred part of the depth of field effect
  110024. */
  110025. depthOfFieldBlurWidth: number;
  110026. /**
  110027. * For motion blur, defines how much the image is blurred by the movement
  110028. */
  110029. motionStrength: number;
  110030. /**
  110031. * List of animations for the pipeline (IAnimatable implementation)
  110032. */
  110033. animations: Animation[];
  110034. /**
  110035. * Private members
  110036. */
  110037. private _scene;
  110038. private _currentDepthOfFieldSource;
  110039. private _basePostProcess;
  110040. private _hdrCurrentLuminance;
  110041. private _floatTextureType;
  110042. private _ratio;
  110043. private _bloomEnabled;
  110044. private _depthOfFieldEnabled;
  110045. private _vlsEnabled;
  110046. private _lensFlareEnabled;
  110047. private _hdrEnabled;
  110048. private _motionBlurEnabled;
  110049. private _fxaaEnabled;
  110050. private _motionBlurSamples;
  110051. private _volumetricLightStepsCount;
  110052. private _samples;
  110053. /**
  110054. * @ignore
  110055. * Specifies if the bloom pipeline is enabled
  110056. */
  110057. BloomEnabled: boolean;
  110058. /**
  110059. * @ignore
  110060. * Specifies if the depth of field pipeline is enabed
  110061. */
  110062. DepthOfFieldEnabled: boolean;
  110063. /**
  110064. * @ignore
  110065. * Specifies if the lens flare pipeline is enabed
  110066. */
  110067. LensFlareEnabled: boolean;
  110068. /**
  110069. * @ignore
  110070. * Specifies if the HDR pipeline is enabled
  110071. */
  110072. HDREnabled: boolean;
  110073. /**
  110074. * @ignore
  110075. * Specifies if the volumetric lights scattering effect is enabled
  110076. */
  110077. VLSEnabled: boolean;
  110078. /**
  110079. * @ignore
  110080. * Specifies if the motion blur effect is enabled
  110081. */
  110082. MotionBlurEnabled: boolean;
  110083. /**
  110084. * Specifies if anti-aliasing is enabled
  110085. */
  110086. fxaaEnabled: boolean;
  110087. /**
  110088. * Specifies the number of steps used to calculate the volumetric lights
  110089. * Typically in interval [50, 200]
  110090. */
  110091. volumetricLightStepsCount: number;
  110092. /**
  110093. * Specifies the number of samples used for the motion blur effect
  110094. * Typically in interval [16, 64]
  110095. */
  110096. motionBlurSamples: number;
  110097. /**
  110098. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110099. */
  110100. samples: number;
  110101. /**
  110102. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110103. * @constructor
  110104. * @param name The rendering pipeline name
  110105. * @param scene The scene linked to this pipeline
  110106. * @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)
  110107. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110108. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110109. */
  110110. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110111. private _buildPipeline;
  110112. private _createDownSampleX4PostProcess;
  110113. private _createBrightPassPostProcess;
  110114. private _createBlurPostProcesses;
  110115. private _createTextureAdderPostProcess;
  110116. private _createVolumetricLightPostProcess;
  110117. private _createLuminancePostProcesses;
  110118. private _createHdrPostProcess;
  110119. private _createLensFlarePostProcess;
  110120. private _createDepthOfFieldPostProcess;
  110121. private _createMotionBlurPostProcess;
  110122. private _getDepthTexture;
  110123. private _disposePostProcesses;
  110124. /**
  110125. * Dispose of the pipeline and stop all post processes
  110126. */
  110127. dispose(): void;
  110128. /**
  110129. * Serialize the rendering pipeline (Used when exporting)
  110130. * @returns the serialized object
  110131. */
  110132. serialize(): any;
  110133. /**
  110134. * Parse the serialized pipeline
  110135. * @param source Source pipeline.
  110136. * @param scene The scene to load the pipeline to.
  110137. * @param rootUrl The URL of the serialized pipeline.
  110138. * @returns An instantiated pipeline from the serialized object.
  110139. */
  110140. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110141. /**
  110142. * Luminance steps
  110143. */
  110144. static LuminanceSteps: number;
  110145. }
  110146. }
  110147. declare module BABYLON {
  110148. /** @hidden */
  110149. export var tonemapPixelShader: {
  110150. name: string;
  110151. shader: string;
  110152. };
  110153. }
  110154. declare module BABYLON {
  110155. /** Defines operator used for tonemapping */
  110156. export enum TonemappingOperator {
  110157. /** Hable */
  110158. Hable = 0,
  110159. /** Reinhard */
  110160. Reinhard = 1,
  110161. /** HejiDawson */
  110162. HejiDawson = 2,
  110163. /** Photographic */
  110164. Photographic = 3
  110165. }
  110166. /**
  110167. * Defines a post process to apply tone mapping
  110168. */
  110169. export class TonemapPostProcess extends PostProcess {
  110170. private _operator;
  110171. /** Defines the required exposure adjustement */
  110172. exposureAdjustment: number;
  110173. /**
  110174. * Creates a new TonemapPostProcess
  110175. * @param name defines the name of the postprocess
  110176. * @param _operator defines the operator to use
  110177. * @param exposureAdjustment defines the required exposure adjustement
  110178. * @param camera defines the camera to use (can be null)
  110179. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110180. * @param engine defines the hosting engine (can be ignore if camera is set)
  110181. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110182. */
  110183. constructor(name: string, _operator: TonemappingOperator,
  110184. /** Defines the required exposure adjustement */
  110185. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110186. }
  110187. }
  110188. declare module BABYLON {
  110189. /** @hidden */
  110190. export var depthVertexShader: {
  110191. name: string;
  110192. shader: string;
  110193. };
  110194. }
  110195. declare module BABYLON {
  110196. /** @hidden */
  110197. export var volumetricLightScatteringPixelShader: {
  110198. name: string;
  110199. shader: string;
  110200. };
  110201. }
  110202. declare module BABYLON {
  110203. /** @hidden */
  110204. export var volumetricLightScatteringPassPixelShader: {
  110205. name: string;
  110206. shader: string;
  110207. };
  110208. }
  110209. declare module BABYLON {
  110210. /**
  110211. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110212. */
  110213. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110214. private _volumetricLightScatteringPass;
  110215. private _volumetricLightScatteringRTT;
  110216. private _viewPort;
  110217. private _screenCoordinates;
  110218. private _cachedDefines;
  110219. /**
  110220. * If not undefined, the mesh position is computed from the attached node position
  110221. */
  110222. attachedNode: {
  110223. position: Vector3;
  110224. };
  110225. /**
  110226. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110227. */
  110228. customMeshPosition: Vector3;
  110229. /**
  110230. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110231. */
  110232. useCustomMeshPosition: boolean;
  110233. /**
  110234. * If the post-process should inverse the light scattering direction
  110235. */
  110236. invert: boolean;
  110237. /**
  110238. * The internal mesh used by the post-process
  110239. */
  110240. mesh: Mesh;
  110241. /**
  110242. * @hidden
  110243. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110244. */
  110245. useDiffuseColor: boolean;
  110246. /**
  110247. * Array containing the excluded meshes not rendered in the internal pass
  110248. */
  110249. excludedMeshes: AbstractMesh[];
  110250. /**
  110251. * Controls the overall intensity of the post-process
  110252. */
  110253. exposure: number;
  110254. /**
  110255. * Dissipates each sample's contribution in range [0, 1]
  110256. */
  110257. decay: number;
  110258. /**
  110259. * Controls the overall intensity of each sample
  110260. */
  110261. weight: number;
  110262. /**
  110263. * Controls the density of each sample
  110264. */
  110265. density: number;
  110266. /**
  110267. * @constructor
  110268. * @param name The post-process name
  110269. * @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)
  110270. * @param camera The camera that the post-process will be attached to
  110271. * @param mesh The mesh used to create the light scattering
  110272. * @param samples The post-process quality, default 100
  110273. * @param samplingModeThe post-process filtering mode
  110274. * @param engine The babylon engine
  110275. * @param reusable If the post-process is reusable
  110276. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110277. */
  110278. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110279. /**
  110280. * Returns the string "VolumetricLightScatteringPostProcess"
  110281. * @returns "VolumetricLightScatteringPostProcess"
  110282. */
  110283. getClassName(): string;
  110284. private _isReady;
  110285. /**
  110286. * Sets the new light position for light scattering effect
  110287. * @param position The new custom light position
  110288. */
  110289. setCustomMeshPosition(position: Vector3): void;
  110290. /**
  110291. * Returns the light position for light scattering effect
  110292. * @return Vector3 The custom light position
  110293. */
  110294. getCustomMeshPosition(): Vector3;
  110295. /**
  110296. * Disposes the internal assets and detaches the post-process from the camera
  110297. */
  110298. dispose(camera: Camera): void;
  110299. /**
  110300. * Returns the render target texture used by the post-process
  110301. * @return the render target texture used by the post-process
  110302. */
  110303. getPass(): RenderTargetTexture;
  110304. private _meshExcluded;
  110305. private _createPass;
  110306. private _updateMeshScreenCoordinates;
  110307. /**
  110308. * Creates a default mesh for the Volumeric Light Scattering post-process
  110309. * @param name The mesh name
  110310. * @param scene The scene where to create the mesh
  110311. * @return the default mesh
  110312. */
  110313. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110314. }
  110315. }
  110316. declare module BABYLON {
  110317. interface Scene {
  110318. /** @hidden (Backing field) */
  110319. _boundingBoxRenderer: BoundingBoxRenderer;
  110320. /** @hidden (Backing field) */
  110321. _forceShowBoundingBoxes: boolean;
  110322. /**
  110323. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110324. */
  110325. forceShowBoundingBoxes: boolean;
  110326. /**
  110327. * Gets the bounding box renderer associated with the scene
  110328. * @returns a BoundingBoxRenderer
  110329. */
  110330. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110331. }
  110332. interface AbstractMesh {
  110333. /** @hidden (Backing field) */
  110334. _showBoundingBox: boolean;
  110335. /**
  110336. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110337. */
  110338. showBoundingBox: boolean;
  110339. }
  110340. /**
  110341. * Component responsible of rendering the bounding box of the meshes in a scene.
  110342. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110343. */
  110344. export class BoundingBoxRenderer implements ISceneComponent {
  110345. /**
  110346. * The component name helpfull to identify the component in the list of scene components.
  110347. */
  110348. readonly name: string;
  110349. /**
  110350. * The scene the component belongs to.
  110351. */
  110352. scene: Scene;
  110353. /**
  110354. * Color of the bounding box lines placed in front of an object
  110355. */
  110356. frontColor: Color3;
  110357. /**
  110358. * Color of the bounding box lines placed behind an object
  110359. */
  110360. backColor: Color3;
  110361. /**
  110362. * Defines if the renderer should show the back lines or not
  110363. */
  110364. showBackLines: boolean;
  110365. /**
  110366. * @hidden
  110367. */
  110368. renderList: SmartArray<BoundingBox>;
  110369. private _colorShader;
  110370. private _vertexBuffers;
  110371. private _indexBuffer;
  110372. /**
  110373. * Instantiates a new bounding box renderer in a scene.
  110374. * @param scene the scene the renderer renders in
  110375. */
  110376. constructor(scene: Scene);
  110377. /**
  110378. * Registers the component in a given scene
  110379. */
  110380. register(): void;
  110381. private _evaluateSubMesh;
  110382. private _activeMesh;
  110383. private _prepareRessources;
  110384. private _createIndexBuffer;
  110385. /**
  110386. * Rebuilds the elements related to this component in case of
  110387. * context lost for instance.
  110388. */
  110389. rebuild(): void;
  110390. /**
  110391. * @hidden
  110392. */
  110393. reset(): void;
  110394. /**
  110395. * Render the bounding boxes of a specific rendering group
  110396. * @param renderingGroupId defines the rendering group to render
  110397. */
  110398. render(renderingGroupId: number): void;
  110399. /**
  110400. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110401. * @param mesh Define the mesh to render the occlusion bounding box for
  110402. */
  110403. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110404. /**
  110405. * Dispose and release the resources attached to this renderer.
  110406. */
  110407. dispose(): void;
  110408. }
  110409. }
  110410. declare module BABYLON {
  110411. /** @hidden */
  110412. export var depthPixelShader: {
  110413. name: string;
  110414. shader: string;
  110415. };
  110416. }
  110417. declare module BABYLON {
  110418. /**
  110419. * This represents a depth renderer in Babylon.
  110420. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110421. */
  110422. export class DepthRenderer {
  110423. private _scene;
  110424. private _depthMap;
  110425. private _effect;
  110426. private _cachedDefines;
  110427. private _camera;
  110428. /**
  110429. * Specifiess that the depth renderer will only be used within
  110430. * the camera it is created for.
  110431. * This can help forcing its rendering during the camera processing.
  110432. */
  110433. useOnlyInActiveCamera: boolean;
  110434. /** @hidden */
  110435. static _SceneComponentInitialization: (scene: Scene) => void;
  110436. /**
  110437. * Instantiates a depth renderer
  110438. * @param scene The scene the renderer belongs to
  110439. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110440. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110441. */
  110442. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110443. /**
  110444. * Creates the depth rendering effect and checks if the effect is ready.
  110445. * @param subMesh The submesh to be used to render the depth map of
  110446. * @param useInstances If multiple world instances should be used
  110447. * @returns if the depth renderer is ready to render the depth map
  110448. */
  110449. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110450. /**
  110451. * Gets the texture which the depth map will be written to.
  110452. * @returns The depth map texture
  110453. */
  110454. getDepthMap(): RenderTargetTexture;
  110455. /**
  110456. * Disposes of the depth renderer.
  110457. */
  110458. dispose(): void;
  110459. }
  110460. }
  110461. declare module BABYLON {
  110462. interface Scene {
  110463. /** @hidden (Backing field) */
  110464. _depthRenderer: {
  110465. [id: string]: DepthRenderer;
  110466. };
  110467. /**
  110468. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110469. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110470. * @returns the created depth renderer
  110471. */
  110472. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110473. /**
  110474. * Disables a depth renderer for a given camera
  110475. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110476. */
  110477. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110478. }
  110479. /**
  110480. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110481. * in several rendering techniques.
  110482. */
  110483. export class DepthRendererSceneComponent implements ISceneComponent {
  110484. /**
  110485. * The component name helpfull to identify the component in the list of scene components.
  110486. */
  110487. readonly name: string;
  110488. /**
  110489. * The scene the component belongs to.
  110490. */
  110491. scene: Scene;
  110492. /**
  110493. * Creates a new instance of the component for the given scene
  110494. * @param scene Defines the scene to register the component in
  110495. */
  110496. constructor(scene: Scene);
  110497. /**
  110498. * Registers the component in a given scene
  110499. */
  110500. register(): void;
  110501. /**
  110502. * Rebuilds the elements related to this component in case of
  110503. * context lost for instance.
  110504. */
  110505. rebuild(): void;
  110506. /**
  110507. * Disposes the component and the associated ressources
  110508. */
  110509. dispose(): void;
  110510. private _gatherRenderTargets;
  110511. private _gatherActiveCameraRenderTargets;
  110512. }
  110513. }
  110514. declare module BABYLON {
  110515. /** @hidden */
  110516. export var outlinePixelShader: {
  110517. name: string;
  110518. shader: string;
  110519. };
  110520. }
  110521. declare module BABYLON {
  110522. /** @hidden */
  110523. export var outlineVertexShader: {
  110524. name: string;
  110525. shader: string;
  110526. };
  110527. }
  110528. declare module BABYLON {
  110529. interface Scene {
  110530. /** @hidden */
  110531. _outlineRenderer: OutlineRenderer;
  110532. /**
  110533. * Gets the outline renderer associated with the scene
  110534. * @returns a OutlineRenderer
  110535. */
  110536. getOutlineRenderer(): OutlineRenderer;
  110537. }
  110538. interface AbstractMesh {
  110539. /** @hidden (Backing field) */
  110540. _renderOutline: boolean;
  110541. /**
  110542. * Gets or sets a boolean indicating if the outline must be rendered as well
  110543. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110544. */
  110545. renderOutline: boolean;
  110546. /** @hidden (Backing field) */
  110547. _renderOverlay: boolean;
  110548. /**
  110549. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110550. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110551. */
  110552. renderOverlay: boolean;
  110553. }
  110554. /**
  110555. * This class is responsible to draw bothe outline/overlay of meshes.
  110556. * It should not be used directly but through the available method on mesh.
  110557. */
  110558. export class OutlineRenderer implements ISceneComponent {
  110559. /**
  110560. * The name of the component. Each component must have a unique name.
  110561. */
  110562. name: string;
  110563. /**
  110564. * The scene the component belongs to.
  110565. */
  110566. scene: Scene;
  110567. /**
  110568. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110569. */
  110570. zOffset: number;
  110571. private _engine;
  110572. private _effect;
  110573. private _cachedDefines;
  110574. private _savedDepthWrite;
  110575. /**
  110576. * Instantiates a new outline renderer. (There could be only one per scene).
  110577. * @param scene Defines the scene it belongs to
  110578. */
  110579. constructor(scene: Scene);
  110580. /**
  110581. * Register the component to one instance of a scene.
  110582. */
  110583. register(): void;
  110584. /**
  110585. * Rebuilds the elements related to this component in case of
  110586. * context lost for instance.
  110587. */
  110588. rebuild(): void;
  110589. /**
  110590. * Disposes the component and the associated ressources.
  110591. */
  110592. dispose(): void;
  110593. /**
  110594. * Renders the outline in the canvas.
  110595. * @param subMesh Defines the sumesh to render
  110596. * @param batch Defines the batch of meshes in case of instances
  110597. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110598. */
  110599. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110600. /**
  110601. * Returns whether or not the outline renderer is ready for a given submesh.
  110602. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110603. * @param subMesh Defines the submesh to check readyness for
  110604. * @param useInstances Defines wheter wee are trying to render instances or not
  110605. * @returns true if ready otherwise false
  110606. */
  110607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110608. private _beforeRenderingMesh;
  110609. private _afterRenderingMesh;
  110610. }
  110611. }
  110612. declare module BABYLON {
  110613. /**
  110614. * Defines the list of states available for a task inside a AssetsManager
  110615. */
  110616. export enum AssetTaskState {
  110617. /**
  110618. * Initialization
  110619. */
  110620. INIT = 0,
  110621. /**
  110622. * Running
  110623. */
  110624. RUNNING = 1,
  110625. /**
  110626. * Done
  110627. */
  110628. DONE = 2,
  110629. /**
  110630. * Error
  110631. */
  110632. ERROR = 3
  110633. }
  110634. /**
  110635. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110636. */
  110637. export abstract class AbstractAssetTask {
  110638. /**
  110639. * Task name
  110640. */ name: string;
  110641. /**
  110642. * Callback called when the task is successful
  110643. */
  110644. onSuccess: (task: any) => void;
  110645. /**
  110646. * Callback called when the task is not successful
  110647. */
  110648. onError: (task: any, message?: string, exception?: any) => void;
  110649. /**
  110650. * Creates a new AssetsManager
  110651. * @param name defines the name of the task
  110652. */
  110653. constructor(
  110654. /**
  110655. * Task name
  110656. */ name: string);
  110657. private _isCompleted;
  110658. private _taskState;
  110659. private _errorObject;
  110660. /**
  110661. * Get if the task is completed
  110662. */
  110663. readonly isCompleted: boolean;
  110664. /**
  110665. * Gets the current state of the task
  110666. */
  110667. readonly taskState: AssetTaskState;
  110668. /**
  110669. * Gets the current error object (if task is in error)
  110670. */
  110671. readonly errorObject: {
  110672. message?: string;
  110673. exception?: any;
  110674. };
  110675. /**
  110676. * Internal only
  110677. * @hidden
  110678. */
  110679. _setErrorObject(message?: string, exception?: any): void;
  110680. /**
  110681. * Execute the current task
  110682. * @param scene defines the scene where you want your assets to be loaded
  110683. * @param onSuccess is a callback called when the task is successfully executed
  110684. * @param onError is a callback called if an error occurs
  110685. */
  110686. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110687. /**
  110688. * Execute the current task
  110689. * @param scene defines the scene where you want your assets to be loaded
  110690. * @param onSuccess is a callback called when the task is successfully executed
  110691. * @param onError is a callback called if an error occurs
  110692. */
  110693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110694. /**
  110695. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110696. * This can be used with failed tasks that have the reason for failure fixed.
  110697. */
  110698. reset(): void;
  110699. private onErrorCallback;
  110700. private onDoneCallback;
  110701. }
  110702. /**
  110703. * Define the interface used by progress events raised during assets loading
  110704. */
  110705. export interface IAssetsProgressEvent {
  110706. /**
  110707. * Defines the number of remaining tasks to process
  110708. */
  110709. remainingCount: number;
  110710. /**
  110711. * Defines the total number of tasks
  110712. */
  110713. totalCount: number;
  110714. /**
  110715. * Defines the task that was just processed
  110716. */
  110717. task: AbstractAssetTask;
  110718. }
  110719. /**
  110720. * Class used to share progress information about assets loading
  110721. */
  110722. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110723. /**
  110724. * Defines the number of remaining tasks to process
  110725. */
  110726. remainingCount: number;
  110727. /**
  110728. * Defines the total number of tasks
  110729. */
  110730. totalCount: number;
  110731. /**
  110732. * Defines the task that was just processed
  110733. */
  110734. task: AbstractAssetTask;
  110735. /**
  110736. * Creates a AssetsProgressEvent
  110737. * @param remainingCount defines the number of remaining tasks to process
  110738. * @param totalCount defines the total number of tasks
  110739. * @param task defines the task that was just processed
  110740. */
  110741. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110742. }
  110743. /**
  110744. * Define a task used by AssetsManager to load meshes
  110745. */
  110746. export class MeshAssetTask extends AbstractAssetTask {
  110747. /**
  110748. * Defines the name of the task
  110749. */
  110750. name: string;
  110751. /**
  110752. * Defines the list of mesh's names you want to load
  110753. */
  110754. meshesNames: any;
  110755. /**
  110756. * Defines the root url to use as a base to load your meshes and associated resources
  110757. */
  110758. rootUrl: string;
  110759. /**
  110760. * Defines the filename of the scene to load from
  110761. */
  110762. sceneFilename: string;
  110763. /**
  110764. * Gets the list of loaded meshes
  110765. */
  110766. loadedMeshes: Array<AbstractMesh>;
  110767. /**
  110768. * Gets the list of loaded particle systems
  110769. */
  110770. loadedParticleSystems: Array<IParticleSystem>;
  110771. /**
  110772. * Gets the list of loaded skeletons
  110773. */
  110774. loadedSkeletons: Array<Skeleton>;
  110775. /**
  110776. * Gets the list of loaded animation groups
  110777. */
  110778. loadedAnimationGroups: Array<AnimationGroup>;
  110779. /**
  110780. * Callback called when the task is successful
  110781. */
  110782. onSuccess: (task: MeshAssetTask) => void;
  110783. /**
  110784. * Callback called when the task is successful
  110785. */
  110786. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110787. /**
  110788. * Creates a new MeshAssetTask
  110789. * @param name defines the name of the task
  110790. * @param meshesNames defines the list of mesh's names you want to load
  110791. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110792. * @param sceneFilename defines the filename of the scene to load from
  110793. */
  110794. constructor(
  110795. /**
  110796. * Defines the name of the task
  110797. */
  110798. name: string,
  110799. /**
  110800. * Defines the list of mesh's names you want to load
  110801. */
  110802. meshesNames: any,
  110803. /**
  110804. * Defines the root url to use as a base to load your meshes and associated resources
  110805. */
  110806. rootUrl: string,
  110807. /**
  110808. * Defines the filename of the scene to load from
  110809. */
  110810. sceneFilename: string);
  110811. /**
  110812. * Execute the current task
  110813. * @param scene defines the scene where you want your assets to be loaded
  110814. * @param onSuccess is a callback called when the task is successfully executed
  110815. * @param onError is a callback called if an error occurs
  110816. */
  110817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110818. }
  110819. /**
  110820. * Define a task used by AssetsManager to load text content
  110821. */
  110822. export class TextFileAssetTask extends AbstractAssetTask {
  110823. /**
  110824. * Defines the name of the task
  110825. */
  110826. name: string;
  110827. /**
  110828. * Defines the location of the file to load
  110829. */
  110830. url: string;
  110831. /**
  110832. * Gets the loaded text string
  110833. */
  110834. text: string;
  110835. /**
  110836. * Callback called when the task is successful
  110837. */
  110838. onSuccess: (task: TextFileAssetTask) => void;
  110839. /**
  110840. * Callback called when the task is successful
  110841. */
  110842. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110843. /**
  110844. * Creates a new TextFileAssetTask object
  110845. * @param name defines the name of the task
  110846. * @param url defines the location of the file to load
  110847. */
  110848. constructor(
  110849. /**
  110850. * Defines the name of the task
  110851. */
  110852. name: string,
  110853. /**
  110854. * Defines the location of the file to load
  110855. */
  110856. url: string);
  110857. /**
  110858. * Execute the current task
  110859. * @param scene defines the scene where you want your assets to be loaded
  110860. * @param onSuccess is a callback called when the task is successfully executed
  110861. * @param onError is a callback called if an error occurs
  110862. */
  110863. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110864. }
  110865. /**
  110866. * Define a task used by AssetsManager to load binary data
  110867. */
  110868. export class BinaryFileAssetTask extends AbstractAssetTask {
  110869. /**
  110870. * Defines the name of the task
  110871. */
  110872. name: string;
  110873. /**
  110874. * Defines the location of the file to load
  110875. */
  110876. url: string;
  110877. /**
  110878. * Gets the lodaded data (as an array buffer)
  110879. */
  110880. data: ArrayBuffer;
  110881. /**
  110882. * Callback called when the task is successful
  110883. */
  110884. onSuccess: (task: BinaryFileAssetTask) => void;
  110885. /**
  110886. * Callback called when the task is successful
  110887. */
  110888. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110889. /**
  110890. * Creates a new BinaryFileAssetTask object
  110891. * @param name defines the name of the new task
  110892. * @param url defines the location of the file to load
  110893. */
  110894. constructor(
  110895. /**
  110896. * Defines the name of the task
  110897. */
  110898. name: string,
  110899. /**
  110900. * Defines the location of the file to load
  110901. */
  110902. url: string);
  110903. /**
  110904. * Execute the current task
  110905. * @param scene defines the scene where you want your assets to be loaded
  110906. * @param onSuccess is a callback called when the task is successfully executed
  110907. * @param onError is a callback called if an error occurs
  110908. */
  110909. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110910. }
  110911. /**
  110912. * Define a task used by AssetsManager to load images
  110913. */
  110914. export class ImageAssetTask extends AbstractAssetTask {
  110915. /**
  110916. * Defines the name of the task
  110917. */
  110918. name: string;
  110919. /**
  110920. * Defines the location of the image to load
  110921. */
  110922. url: string;
  110923. /**
  110924. * Gets the loaded images
  110925. */
  110926. image: HTMLImageElement;
  110927. /**
  110928. * Callback called when the task is successful
  110929. */
  110930. onSuccess: (task: ImageAssetTask) => void;
  110931. /**
  110932. * Callback called when the task is successful
  110933. */
  110934. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110935. /**
  110936. * Creates a new ImageAssetTask
  110937. * @param name defines the name of the task
  110938. * @param url defines the location of the image to load
  110939. */
  110940. constructor(
  110941. /**
  110942. * Defines the name of the task
  110943. */
  110944. name: string,
  110945. /**
  110946. * Defines the location of the image to load
  110947. */
  110948. url: string);
  110949. /**
  110950. * Execute the current task
  110951. * @param scene defines the scene where you want your assets to be loaded
  110952. * @param onSuccess is a callback called when the task is successfully executed
  110953. * @param onError is a callback called if an error occurs
  110954. */
  110955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110956. }
  110957. /**
  110958. * Defines the interface used by texture loading tasks
  110959. */
  110960. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110961. /**
  110962. * Gets the loaded texture
  110963. */
  110964. texture: TEX;
  110965. }
  110966. /**
  110967. * Define a task used by AssetsManager to load 2D textures
  110968. */
  110969. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110970. /**
  110971. * Defines the name of the task
  110972. */
  110973. name: string;
  110974. /**
  110975. * Defines the location of the file to load
  110976. */
  110977. url: string;
  110978. /**
  110979. * Defines if mipmap should not be generated (default is false)
  110980. */
  110981. noMipmap?: boolean | undefined;
  110982. /**
  110983. * Defines if texture must be inverted on Y axis (default is false)
  110984. */
  110985. invertY?: boolean | undefined;
  110986. /**
  110987. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110988. */
  110989. samplingMode: number;
  110990. /**
  110991. * Gets the loaded texture
  110992. */
  110993. texture: Texture;
  110994. /**
  110995. * Callback called when the task is successful
  110996. */
  110997. onSuccess: (task: TextureAssetTask) => void;
  110998. /**
  110999. * Callback called when the task is successful
  111000. */
  111001. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  111002. /**
  111003. * Creates a new TextureAssetTask object
  111004. * @param name defines the name of the task
  111005. * @param url defines the location of the file to load
  111006. * @param noMipmap defines if mipmap should not be generated (default is false)
  111007. * @param invertY defines if texture must be inverted on Y axis (default is false)
  111008. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111009. */
  111010. constructor(
  111011. /**
  111012. * Defines the name of the task
  111013. */
  111014. name: string,
  111015. /**
  111016. * Defines the location of the file to load
  111017. */
  111018. url: string,
  111019. /**
  111020. * Defines if mipmap should not be generated (default is false)
  111021. */
  111022. noMipmap?: boolean | undefined,
  111023. /**
  111024. * Defines if texture must be inverted on Y axis (default is false)
  111025. */
  111026. invertY?: boolean | undefined,
  111027. /**
  111028. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111029. */
  111030. samplingMode?: number);
  111031. /**
  111032. * Execute the current task
  111033. * @param scene defines the scene where you want your assets to be loaded
  111034. * @param onSuccess is a callback called when the task is successfully executed
  111035. * @param onError is a callback called if an error occurs
  111036. */
  111037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111038. }
  111039. /**
  111040. * Define a task used by AssetsManager to load cube textures
  111041. */
  111042. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111043. /**
  111044. * Defines the name of the task
  111045. */
  111046. name: string;
  111047. /**
  111048. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111049. */
  111050. url: string;
  111051. /**
  111052. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111053. */
  111054. extensions?: string[] | undefined;
  111055. /**
  111056. * Defines if mipmaps should not be generated (default is false)
  111057. */
  111058. noMipmap?: boolean | undefined;
  111059. /**
  111060. * Defines the explicit list of files (undefined by default)
  111061. */
  111062. files?: string[] | undefined;
  111063. /**
  111064. * Gets the loaded texture
  111065. */
  111066. texture: CubeTexture;
  111067. /**
  111068. * Callback called when the task is successful
  111069. */
  111070. onSuccess: (task: CubeTextureAssetTask) => void;
  111071. /**
  111072. * Callback called when the task is successful
  111073. */
  111074. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111075. /**
  111076. * Creates a new CubeTextureAssetTask
  111077. * @param name defines the name of the task
  111078. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111079. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111080. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111081. * @param files defines the explicit list of files (undefined by default)
  111082. */
  111083. constructor(
  111084. /**
  111085. * Defines the name of the task
  111086. */
  111087. name: string,
  111088. /**
  111089. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111090. */
  111091. url: string,
  111092. /**
  111093. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111094. */
  111095. extensions?: string[] | undefined,
  111096. /**
  111097. * Defines if mipmaps should not be generated (default is false)
  111098. */
  111099. noMipmap?: boolean | undefined,
  111100. /**
  111101. * Defines the explicit list of files (undefined by default)
  111102. */
  111103. files?: string[] | undefined);
  111104. /**
  111105. * Execute the current task
  111106. * @param scene defines the scene where you want your assets to be loaded
  111107. * @param onSuccess is a callback called when the task is successfully executed
  111108. * @param onError is a callback called if an error occurs
  111109. */
  111110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111111. }
  111112. /**
  111113. * Define a task used by AssetsManager to load HDR cube textures
  111114. */
  111115. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111116. /**
  111117. * Defines the name of the task
  111118. */
  111119. name: string;
  111120. /**
  111121. * Defines the location of the file to load
  111122. */
  111123. url: string;
  111124. /**
  111125. * Defines the desired size (the more it increases the longer the generation will be)
  111126. */
  111127. size: number;
  111128. /**
  111129. * Defines if mipmaps should not be generated (default is false)
  111130. */
  111131. noMipmap: boolean;
  111132. /**
  111133. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111134. */
  111135. generateHarmonics: boolean;
  111136. /**
  111137. * 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)
  111138. */
  111139. gammaSpace: boolean;
  111140. /**
  111141. * Internal Use Only
  111142. */
  111143. reserved: boolean;
  111144. /**
  111145. * Gets the loaded texture
  111146. */
  111147. texture: HDRCubeTexture;
  111148. /**
  111149. * Callback called when the task is successful
  111150. */
  111151. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111152. /**
  111153. * Callback called when the task is successful
  111154. */
  111155. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111156. /**
  111157. * Creates a new HDRCubeTextureAssetTask object
  111158. * @param name defines the name of the task
  111159. * @param url defines the location of the file to load
  111160. * @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.
  111161. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111162. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111163. * @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)
  111164. * @param reserved Internal use only
  111165. */
  111166. constructor(
  111167. /**
  111168. * Defines the name of the task
  111169. */
  111170. name: string,
  111171. /**
  111172. * Defines the location of the file to load
  111173. */
  111174. url: string,
  111175. /**
  111176. * Defines the desired size (the more it increases the longer the generation will be)
  111177. */
  111178. size: number,
  111179. /**
  111180. * Defines if mipmaps should not be generated (default is false)
  111181. */
  111182. noMipmap?: boolean,
  111183. /**
  111184. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111185. */
  111186. generateHarmonics?: boolean,
  111187. /**
  111188. * 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)
  111189. */
  111190. gammaSpace?: boolean,
  111191. /**
  111192. * Internal Use Only
  111193. */
  111194. reserved?: boolean);
  111195. /**
  111196. * Execute the current task
  111197. * @param scene defines the scene where you want your assets to be loaded
  111198. * @param onSuccess is a callback called when the task is successfully executed
  111199. * @param onError is a callback called if an error occurs
  111200. */
  111201. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111202. }
  111203. /**
  111204. * This class can be used to easily import assets into a scene
  111205. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111206. */
  111207. export class AssetsManager {
  111208. private _scene;
  111209. private _isLoading;
  111210. protected _tasks: AbstractAssetTask[];
  111211. protected _waitingTasksCount: number;
  111212. protected _totalTasksCount: number;
  111213. /**
  111214. * Callback called when all tasks are processed
  111215. */
  111216. onFinish: (tasks: AbstractAssetTask[]) => void;
  111217. /**
  111218. * Callback called when a task is successful
  111219. */
  111220. onTaskSuccess: (task: AbstractAssetTask) => void;
  111221. /**
  111222. * Callback called when a task had an error
  111223. */
  111224. onTaskError: (task: AbstractAssetTask) => void;
  111225. /**
  111226. * Callback called when a task is done (whatever the result is)
  111227. */
  111228. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111229. /**
  111230. * Observable called when all tasks are processed
  111231. */
  111232. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111233. /**
  111234. * Observable called when a task had an error
  111235. */
  111236. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111237. /**
  111238. * Observable called when a task is successful
  111239. */
  111240. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111241. /**
  111242. * Observable called when a task is done (whatever the result is)
  111243. */
  111244. onProgressObservable: Observable<IAssetsProgressEvent>;
  111245. /**
  111246. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111248. */
  111249. useDefaultLoadingScreen: boolean;
  111250. /**
  111251. * Creates a new AssetsManager
  111252. * @param scene defines the scene to work on
  111253. */
  111254. constructor(scene: Scene);
  111255. /**
  111256. * Add a MeshAssetTask to the list of active tasks
  111257. * @param taskName defines the name of the new task
  111258. * @param meshesNames defines the name of meshes to load
  111259. * @param rootUrl defines the root url to use to locate files
  111260. * @param sceneFilename defines the filename of the scene file
  111261. * @returns a new MeshAssetTask object
  111262. */
  111263. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111264. /**
  111265. * Add a TextFileAssetTask to the list of active tasks
  111266. * @param taskName defines the name of the new task
  111267. * @param url defines the url of the file to load
  111268. * @returns a new TextFileAssetTask object
  111269. */
  111270. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111271. /**
  111272. * Add a BinaryFileAssetTask to the list of active tasks
  111273. * @param taskName defines the name of the new task
  111274. * @param url defines the url of the file to load
  111275. * @returns a new BinaryFileAssetTask object
  111276. */
  111277. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111278. /**
  111279. * Add a ImageAssetTask to the list of active tasks
  111280. * @param taskName defines the name of the new task
  111281. * @param url defines the url of the file to load
  111282. * @returns a new ImageAssetTask object
  111283. */
  111284. addImageTask(taskName: string, url: string): ImageAssetTask;
  111285. /**
  111286. * Add a TextureAssetTask to the list of active tasks
  111287. * @param taskName defines the name of the new task
  111288. * @param url defines the url of the file to load
  111289. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111290. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111291. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111292. * @returns a new TextureAssetTask object
  111293. */
  111294. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111295. /**
  111296. * Add a CubeTextureAssetTask to the list of active tasks
  111297. * @param taskName defines the name of the new task
  111298. * @param url defines the url of the file to load
  111299. * @param extensions defines the extension to use to load the cube map (can be null)
  111300. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111301. * @param files defines the list of files to load (can be null)
  111302. * @returns a new CubeTextureAssetTask object
  111303. */
  111304. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111305. /**
  111306. *
  111307. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111308. * @param taskName defines the name of the new task
  111309. * @param url defines the url of the file to load
  111310. * @param size defines the size you want for the cubemap (can be null)
  111311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111312. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111313. * @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)
  111314. * @param reserved Internal use only
  111315. * @returns a new HDRCubeTextureAssetTask object
  111316. */
  111317. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111318. /**
  111319. * Remove a task from the assets manager.
  111320. * @param task the task to remove
  111321. */
  111322. removeTask(task: AbstractAssetTask): void;
  111323. private _decreaseWaitingTasksCount;
  111324. private _runTask;
  111325. /**
  111326. * Reset the AssetsManager and remove all tasks
  111327. * @return the current instance of the AssetsManager
  111328. */
  111329. reset(): AssetsManager;
  111330. /**
  111331. * Start the loading process
  111332. * @return the current instance of the AssetsManager
  111333. */
  111334. load(): AssetsManager;
  111335. }
  111336. }
  111337. declare module BABYLON {
  111338. /**
  111339. * Wrapper class for promise with external resolve and reject.
  111340. */
  111341. export class Deferred<T> {
  111342. /**
  111343. * The promise associated with this deferred object.
  111344. */
  111345. readonly promise: Promise<T>;
  111346. private _resolve;
  111347. private _reject;
  111348. /**
  111349. * The resolve method of the promise associated with this deferred object.
  111350. */
  111351. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111352. /**
  111353. * The reject method of the promise associated with this deferred object.
  111354. */
  111355. readonly reject: (reason?: any) => void;
  111356. /**
  111357. * Constructor for this deferred object.
  111358. */
  111359. constructor();
  111360. }
  111361. }
  111362. declare module BABYLON {
  111363. /**
  111364. * Class used to help managing file picking and drag'n'drop
  111365. */
  111366. export class FilesInput {
  111367. /**
  111368. * List of files ready to be loaded
  111369. */
  111370. static readonly FilesToLoad: {
  111371. [key: string]: File;
  111372. };
  111373. /**
  111374. * Callback called when a file is processed
  111375. */
  111376. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111377. private _engine;
  111378. private _currentScene;
  111379. private _sceneLoadedCallback;
  111380. private _progressCallback;
  111381. private _additionalRenderLoopLogicCallback;
  111382. private _textureLoadingCallback;
  111383. private _startingProcessingFilesCallback;
  111384. private _onReloadCallback;
  111385. private _errorCallback;
  111386. private _elementToMonitor;
  111387. private _sceneFileToLoad;
  111388. private _filesToLoad;
  111389. /**
  111390. * Creates a new FilesInput
  111391. * @param engine defines the rendering engine
  111392. * @param scene defines the hosting scene
  111393. * @param sceneLoadedCallback callback called when scene is loaded
  111394. * @param progressCallback callback called to track progress
  111395. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111396. * @param textureLoadingCallback callback called when a texture is loading
  111397. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111398. * @param onReloadCallback callback called when a reload is requested
  111399. * @param errorCallback callback call if an error occurs
  111400. */
  111401. 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);
  111402. private _dragEnterHandler;
  111403. private _dragOverHandler;
  111404. private _dropHandler;
  111405. /**
  111406. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111407. * @param elementToMonitor defines the DOM element to track
  111408. */
  111409. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111410. /**
  111411. * Release all associated resources
  111412. */
  111413. dispose(): void;
  111414. private renderFunction;
  111415. private drag;
  111416. private drop;
  111417. private _traverseFolder;
  111418. private _processFiles;
  111419. /**
  111420. * Load files from a drop event
  111421. * @param event defines the drop event to use as source
  111422. */
  111423. loadFiles(event: any): void;
  111424. private _processReload;
  111425. /**
  111426. * Reload the current scene from the loaded files
  111427. */
  111428. reload(): void;
  111429. }
  111430. }
  111431. declare module BABYLON {
  111432. /**
  111433. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111435. */
  111436. export class SceneOptimization {
  111437. /**
  111438. * Defines the priority of this optimization (0 by default which means first in the list)
  111439. */
  111440. priority: number;
  111441. /**
  111442. * Gets a string describing the action executed by the current optimization
  111443. * @returns description string
  111444. */
  111445. getDescription(): string;
  111446. /**
  111447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111448. * @param scene defines the current scene where to apply this optimization
  111449. * @param optimizer defines the current optimizer
  111450. * @returns true if everything that can be done was applied
  111451. */
  111452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111453. /**
  111454. * Creates the SceneOptimization object
  111455. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111456. * @param desc defines the description associated with the optimization
  111457. */
  111458. constructor(
  111459. /**
  111460. * Defines the priority of this optimization (0 by default which means first in the list)
  111461. */
  111462. priority?: number);
  111463. }
  111464. /**
  111465. * Defines an optimization used to reduce the size of render target textures
  111466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111467. */
  111468. export class TextureOptimization extends SceneOptimization {
  111469. /**
  111470. * Defines the priority of this optimization (0 by default which means first in the list)
  111471. */
  111472. priority: number;
  111473. /**
  111474. * 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
  111475. */
  111476. maximumSize: number;
  111477. /**
  111478. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111479. */
  111480. step: number;
  111481. /**
  111482. * Gets a string describing the action executed by the current optimization
  111483. * @returns description string
  111484. */
  111485. getDescription(): string;
  111486. /**
  111487. * Creates the TextureOptimization object
  111488. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111489. * @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
  111490. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111491. */
  111492. constructor(
  111493. /**
  111494. * Defines the priority of this optimization (0 by default which means first in the list)
  111495. */
  111496. priority?: number,
  111497. /**
  111498. * 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
  111499. */
  111500. maximumSize?: number,
  111501. /**
  111502. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111503. */
  111504. step?: number);
  111505. /**
  111506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111507. * @param scene defines the current scene where to apply this optimization
  111508. * @param optimizer defines the current optimizer
  111509. * @returns true if everything that can be done was applied
  111510. */
  111511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111512. }
  111513. /**
  111514. * Defines an optimization used to increase or decrease the rendering resolution
  111515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111516. */
  111517. export class HardwareScalingOptimization extends SceneOptimization {
  111518. /**
  111519. * Defines the priority of this optimization (0 by default which means first in the list)
  111520. */
  111521. priority: number;
  111522. /**
  111523. * Defines the maximum scale to use (2 by default)
  111524. */
  111525. maximumScale: number;
  111526. /**
  111527. * Defines the step to use between two passes (0.5 by default)
  111528. */
  111529. step: number;
  111530. private _currentScale;
  111531. private _directionOffset;
  111532. /**
  111533. * Gets a string describing the action executed by the current optimization
  111534. * @return description string
  111535. */
  111536. getDescription(): string;
  111537. /**
  111538. * Creates the HardwareScalingOptimization object
  111539. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111540. * @param maximumScale defines the maximum scale to use (2 by default)
  111541. * @param step defines the step to use between two passes (0.5 by default)
  111542. */
  111543. constructor(
  111544. /**
  111545. * Defines the priority of this optimization (0 by default which means first in the list)
  111546. */
  111547. priority?: number,
  111548. /**
  111549. * Defines the maximum scale to use (2 by default)
  111550. */
  111551. maximumScale?: number,
  111552. /**
  111553. * Defines the step to use between two passes (0.5 by default)
  111554. */
  111555. step?: number);
  111556. /**
  111557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111558. * @param scene defines the current scene where to apply this optimization
  111559. * @param optimizer defines the current optimizer
  111560. * @returns true if everything that can be done was applied
  111561. */
  111562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111563. }
  111564. /**
  111565. * Defines an optimization used to remove shadows
  111566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111567. */
  111568. export class ShadowsOptimization extends SceneOptimization {
  111569. /**
  111570. * Gets a string describing the action executed by the current optimization
  111571. * @return description string
  111572. */
  111573. getDescription(): string;
  111574. /**
  111575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111576. * @param scene defines the current scene where to apply this optimization
  111577. * @param optimizer defines the current optimizer
  111578. * @returns true if everything that can be done was applied
  111579. */
  111580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111581. }
  111582. /**
  111583. * Defines an optimization used to turn post-processes off
  111584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111585. */
  111586. export class PostProcessesOptimization extends SceneOptimization {
  111587. /**
  111588. * Gets a string describing the action executed by the current optimization
  111589. * @return description string
  111590. */
  111591. getDescription(): string;
  111592. /**
  111593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111594. * @param scene defines the current scene where to apply this optimization
  111595. * @param optimizer defines the current optimizer
  111596. * @returns true if everything that can be done was applied
  111597. */
  111598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111599. }
  111600. /**
  111601. * Defines an optimization used to turn lens flares off
  111602. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111603. */
  111604. export class LensFlaresOptimization extends SceneOptimization {
  111605. /**
  111606. * Gets a string describing the action executed by the current optimization
  111607. * @return description string
  111608. */
  111609. getDescription(): string;
  111610. /**
  111611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111612. * @param scene defines the current scene where to apply this optimization
  111613. * @param optimizer defines the current optimizer
  111614. * @returns true if everything that can be done was applied
  111615. */
  111616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111617. }
  111618. /**
  111619. * Defines an optimization based on user defined callback.
  111620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111621. */
  111622. export class CustomOptimization extends SceneOptimization {
  111623. /**
  111624. * Callback called to apply the custom optimization.
  111625. */
  111626. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111627. /**
  111628. * Callback called to get custom description
  111629. */
  111630. onGetDescription: () => string;
  111631. /**
  111632. * Gets a string describing the action executed by the current optimization
  111633. * @returns description string
  111634. */
  111635. getDescription(): string;
  111636. /**
  111637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111638. * @param scene defines the current scene where to apply this optimization
  111639. * @param optimizer defines the current optimizer
  111640. * @returns true if everything that can be done was applied
  111641. */
  111642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111643. }
  111644. /**
  111645. * Defines an optimization used to turn particles off
  111646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111647. */
  111648. export class ParticlesOptimization extends SceneOptimization {
  111649. /**
  111650. * Gets a string describing the action executed by the current optimization
  111651. * @return description string
  111652. */
  111653. getDescription(): string;
  111654. /**
  111655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111656. * @param scene defines the current scene where to apply this optimization
  111657. * @param optimizer defines the current optimizer
  111658. * @returns true if everything that can be done was applied
  111659. */
  111660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111661. }
  111662. /**
  111663. * Defines an optimization used to turn render targets off
  111664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111665. */
  111666. export class RenderTargetsOptimization extends SceneOptimization {
  111667. /**
  111668. * Gets a string describing the action executed by the current optimization
  111669. * @return description string
  111670. */
  111671. getDescription(): string;
  111672. /**
  111673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111674. * @param scene defines the current scene where to apply this optimization
  111675. * @param optimizer defines the current optimizer
  111676. * @returns true if everything that can be done was applied
  111677. */
  111678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111679. }
  111680. /**
  111681. * Defines an optimization used to merge meshes with compatible materials
  111682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111683. */
  111684. export class MergeMeshesOptimization extends SceneOptimization {
  111685. private static _UpdateSelectionTree;
  111686. /**
  111687. * Gets or sets a boolean which defines if optimization octree has to be updated
  111688. */
  111689. /**
  111690. * Gets or sets a boolean which defines if optimization octree has to be updated
  111691. */
  111692. static UpdateSelectionTree: boolean;
  111693. /**
  111694. * Gets a string describing the action executed by the current optimization
  111695. * @return description string
  111696. */
  111697. getDescription(): string;
  111698. private _canBeMerged;
  111699. /**
  111700. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111701. * @param scene defines the current scene where to apply this optimization
  111702. * @param optimizer defines the current optimizer
  111703. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111704. * @returns true if everything that can be done was applied
  111705. */
  111706. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111707. }
  111708. /**
  111709. * Defines a list of options used by SceneOptimizer
  111710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111711. */
  111712. export class SceneOptimizerOptions {
  111713. /**
  111714. * Defines the target frame rate to reach (60 by default)
  111715. */
  111716. targetFrameRate: number;
  111717. /**
  111718. * Defines the interval between two checkes (2000ms by default)
  111719. */
  111720. trackerDuration: number;
  111721. /**
  111722. * Gets the list of optimizations to apply
  111723. */
  111724. optimizations: SceneOptimization[];
  111725. /**
  111726. * Creates a new list of options used by SceneOptimizer
  111727. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111728. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111729. */
  111730. constructor(
  111731. /**
  111732. * Defines the target frame rate to reach (60 by default)
  111733. */
  111734. targetFrameRate?: number,
  111735. /**
  111736. * Defines the interval between two checkes (2000ms by default)
  111737. */
  111738. trackerDuration?: number);
  111739. /**
  111740. * Add a new optimization
  111741. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111742. * @returns the current SceneOptimizerOptions
  111743. */
  111744. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111745. /**
  111746. * Add a new custom optimization
  111747. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111748. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111749. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111750. * @returns the current SceneOptimizerOptions
  111751. */
  111752. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111753. /**
  111754. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111755. * @param targetFrameRate defines the target frame rate (60 by default)
  111756. * @returns a SceneOptimizerOptions object
  111757. */
  111758. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111759. /**
  111760. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111761. * @param targetFrameRate defines the target frame rate (60 by default)
  111762. * @returns a SceneOptimizerOptions object
  111763. */
  111764. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111765. /**
  111766. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111767. * @param targetFrameRate defines the target frame rate (60 by default)
  111768. * @returns a SceneOptimizerOptions object
  111769. */
  111770. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111771. }
  111772. /**
  111773. * Class used to run optimizations in order to reach a target frame rate
  111774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111775. */
  111776. export class SceneOptimizer implements IDisposable {
  111777. private _isRunning;
  111778. private _options;
  111779. private _scene;
  111780. private _currentPriorityLevel;
  111781. private _targetFrameRate;
  111782. private _trackerDuration;
  111783. private _currentFrameRate;
  111784. private _sceneDisposeObserver;
  111785. private _improvementMode;
  111786. /**
  111787. * Defines an observable called when the optimizer reaches the target frame rate
  111788. */
  111789. onSuccessObservable: Observable<SceneOptimizer>;
  111790. /**
  111791. * Defines an observable called when the optimizer enables an optimization
  111792. */
  111793. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111794. /**
  111795. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111796. */
  111797. onFailureObservable: Observable<SceneOptimizer>;
  111798. /**
  111799. * Gets a boolean indicating if the optimizer is in improvement mode
  111800. */
  111801. readonly isInImprovementMode: boolean;
  111802. /**
  111803. * Gets the current priority level (0 at start)
  111804. */
  111805. readonly currentPriorityLevel: number;
  111806. /**
  111807. * Gets the current frame rate checked by the SceneOptimizer
  111808. */
  111809. readonly currentFrameRate: number;
  111810. /**
  111811. * Gets or sets the current target frame rate (60 by default)
  111812. */
  111813. /**
  111814. * Gets or sets the current target frame rate (60 by default)
  111815. */
  111816. targetFrameRate: number;
  111817. /**
  111818. * Gets or sets the current interval between two checks (every 2000ms by default)
  111819. */
  111820. /**
  111821. * Gets or sets the current interval between two checks (every 2000ms by default)
  111822. */
  111823. trackerDuration: number;
  111824. /**
  111825. * Gets the list of active optimizations
  111826. */
  111827. readonly optimizations: SceneOptimization[];
  111828. /**
  111829. * Creates a new SceneOptimizer
  111830. * @param scene defines the scene to work on
  111831. * @param options defines the options to use with the SceneOptimizer
  111832. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111833. * @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)
  111834. */
  111835. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111836. /**
  111837. * Stops the current optimizer
  111838. */
  111839. stop(): void;
  111840. /**
  111841. * Reset the optimizer to initial step (current priority level = 0)
  111842. */
  111843. reset(): void;
  111844. /**
  111845. * Start the optimizer. By default it will try to reach a specific framerate
  111846. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111847. */
  111848. start(): void;
  111849. private _checkCurrentState;
  111850. /**
  111851. * Release all resources
  111852. */
  111853. dispose(): void;
  111854. /**
  111855. * Helper function to create a SceneOptimizer with one single line of code
  111856. * @param scene defines the scene to work on
  111857. * @param options defines the options to use with the SceneOptimizer
  111858. * @param onSuccess defines a callback to call on success
  111859. * @param onFailure defines a callback to call on failure
  111860. * @returns the new SceneOptimizer object
  111861. */
  111862. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111863. }
  111864. }
  111865. declare module BABYLON {
  111866. /**
  111867. * Class used to serialize a scene into a string
  111868. */
  111869. export class SceneSerializer {
  111870. /**
  111871. * Clear cache used by a previous serialization
  111872. */
  111873. static ClearCache(): void;
  111874. /**
  111875. * Serialize a scene into a JSON compatible object
  111876. * @param scene defines the scene to serialize
  111877. * @returns a JSON compatible object
  111878. */
  111879. static Serialize(scene: Scene): any;
  111880. /**
  111881. * Serialize a mesh into a JSON compatible object
  111882. * @param toSerialize defines the mesh to serialize
  111883. * @param withParents defines if parents must be serialized as well
  111884. * @param withChildren defines if children must be serialized as well
  111885. * @returns a JSON compatible object
  111886. */
  111887. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111888. }
  111889. }
  111890. declare module BABYLON {
  111891. /**
  111892. * This represents the different options avilable for the video capture.
  111893. */
  111894. export interface VideoRecorderOptions {
  111895. /** Defines the mime type of the video */
  111896. mimeType: string;
  111897. /** Defines the video the video should be recorded at */
  111898. fps: number;
  111899. /** Defines the chunk size for the recording data */
  111900. recordChunckSize: number;
  111901. /** The audio tracks to attach to the record */
  111902. audioTracks?: MediaStreamTrack[];
  111903. }
  111904. /**
  111905. * This can helps recording videos from BabylonJS.
  111906. * This is based on the available WebRTC functionalities of the browser.
  111907. *
  111908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111909. */
  111910. export class VideoRecorder {
  111911. private static readonly _defaultOptions;
  111912. /**
  111913. * Returns wehther or not the VideoRecorder is available in your browser.
  111914. * @param engine Defines the Babylon Engine to check the support for
  111915. * @returns true if supported otherwise false
  111916. */
  111917. static IsSupported(engine: Engine): boolean;
  111918. private readonly _options;
  111919. private _canvas;
  111920. private _mediaRecorder;
  111921. private _recordedChunks;
  111922. private _fileName;
  111923. private _resolve;
  111924. private _reject;
  111925. /**
  111926. * True wether a recording is already in progress.
  111927. */
  111928. readonly isRecording: boolean;
  111929. /**
  111930. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111931. * a video file.
  111932. * @param engine Defines the BabylonJS Engine you wish to record
  111933. * @param options Defines options that can be used to customized the capture
  111934. */
  111935. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111936. /**
  111937. * Stops the current recording before the default capture timeout passed in the startRecording
  111938. * functions.
  111939. */
  111940. stopRecording(): void;
  111941. /**
  111942. * Starts recording the canvas for a max duration specified in parameters.
  111943. * @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.
  111944. * @param maxDuration Defines the maximum recording time in seconds.
  111945. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111946. * @return a promise callback at the end of the recording with the video data in Blob.
  111947. */
  111948. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111949. /**
  111950. * Releases internal resources used during the recording.
  111951. */
  111952. dispose(): void;
  111953. private _handleDataAvailable;
  111954. private _handleError;
  111955. private _handleStop;
  111956. }
  111957. }
  111958. declare module BABYLON {
  111959. /**
  111960. * Helper class to push actions to a pool of workers.
  111961. */
  111962. export class WorkerPool implements IDisposable {
  111963. private _workerInfos;
  111964. private _pendingActions;
  111965. /**
  111966. * Constructor
  111967. * @param workers Array of workers to use for actions
  111968. */
  111969. constructor(workers: Array<Worker>);
  111970. /**
  111971. * Terminates all workers and clears any pending actions.
  111972. */
  111973. dispose(): void;
  111974. /**
  111975. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111976. * pended until a worker has completed its action.
  111977. * @param action The action to perform. Call onComplete when the action is complete.
  111978. */
  111979. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111980. private _execute;
  111981. }
  111982. }
  111983. declare module BABYLON {
  111984. /**
  111985. * Class containing a set of static utilities functions for screenshots
  111986. */
  111987. export class ScreenshotTools {
  111988. /**
  111989. * Captures a screenshot of the current rendering
  111990. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111991. * @param engine defines the rendering engine
  111992. * @param camera defines the source camera
  111993. * @param size This parameter can be set to a single number or to an object with the
  111994. * following (optional) properties: precision, width, height. If a single number is passed,
  111995. * it will be used for both width and height. If an object is passed, the screenshot size
  111996. * will be derived from the parameters. The precision property is a multiplier allowing
  111997. * rendering at a higher or lower resolution
  111998. * @param successCallback defines the callback receives a single parameter which contains the
  111999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112000. * src parameter of an <img> to display it
  112001. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  112002. * Check your browser for supported MIME types
  112003. */
  112004. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  112005. /**
  112006. * Generates an image screenshot from the specified camera.
  112007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  112008. * @param engine The engine to use for rendering
  112009. * @param camera The camera to use for rendering
  112010. * @param size This parameter can be set to a single number or to an object with the
  112011. * following (optional) properties: precision, width, height. If a single number is passed,
  112012. * it will be used for both width and height. If an object is passed, the screenshot size
  112013. * will be derived from the parameters. The precision property is a multiplier allowing
  112014. * rendering at a higher or lower resolution
  112015. * @param successCallback The callback receives a single parameter which contains the
  112016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  112017. * src parameter of an <img> to display it
  112018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  112019. * Check your browser for supported MIME types
  112020. * @param samples Texture samples (default: 1)
  112021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112022. * @param fileName A name for for the downloaded file.
  112023. */
  112024. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112025. }
  112026. }
  112027. declare module BABYLON {
  112028. /**
  112029. * A cursor which tracks a point on a path
  112030. */
  112031. export class PathCursor {
  112032. private path;
  112033. /**
  112034. * Stores path cursor callbacks for when an onchange event is triggered
  112035. */
  112036. private _onchange;
  112037. /**
  112038. * The value of the path cursor
  112039. */
  112040. value: number;
  112041. /**
  112042. * The animation array of the path cursor
  112043. */
  112044. animations: Animation[];
  112045. /**
  112046. * Initializes the path cursor
  112047. * @param path The path to track
  112048. */
  112049. constructor(path: Path2);
  112050. /**
  112051. * Gets the cursor point on the path
  112052. * @returns A point on the path cursor at the cursor location
  112053. */
  112054. getPoint(): Vector3;
  112055. /**
  112056. * Moves the cursor ahead by the step amount
  112057. * @param step The amount to move the cursor forward
  112058. * @returns This path cursor
  112059. */
  112060. moveAhead(step?: number): PathCursor;
  112061. /**
  112062. * Moves the cursor behind by the step amount
  112063. * @param step The amount to move the cursor back
  112064. * @returns This path cursor
  112065. */
  112066. moveBack(step?: number): PathCursor;
  112067. /**
  112068. * Moves the cursor by the step amount
  112069. * If the step amount is greater than one, an exception is thrown
  112070. * @param step The amount to move the cursor
  112071. * @returns This path cursor
  112072. */
  112073. move(step: number): PathCursor;
  112074. /**
  112075. * Ensures that the value is limited between zero and one
  112076. * @returns This path cursor
  112077. */
  112078. private ensureLimits;
  112079. /**
  112080. * Runs onchange callbacks on change (used by the animation engine)
  112081. * @returns This path cursor
  112082. */
  112083. private raiseOnChange;
  112084. /**
  112085. * Executes a function on change
  112086. * @param f A path cursor onchange callback
  112087. * @returns This path cursor
  112088. */
  112089. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112090. }
  112091. }
  112092. declare module BABYLON {
  112093. /** @hidden */
  112094. export var blurPixelShader: {
  112095. name: string;
  112096. shader: string;
  112097. };
  112098. }
  112099. declare module BABYLON {
  112100. /** @hidden */
  112101. export var bones300Declaration: {
  112102. name: string;
  112103. shader: string;
  112104. };
  112105. }
  112106. declare module BABYLON {
  112107. /** @hidden */
  112108. export var instances300Declaration: {
  112109. name: string;
  112110. shader: string;
  112111. };
  112112. }
  112113. declare module BABYLON {
  112114. /** @hidden */
  112115. export var pointCloudVertexDeclaration: {
  112116. name: string;
  112117. shader: string;
  112118. };
  112119. }
  112120. // Mixins
  112121. interface Window {
  112122. mozIndexedDB: IDBFactory;
  112123. webkitIndexedDB: IDBFactory;
  112124. msIndexedDB: IDBFactory;
  112125. webkitURL: typeof URL;
  112126. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112127. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112128. WebGLRenderingContext: WebGLRenderingContext;
  112129. MSGesture: MSGesture;
  112130. CANNON: any;
  112131. AudioContext: AudioContext;
  112132. webkitAudioContext: AudioContext;
  112133. PointerEvent: any;
  112134. Math: Math;
  112135. Uint8Array: Uint8ArrayConstructor;
  112136. Float32Array: Float32ArrayConstructor;
  112137. mozURL: typeof URL;
  112138. msURL: typeof URL;
  112139. VRFrameData: any; // WebVR, from specs 1.1
  112140. DracoDecoderModule: any;
  112141. setImmediate(handler: (...args: any[]) => void): number;
  112142. }
  112143. interface HTMLCanvasElement {
  112144. requestPointerLock(): void;
  112145. msRequestPointerLock?(): void;
  112146. mozRequestPointerLock?(): void;
  112147. webkitRequestPointerLock?(): void;
  112148. /** Track wether a record is in progress */
  112149. isRecording: boolean;
  112150. /** Capture Stream method defined by some browsers */
  112151. captureStream(fps?: number): MediaStream;
  112152. }
  112153. interface CanvasRenderingContext2D {
  112154. msImageSmoothingEnabled: boolean;
  112155. }
  112156. interface MouseEvent {
  112157. mozMovementX: number;
  112158. mozMovementY: number;
  112159. webkitMovementX: number;
  112160. webkitMovementY: number;
  112161. msMovementX: number;
  112162. msMovementY: number;
  112163. }
  112164. interface Navigator {
  112165. mozGetVRDevices: (any: any) => any;
  112166. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112167. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112168. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112169. webkitGetGamepads(): Gamepad[];
  112170. msGetGamepads(): Gamepad[];
  112171. webkitGamepads(): Gamepad[];
  112172. }
  112173. interface HTMLVideoElement {
  112174. mozSrcObject: any;
  112175. }
  112176. interface Math {
  112177. fround(x: number): number;
  112178. imul(a: number, b: number): number;
  112179. }
  112180. interface WebGLProgram {
  112181. context?: WebGLRenderingContext;
  112182. vertexShader?: WebGLShader;
  112183. fragmentShader?: WebGLShader;
  112184. isParallelCompiled: boolean;
  112185. onCompiled?: () => void;
  112186. }
  112187. interface WebGLRenderingContext {
  112188. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112189. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112190. vertexAttribDivisor(index: number, divisor: number): void;
  112191. createVertexArray(): any;
  112192. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112193. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112194. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112195. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112196. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112197. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112198. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112199. // Queries
  112200. createQuery(): WebGLQuery;
  112201. deleteQuery(query: WebGLQuery): void;
  112202. beginQuery(target: number, query: WebGLQuery): void;
  112203. endQuery(target: number): void;
  112204. getQueryParameter(query: WebGLQuery, pname: number): any;
  112205. getQuery(target: number, pname: number): any;
  112206. MAX_SAMPLES: number;
  112207. RGBA8: number;
  112208. READ_FRAMEBUFFER: number;
  112209. DRAW_FRAMEBUFFER: number;
  112210. UNIFORM_BUFFER: number;
  112211. HALF_FLOAT_OES: number;
  112212. RGBA16F: number;
  112213. RGBA32F: number;
  112214. R32F: number;
  112215. RG32F: number;
  112216. RGB32F: number;
  112217. R16F: number;
  112218. RG16F: number;
  112219. RGB16F: number;
  112220. RED: number;
  112221. RG: number;
  112222. R8: number;
  112223. RG8: number;
  112224. UNSIGNED_INT_24_8: number;
  112225. DEPTH24_STENCIL8: number;
  112226. /* Multiple Render Targets */
  112227. drawBuffers(buffers: number[]): void;
  112228. readBuffer(src: number): void;
  112229. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112230. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112231. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112232. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112233. // Occlusion Query
  112234. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112235. ANY_SAMPLES_PASSED: number;
  112236. QUERY_RESULT_AVAILABLE: number;
  112237. QUERY_RESULT: number;
  112238. }
  112239. interface WebGLBuffer {
  112240. references: number;
  112241. capacity: number;
  112242. is32Bits: boolean;
  112243. }
  112244. interface WebGLProgram {
  112245. transformFeedback?: WebGLTransformFeedback | null;
  112246. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112247. }
  112248. interface EXT_disjoint_timer_query {
  112249. QUERY_COUNTER_BITS_EXT: number;
  112250. TIME_ELAPSED_EXT: number;
  112251. TIMESTAMP_EXT: number;
  112252. GPU_DISJOINT_EXT: number;
  112253. QUERY_RESULT_EXT: number;
  112254. QUERY_RESULT_AVAILABLE_EXT: number;
  112255. queryCounterEXT(query: WebGLQuery, target: number): void;
  112256. createQueryEXT(): WebGLQuery;
  112257. beginQueryEXT(target: number, query: WebGLQuery): void;
  112258. endQueryEXT(target: number): void;
  112259. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112260. deleteQueryEXT(query: WebGLQuery): void;
  112261. }
  112262. interface WebGLUniformLocation {
  112263. _currentState: any;
  112264. }
  112265. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112266. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112267. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112268. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112269. interface WebGLRenderingContext {
  112270. readonly RASTERIZER_DISCARD: number;
  112271. readonly DEPTH_COMPONENT24: number;
  112272. readonly TEXTURE_3D: number;
  112273. readonly TEXTURE_2D_ARRAY: number;
  112274. readonly TEXTURE_COMPARE_FUNC: number;
  112275. readonly TEXTURE_COMPARE_MODE: number;
  112276. readonly COMPARE_REF_TO_TEXTURE: number;
  112277. readonly TEXTURE_WRAP_R: number;
  112278. readonly HALF_FLOAT: number;
  112279. readonly RGB8: number;
  112280. readonly RED_INTEGER: number;
  112281. readonly RG_INTEGER: number;
  112282. readonly RGB_INTEGER: number;
  112283. readonly RGBA_INTEGER: number;
  112284. readonly R8_SNORM: number;
  112285. readonly RG8_SNORM: number;
  112286. readonly RGB8_SNORM: number;
  112287. readonly RGBA8_SNORM: number;
  112288. readonly R8I: number;
  112289. readonly RG8I: number;
  112290. readonly RGB8I: number;
  112291. readonly RGBA8I: number;
  112292. readonly R8UI: number;
  112293. readonly RG8UI: number;
  112294. readonly RGB8UI: number;
  112295. readonly RGBA8UI: number;
  112296. readonly R16I: number;
  112297. readonly RG16I: number;
  112298. readonly RGB16I: number;
  112299. readonly RGBA16I: number;
  112300. readonly R16UI: number;
  112301. readonly RG16UI: number;
  112302. readonly RGB16UI: number;
  112303. readonly RGBA16UI: number;
  112304. readonly R32I: number;
  112305. readonly RG32I: number;
  112306. readonly RGB32I: number;
  112307. readonly RGBA32I: number;
  112308. readonly R32UI: number;
  112309. readonly RG32UI: number;
  112310. readonly RGB32UI: number;
  112311. readonly RGBA32UI: number;
  112312. readonly RGB10_A2UI: number;
  112313. readonly R11F_G11F_B10F: number;
  112314. readonly RGB9_E5: number;
  112315. readonly RGB10_A2: number;
  112316. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112317. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112318. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112319. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112320. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112321. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112322. 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;
  112323. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112324. readonly TRANSFORM_FEEDBACK: number;
  112325. readonly INTERLEAVED_ATTRIBS: number;
  112326. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112327. createTransformFeedback(): WebGLTransformFeedback;
  112328. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112329. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112330. beginTransformFeedback(primitiveMode: number): void;
  112331. endTransformFeedback(): void;
  112332. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112333. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112334. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112335. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112336. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112337. }
  112338. interface ImageBitmap {
  112339. readonly width: number;
  112340. readonly height: number;
  112341. close(): void;
  112342. }
  112343. interface WebGLQuery extends WebGLObject {
  112344. }
  112345. declare var WebGLQuery: {
  112346. prototype: WebGLQuery;
  112347. new(): WebGLQuery;
  112348. };
  112349. interface WebGLSampler extends WebGLObject {
  112350. }
  112351. declare var WebGLSampler: {
  112352. prototype: WebGLSampler;
  112353. new(): WebGLSampler;
  112354. };
  112355. interface WebGLSync extends WebGLObject {
  112356. }
  112357. declare var WebGLSync: {
  112358. prototype: WebGLSync;
  112359. new(): WebGLSync;
  112360. };
  112361. interface WebGLTransformFeedback extends WebGLObject {
  112362. }
  112363. declare var WebGLTransformFeedback: {
  112364. prototype: WebGLTransformFeedback;
  112365. new(): WebGLTransformFeedback;
  112366. };
  112367. interface WebGLVertexArrayObject extends WebGLObject {
  112368. }
  112369. declare var WebGLVertexArrayObject: {
  112370. prototype: WebGLVertexArrayObject;
  112371. new(): WebGLVertexArrayObject;
  112372. };
  112373. // Type definitions for WebVR API
  112374. // Project: https://w3c.github.io/webvr/
  112375. // Definitions by: six a <https://github.com/lostfictions>
  112376. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112377. interface VRDisplay extends EventTarget {
  112378. /**
  112379. * Dictionary of capabilities describing the VRDisplay.
  112380. */
  112381. readonly capabilities: VRDisplayCapabilities;
  112382. /**
  112383. * z-depth defining the far plane of the eye view frustum
  112384. * enables mapping of values in the render target depth
  112385. * attachment to scene coordinates. Initially set to 10000.0.
  112386. */
  112387. depthFar: number;
  112388. /**
  112389. * z-depth defining the near plane of the eye view frustum
  112390. * enables mapping of values in the render target depth
  112391. * attachment to scene coordinates. Initially set to 0.01.
  112392. */
  112393. depthNear: number;
  112394. /**
  112395. * An identifier for this distinct VRDisplay. Used as an
  112396. * association point in the Gamepad API.
  112397. */
  112398. readonly displayId: number;
  112399. /**
  112400. * A display name, a user-readable name identifying it.
  112401. */
  112402. readonly displayName: string;
  112403. readonly isConnected: boolean;
  112404. readonly isPresenting: boolean;
  112405. /**
  112406. * If this VRDisplay supports room-scale experiences, the optional
  112407. * stage attribute contains details on the room-scale parameters.
  112408. */
  112409. readonly stageParameters: VRStageParameters | null;
  112410. /**
  112411. * Passing the value returned by `requestAnimationFrame` to
  112412. * `cancelAnimationFrame` will unregister the callback.
  112413. * @param handle Define the hanle of the request to cancel
  112414. */
  112415. cancelAnimationFrame(handle: number): void;
  112416. /**
  112417. * Stops presenting to the VRDisplay.
  112418. * @returns a promise to know when it stopped
  112419. */
  112420. exitPresent(): Promise<void>;
  112421. /**
  112422. * Return the current VREyeParameters for the given eye.
  112423. * @param whichEye Define the eye we want the parameter for
  112424. * @returns the eye parameters
  112425. */
  112426. getEyeParameters(whichEye: string): VREyeParameters;
  112427. /**
  112428. * Populates the passed VRFrameData with the information required to render
  112429. * the current frame.
  112430. * @param frameData Define the data structure to populate
  112431. * @returns true if ok otherwise false
  112432. */
  112433. getFrameData(frameData: VRFrameData): boolean;
  112434. /**
  112435. * Get the layers currently being presented.
  112436. * @returns the list of VR layers
  112437. */
  112438. getLayers(): VRLayer[];
  112439. /**
  112440. * Return a VRPose containing the future predicted pose of the VRDisplay
  112441. * when the current frame will be presented. The value returned will not
  112442. * change until JavaScript has returned control to the browser.
  112443. *
  112444. * The VRPose will contain the position, orientation, velocity,
  112445. * and acceleration of each of these properties.
  112446. * @returns the pose object
  112447. */
  112448. getPose(): VRPose;
  112449. /**
  112450. * Return the current instantaneous pose of the VRDisplay, with no
  112451. * prediction applied.
  112452. * @returns the current instantaneous pose
  112453. */
  112454. getImmediatePose(): VRPose;
  112455. /**
  112456. * The callback passed to `requestAnimationFrame` will be called
  112457. * any time a new frame should be rendered. When the VRDisplay is
  112458. * presenting the callback will be called at the native refresh
  112459. * rate of the HMD. When not presenting this function acts
  112460. * identically to how window.requestAnimationFrame acts. Content should
  112461. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112462. * asynchronously from other displays and at differing refresh rates.
  112463. * @param callback Define the eaction to run next frame
  112464. * @returns the request handle it
  112465. */
  112466. requestAnimationFrame(callback: FrameRequestCallback): number;
  112467. /**
  112468. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112469. * Repeat calls while already presenting will update the VRLayers being displayed.
  112470. * @param layers Define the list of layer to present
  112471. * @returns a promise to know when the request has been fulfilled
  112472. */
  112473. requestPresent(layers: VRLayer[]): Promise<void>;
  112474. /**
  112475. * Reset the pose for this display, treating its current position and
  112476. * orientation as the "origin/zero" values. VRPose.position,
  112477. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112478. * updated when calling resetPose(). This should be called in only
  112479. * sitting-space experiences.
  112480. */
  112481. resetPose(): void;
  112482. /**
  112483. * The VRLayer provided to the VRDisplay will be captured and presented
  112484. * in the HMD. Calling this function has the same effect on the source
  112485. * canvas as any other operation that uses its source image, and canvases
  112486. * created without preserveDrawingBuffer set to true will be cleared.
  112487. * @param pose Define the pose to submit
  112488. */
  112489. submitFrame(pose?: VRPose): void;
  112490. }
  112491. declare var VRDisplay: {
  112492. prototype: VRDisplay;
  112493. new(): VRDisplay;
  112494. };
  112495. interface VRLayer {
  112496. leftBounds?: number[] | Float32Array | null;
  112497. rightBounds?: number[] | Float32Array | null;
  112498. source?: HTMLCanvasElement | null;
  112499. }
  112500. interface VRDisplayCapabilities {
  112501. readonly canPresent: boolean;
  112502. readonly hasExternalDisplay: boolean;
  112503. readonly hasOrientation: boolean;
  112504. readonly hasPosition: boolean;
  112505. readonly maxLayers: number;
  112506. }
  112507. interface VREyeParameters {
  112508. /** @deprecated */
  112509. readonly fieldOfView: VRFieldOfView;
  112510. readonly offset: Float32Array;
  112511. readonly renderHeight: number;
  112512. readonly renderWidth: number;
  112513. }
  112514. interface VRFieldOfView {
  112515. readonly downDegrees: number;
  112516. readonly leftDegrees: number;
  112517. readonly rightDegrees: number;
  112518. readonly upDegrees: number;
  112519. }
  112520. interface VRFrameData {
  112521. readonly leftProjectionMatrix: Float32Array;
  112522. readonly leftViewMatrix: Float32Array;
  112523. readonly pose: VRPose;
  112524. readonly rightProjectionMatrix: Float32Array;
  112525. readonly rightViewMatrix: Float32Array;
  112526. readonly timestamp: number;
  112527. }
  112528. interface VRPose {
  112529. readonly angularAcceleration: Float32Array | null;
  112530. readonly angularVelocity: Float32Array | null;
  112531. readonly linearAcceleration: Float32Array | null;
  112532. readonly linearVelocity: Float32Array | null;
  112533. readonly orientation: Float32Array | null;
  112534. readonly position: Float32Array | null;
  112535. readonly timestamp: number;
  112536. }
  112537. interface VRStageParameters {
  112538. sittingToStandingTransform?: Float32Array;
  112539. sizeX?: number;
  112540. sizeY?: number;
  112541. }
  112542. interface Navigator {
  112543. getVRDisplays(): Promise<VRDisplay[]>;
  112544. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112545. }
  112546. interface Window {
  112547. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112548. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112549. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112550. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112551. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112552. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112553. }
  112554. interface Gamepad {
  112555. readonly displayId: number;
  112556. }
  112557. interface XRDevice {
  112558. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112559. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112560. }
  112561. interface XRSession {
  112562. getInputSources(): Array<any>;
  112563. baseLayer: XRWebGLLayer;
  112564. requestFrameOfReference(type: string): Promise<void>;
  112565. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112566. end(): Promise<void>;
  112567. requestAnimationFrame: Function;
  112568. addEventListener: Function;
  112569. }
  112570. interface XRSessionCreationOptions {
  112571. outputContext?: WebGLRenderingContext | null;
  112572. immersive?: boolean;
  112573. environmentIntegration?: boolean;
  112574. }
  112575. interface XRLayer {
  112576. getViewport: Function;
  112577. framebufferWidth: number;
  112578. framebufferHeight: number;
  112579. }
  112580. interface XRView {
  112581. projectionMatrix: Float32Array;
  112582. }
  112583. interface XRFrame {
  112584. getDevicePose: Function;
  112585. getInputPose: Function;
  112586. views: Array<XRView>;
  112587. baseLayer: XRLayer;
  112588. }
  112589. interface XRFrameOfReference {
  112590. }
  112591. interface XRWebGLLayer extends XRLayer {
  112592. framebuffer: WebGLFramebuffer;
  112593. }
  112594. declare var XRWebGLLayer: {
  112595. prototype: XRWebGLLayer;
  112596. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112597. };